[FIX] account: avoid deleting contact on invoice

From Invoicing/Accounting generate an invoice toward a customer
which is a child contact of a company.
Click on "Validate" and print the invoice: the name and contact
information of the customer will be in the report.

Now go into Contacts and delete the customer. If you print again the
report there will be no mention of the customer, and also from the
invoicing tree view there is no customer information.
This is due to the contraint on the deletion that affect only the
parent contact (i.e. a company) which is being billed.

The solution is to put a constraint on the account model to restrict the
deletion of the contact if it is customer of an invoice.

opw-2052717

closes odoo/odoo#35761

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2019-08-16 12:50:07 +00:00
parent c2bcd15998
commit 5e268d8893
+1 -1
View File
@@ -304,7 +304,7 @@ class AccountInvoice(models.Model):
"means direct payment.")
partner_id = fields.Many2one('res.partner', string='Partner', change_default=True,
readonly=True, states={'draft': [('readonly', False)]},
track_visibility='always', help="You can find a contact by its Name, TIN, Email or Internal Reference.")
track_visibility='always', ondelete='restrict', help="You can find a contact by its Name, TIN, Email or Internal Reference.")
vendor_bill_id = fields.Many2one('account.invoice', string='Vendor Bill',
help="Auto-complete from a past bill.")
payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', oldname='payment_term',