[FIX] sale: Re-invoicing policy

Steps to reproduce the bug:

- Let's consider a product P
- Let's consider that a draft SO has been created for P with analytic account AA
- P can be sold (sale_ok=True) and Re-invoicing policy = 'At cost'
- Untick the option 'Can be sold' on P
- Create an expense E for P with the analytic account AA
- Submit E and try to post the entries

Bug:

A UserError was raised saying that SO with analytic account AA must validated but
P is no more salable.

opw:2217773

closes odoo/odoo#48408

X-original-commit: 3db629cbcde9c4c3bbe2874c18e01dd31abe092d
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2020-03-26 09:35:12 +00:00
parent 75191f8ac4
commit 50e425ce02
+6
View File
@@ -46,6 +46,12 @@ class ProductTemplate(models.Model):
for product_template in self:
product_template.visible_expense_policy = visibility
@api.onchange('sale_ok')
def _change_sale_ok(self):
if not self.sale_ok:
self.expense_policy = 'no'
@api.depends('product_variant_ids.sales_count')
def _compute_sales_count(self):
for product in self: