[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.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user