Create a new product on module activation

For my module I need to create a couple of default products. But I’m having difficulty figuring out how to lookup the uofm field from my product template definition I just put in eval="16" and that evaluates to Foot but there must be another way to do this. I looked here but didn’t see anything I could use to do this. Is it possible?

<tryton>
  <data>
      <record model="product.template" id="yc-dockerage-fee">
        <field name="name">My Fee</field>
        <field name="code">my-fee</field>
        <field name="type">goods</field>
        <field name="default_uom" eval="16"/>
      </record>...

This is usually a bad idea. Many product properties depend on the company, the accounting etc.

You should use the ref attribute with the value product.uom_foot (which is the module name and the id of the record).

1 Like

Of course - thank you !

Agreed I was weighing this option with a wizard-style that would add the products programmatically post-installation. I’ll take your advice and just make this a manual process for the time being until I have finished work in other areas.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.