Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1933 Widoki

Hello everyone, I'm trying to update the data in a model, but when I execute the code:

models.execute_kw(config['ODOO']['DATABASE'], uid, config['ODOO']['PASSWORD'], 'motorcycle.motorcycle', 'write', [[22981], {'product_ids': [76]}])

I receive the following error:

The operation cannot be completed: another model requires the record being deleted. If possible, archive it instead.\n\nModel: Unknown (unknown)\nConstraint: product_product_motorcycle_motorcycle_rel_product_id_fkey\n'>


The field is a Many2one type and, the Odoo version is 16.0


Does anyone knoknow what could be happening?

Awatar
Odrzuć
Najlepsza odpowiedź

The product_ids field type is many2many od One2many so you can write to it as below:

models.execute_kw(config['ODOO']['DATABASE'], uid, config['ODOO']['PASSWORD'], 'motorcycle.motorcycle', 'write', [[22981], {'product_ids': [(4, 76)]}])

More details in the below link:

ORM API — Odoo 16.0 documentation

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 24
916
0
wrz 24
460
0
sty 23
1528
1
maj 24
2920
2
maj 24
1299