Explanation of eval attribute in product.template file in OpenErp

I need to understand the attribute eval

in the following code in product_demo.xml in a product module in Odoo:

"record id="product_product_4_product_template" model="product.template">
            field name="attribute_line_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])]"/>
        </record>"

      

I understand that a value has been set here attribute_line_ids

. I also understand that the values ​​inside "ref" refer to XML identifiers, which, in short, return the -product.attribute.line model associated with the XML identifier.

I really don't understand what each of the values ​​in the attribute means eval

and what changes it will make at the level and db level. I have mentioned many documents on separate documents but none could provide clarity.

+3


source to share


1 answer


This adds a bunch of values ​​to a field Many2many

called attribute_line_ids

. Odoo has special syntax for setting field values Many2many

. This syntax is described here and used in the code you requested.

Basically, to change the many2many relationship, you use a 3-tuple. The first element of the tuple is a numeric command and the other two are values ​​- their exact function depends on the command.

There are six numeric commands:

  • 0 - creates a new object and adds it to the relationMany2many

  • 1 - updates an object that already exists in the relation
  • 2 - removes an object that already exists in the relation
  • 3 - removes an existing object from a relationship without deleting it
  • 4 - adds an existing object to the relation
  • 5 - removes all objects from the relationship without deleting them
  • 6 - replaces checked objects existing in relation to a new set of objects


The relevant part of your code looks like this:

(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])

      

This is a three-element tuple (which is expected as the code sets values ​​in a relation Many2many

):

  • The first element is the command. "6" means that elements that previously existed in the relation (if any) will be replaced with elements whose identifiers are passed as the third element of the tuple.
  • The second argument is irrelevant. It plays a role with other commands, but when used with "6" it can be anything (I personally would use None

    to better reflect this).
  • The third element is a list of identifiers. Since the first element is "6", this means the objects to be placed in the relation, replacing everything that came before.
+8


source







All Articles