Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4727 Vizualizări

Hi, I am using Odoo 14 I am trying to update a many 2 many field from Server Action, but it seems Odoo is protecting itself because it gets back in a second to the original values. I am trying to link an invoice to as sale order, so I am using:

record.write({'invoice_ids': [(3, 456)]}) #456 is the record of the invoice
raise Warning(record.invoice_ids)

The warning shows that the new Id has been appended to the current values, but if I check again in the next second, the values get back to the original. Any clue on how to make them persistent?

Thx.


Imagine profil
Abandonează
Autor Cel mai bun răspuns

Hi Jainesh Shah,

Thank you for your response. I tried what you suggest, but I receive the following User Errror: "You cannot delete an entry which has been posted once."

So I think that what this code tries to do is delete the records, maybe there is my error. I don't want to delete nor create records. I just want to create a relationship between the current record with another record throught its many2many field.

Explicitly, what I want to do is add two existing invoices to an existing sale order because my user mistakenlty created the invoice by duplicating the previous one. Any clue?

Best Regards!

Imagine profil
Abandonează
Cel mai bun răspuns

Hello Oscar del Rio,

(3,id) will remove record from field but not permanently so if you want to remove this record permanently you can use (2,id) and (4,id) to add existing record in many2many field


Please refer below link for better understanding.
https://www.odoo.com/documentation/15.0/developer/reference/backend/orm.html?highlight=many2many#odoo.fields.Many2many

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
oct. 22
3100
2
mai 23
5289
1
oct. 22
4135
1
feb. 17
3246
2
ian. 17
7083