From 3695886531a66aa93f31e979c6d23b8865cbef0f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 10 Dec 2014 11:21:17 +0100 Subject: [PATCH] [FIX] account: avoid losing product on invoice Add restriction on product_id field to prevent the suppression of the product if already present in an invoice. This is to avoid the suppression of a used product variant when modifying the list of attributes.# Due to the constrain, the variant will be disabled instead of deleted. Fixes #4129 Add warning message on the product form to warn users about the potential impact of modifying variants. --- addons/account/account_invoice.py | 2 +- addons/product/product_view.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index e94a60a545c..e2eddf5b9b0 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1261,7 +1261,7 @@ class account_invoice_line(models.Model): uos_id = fields.Many2one('product.uom', string='Unit of Measure', ondelete='set null', index=True) product_id = fields.Many2one('product.product', string='Product', - ondelete='set null', index=True) + ondelete='restrict', index=True) account_id = fields.Many2one('account.account', string='Account', required=True, domain=[('type', 'not in', ['view', 'closed'])], default=_default_account, diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index c764ab06045..01c9ff2d721 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -250,6 +250,11 @@ +

+ Warning: adding or deleting attributes + will delete and recreate existing variants and lead + to the loss of its eventual customizations. +