Create Product without Creating new Template Proteus

Hello, I am a big Fan of Proteus but i have a Problem. I am trying to immigrate many Products at once, so i wrote a script. But it is quiet slowly (1,5 Seconds per Record).

Product = Model.get(‘product.product’)
Uom= Model.get(‘product.uom’)
Template = Model.get(‘product.template’)

    allUom=Uom.find()
    stück= allUom[26]

    template = Template(
        name=bezeichnung,
        default_uom=stück,
        code=Code,
        list_price=Decimal(0),
        producible=False,
        consumable=False,
        type='goods')

    print("Artikel: "+bezeichnung+" "+Code+" wurde hinzugefügt")
    template.save()
    product=Product(template=template)
    product.save()

Is there a way to boost up the Speed? Why do i need to generate a new Template every-time i create a new Product?

I searched for answers in the Forum but i just find this approach:

but its kind of the same Think.

Instead of saving each record one by one, you should save all of them at once like:

products = []
for …:
    products.append(Product(…))
Product.save(products)

But proteus is not designed to be specially fast but to mimic precisely the client behavior.
You can use a trytond-console script instead where you must code more but can use the ORM optimization.

The best is to create one template and use the default product on it.
So the code would be like:

template = Template(…)
product, = template.products
product.name = "…"
template.save()
1 Like