Sunday 15 January 2012

Explanation of eval attribute in product.template in OpenErp -



Explanation of eval attribute in product.template in OpenErp -

i need understand eval attribute in next code in product_demo.xml in 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 attribute_line_ids value beingness set here. understand values within 'ref' refers xml ids would, in short, homecoming model-'product.attribute.line associate xml id.

i don't understand each of values in eval attribute mean , changes on view level , db level. have referred many odoo documentation none provide clarity.

this adds bunch of values many2many field called attribute_line_ids. odoo has special syntax setting values on many2many fields. syntax described here , used in code asked about.

basically, modify many2many relation utilize three-element tuple. first element of tuple numeric command, , 2 other elements values - exact function depend on command.

there 6 numeric commands:

0 - creates new object , adds many2many relation 1 - updates object exists on relation 2 - deletes object exists on relation 3 - removes existing object relation, without deleting it 4 - adds existing object relation 5 - removes objects relation, without deleting them 6 - replaces pervious objects existing on relation new set of objects

the relevant part of code this:

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

it's three-element tuple (which expected, since code sets values on many2many relation):

the first element command. "6" means elements existing in relation (if any) replaced elements ids passed 3rd element of tuple. the sec argument irrelevant. has role other commands, when used "6" can (personally utilize none improve reflect this). the 3rd element list of ids. since first element "6", signifies objects set relation, replacing whatever there.

eval openerp odoo

No comments:

Post a Comment