-1

I am trying to enter some registers that according to the model are many2one, but Odoo shows me an error message.

Can you help me?

XML File:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="account.payment.term" id="account_payment_term_6">
    <field name="name">10 Dias</field>
    <field name="active" eval="True" />
    <field name="line_ids" eval="[(6, 0), ({'value_amount': '0.0', 'value': > Saldo', 'days2': '0', 'days': '10'})]"/>
</record>
</odoo>

Error:

File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2283, in write
comodel.browse(act[2]).write({inverse: record.id})
odoo.tools.convert.ParseError: "tuple index out of range" while parsing /mnt/extra-addons/import/data/account_payment_term.xml:3, near
<record model="account.payment.term" id="account_payment_term_6">
    <field name="name">10 Dias</field>
    <field name="active" eval="True"/>
    <field name="line_ids" eval="[(6, 0), ({'value_amount': '0.0', 'value': 'Saldo', 'days2': '0', 'days': '10'})]"/>
</record>

Thanks for your help

1 Answers1

0

When you use (6,0) semantic, it only accepts a list of ids. Here you passing key-value pair, so you need to use (0,0).

If you want to create a new record with the key-value pair then you have to use [(0,0),{values}] or you trying to link already existing records either use [(4,ID)] or [(6,0,[IDs])].

Try below code:

 <record model="account.payment.term" id="account_payment_term_6">
<field name="name">10 Dias</field>
<field name="active" eval="True"/>
<field name="line_ids" eval="[(0, 0), ({'value_amount': '0.0', 'value': 'Saldo', 'days2': '0', 'days': '10'})]"/>
</record>

These are the existing semantics for editing/updating, deleting and so, please refer the below samples which are used for both One2Many & Many2Many.

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary

(1, ID, { values }) update the linked record with id = ID (write values on it)

(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

(4, ID) link to existing record with id = ID (adds a relationship)

(5) unlink all (like using (3,ID) for all linked records)

(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Hope it will help you.

KbiR
  • 4,047
  • 6
  • 37
  • 103
  • Thanks for the reply, but my problem still has no solution. Where can you find documentation on this topic that shows examples? – Carlos Soto Jun 28 '18 at 21:12