[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.
This commit is contained in:
Martin Trigaux 2014-12-10 11:21:17 +01:00
parent 5d60c1c887
commit 3695886531
2 changed files with 6 additions and 1 deletions

View File

@ -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,

View File

@ -250,6 +250,11 @@
<field string="List of Variants" name="product_variant_count" widget="statinfo" />
</button>
</div>
<p class="oe_grey">
<strong>Warning</strong>: adding or deleting attributes
will delete and recreate existing variants and lead
to the loss of its eventual customizations.
</p>
<field name="attribute_line_ids" widget="one2many_list" context="{'show_attribute': False}">
<tree string="Variants" editable="bottom">
<field name="attribute_id"/>