From c140f9f54271640995170b70a05e6a6c32ed51ce Mon Sep 17 00:00:00 2001
From: Goffin Simon <sig@odoo.com>
Date: Mon, 9 May 2016 15:00:38 +0200
Subject: [PATCH] [FIX] account_asset: deferred_revenue_category_id and
 asset_category_id

When creating an customer invoice with a product linked to a deferred revenue
category, the account used in the invoice line must be the account_asset_id.

When creating an vendor bill with a product linked to an asset
category, the account used in the invoice line must be the account_depreciation_id.

Inspired from 0287c1e1b34a14300dcf7ef9ffddf160b61631ee

opw:677098
---
 addons/account_asset/account_asset_invoice.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/addons/account_asset/account_asset_invoice.py b/addons/account_asset/account_asset_invoice.py
index 47bcb9bbb830..82bc54d46f6c 100644
--- a/addons/account_asset/account_asset_invoice.py
+++ b/addons/account_asset/account_asset_invoice.py
@@ -110,3 +110,12 @@ class ProductTemplate(models.Model):
     asset_category_id = fields.Many2one('account.asset.category', string='Asset Type', ondelete="restrict")
     deferred_revenue_category_id = fields.Many2one('account.asset.category', string='Deferred Revenue Type', ondelete="restrict")
 
+    @api.onchange('deferred_revenue_category_id')
+    def onchange_deferred_revenue(self):
+        if self.deferred_revenue_category_id:
+            self.property_account_income = self.deferred_revenue_category_id.account_asset_id
+
+    @api.onchange('asset_category_id')
+    def onchange_asset(self):
+        if self.asset_category_id:
+            self.property_account_expense = self.asset_category_id.account_asset_id
-- 
GitLab