Reputation: 35
Today I tried to import some configuration from one data base of Odoo to another (User-defined Defaults) and everything looks ok, but the default values that i'm trying to insert to my new data base (for many2many fields) don't work. I believed it was by for the csv file and i try to add using xml record like this:
<record id="hr_test_record" model="ir.values">
<field name="value_unpickle">2</field>
<field name="name">struct_id</field>
<field name="model">hr.contract</field>
<field name="key">default</field>
<field name="value">I2 .</field>
</record>
but in the database space (for value) appears this way after install the module
S'2' + p0 + .
And has to look like this
I2 + .
I know this but how can apply this? I is for Integer S is for string V is for value
Upvotes: 2
Views: 588
Reputation: 51
To store the value as integer, you must use XML notation to encode the \n character (result of pickle.dumps operation) and must not specify a value for the field "value_unpickle".
e.g.
<record id="hr_test_record" model="ir.values">
<field name="name">struct_id</field>
<field name="model">hr.contract</field>
<field name="key">default</field>
<field name="key2"/>
<field name="value">I2 .</field>
</record>
note that you also need to set key2 to empty string if you don't want any conditions/qualifiers for your default value.
(the above is tested in odoo 10)
Upvotes: 0