[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:
parent
5d60c1c887
commit
3695886531
|
@ -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,
|
||||
|
|
|
@ -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"/>
|
||||
|
|
Loading…
Reference in New Issue