Hello, i'm really struggling with an issue recently
i have a one2many / many2one relation between ResPartner/product.template.
i have a many2many widget to create the link between the two objects.
(add products linked to the respartner)
However i have an api.onchange on a boolean that trigger the unlink that lead to an error :
ERROR adir odoo.sql_db: bad query: DELETE FROM "product_template" WHERE id IN (24)
ERROR: update or delete on table "product_product" violates foreign key constraint "sale_order_line_product_id_fkey" on table "sale_order_line"
DETAIL: Key (id)=(32) is still referenced from table "sale_order_line".
WARNING adir odoo.http: L'opération ne peut pas être terminée : un autre modèle nécessite la suppression de l'enregistrement. Si possible, archivez-le à la place.
Modèle : Sales Order Line (sale.order.line)
Contrainte : sale_order_line_product_id_fkey
my code is when i do an api.onchange on a boolean :
for product in self.custom_products :
self.write({'custom_products ' : [(3,product.id)]})
i really don't understand WHY there is query with a DELETE ???
all my many2one fields avec ondelete='set null', tried also 'restrict'.....
in product :
product_custom_holder = fields.Many2one('res.partner' ,ondelete='set null')
in res partner
custom_products = fields.One2many('product.template')