[FIX] stock_account: prevent stock account update on product change when using manual stock valuation

If the category of a product is using manual stock valuation, when changing the product on an invoice line,
the account should not be set to the `property_stock_account_input_categ_id`. It should be the case only if
we use automatic/real-time stock valuation.

opw-3226536

closes odoo/odoo#119717

Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
This commit is contained in:
Ricardo Gomes Rodrigues (rigr)
2023-04-27 10:13:02 +02:00
parent cd65f8bdb2
commit ef9c74f698
+1 -1
View File
@@ -395,7 +395,7 @@ class AccountMoveLine(models.Model):
return svl_vals_list
def _can_use_stock_accounts(self):
return self.product_id.type == 'product'
return self.product_id.type == 'product' and self.product_id.categ_id.property_valuation == 'real_time'
def _stock_account_get_anglo_saxon_price_unit(self):
self.ensure_one()