From 550fa2650accdc32060c242e09c196ee01b13845 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Thu, 25 Feb 2016 11:33:53 +0100 Subject: [PATCH] [FIX] account_asset: do not overwrite self.asset_category_id if it's already defined The function _set_additional_fields is used to avoid creating a ton of auto-install modules; account extension extend this function and modules that create invoices call it. But when calling this function, it would be better not to overwrite existing values; hence this check. --- addons/account_asset/account_asset_invoice.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/account_asset/account_asset_invoice.py b/addons/account_asset/account_asset_invoice.py index 7a0b90c3581..db020599202 100644 --- a/addons/account_asset/account_asset_invoice.py +++ b/addons/account_asset/account_asset_invoice.py @@ -73,12 +73,14 @@ class AccountInvoiceLine(models.Model): self.asset_category_id = self.product_id.product_tmpl_id.asset_category_id def _set_additional_fields(self, invoice): - if invoice.type == 'out_invoice': - self.asset_category_id = self.product_id.product_tmpl_id.deferred_revenue_category_id.id - elif invoice.type == 'in_invoice': - self.asset_category_id = self.product_id.product_tmpl_id.asset_category_id.id + if not self.asset_category_id: + if invoice.type == 'out_invoice': + self.asset_category_id = self.product_id.product_tmpl_id.deferred_revenue_category_id.id + elif invoice.type == 'in_invoice': + self.asset_category_id = self.product_id.product_tmpl_id.asset_category_id.id super(AccountInvoiceLine, self)._set_additional_fields(invoice) + class ProductTemplate(models.Model): _inherit = 'product.template' asset_category_id = fields.Many2one('account.asset.category', string='Asset Type', ondelete="restrict")