From f98a4d45af6088fc8a4e3268f3c92c57de51cdd0 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 18 Jan 2017 13:30:40 +0100 Subject: [PATCH] [FIX] account_asset_invoice: setting account_id on an invoice line with an asset Thanks to this commit: 342dad44cd78e1567bc9e7ae95a75be8adb26c4e (1) Asset Account (2) Depreciation Entries: Asset Account (3) Depreciation Entries: Expense Account Now it's possible in 9.0 to set the account_income_recognition_id. So in the case of a vendor bill if the account_income_recognition_id(3) is set, it means that the depreciation entries are debited on this account(3). Then the asset account can be used on the invoice line. NB: When the account_income_recognition_id(3) is not set, it means that The Asset Account(1) is used to debit the depreciation entries so it cannot be used as an asset account. In this case, (1) is used as (3) And the Depreciation Entries: Asset Account(2) is used as (1) and (2) because the all assets are first debited on this account and progressively the depreciation entries are credited on this account too. This is why in 10.0, there is an onchange on account_asset_id on model "account.asset.category" which sets the same value for (1) and (2). Example with account_income_recognition_id set: Purchase of 100k with a 5 years depreciation: on (1) debit=100k and credit=0 on (2) each year debit=0 and credit=20k on (3) each year debit=20k and credit=0 Example without account_income_recognition_id set: Purchase of 100k with a 5 years depreciation: on (2) debit=100k and credit=0 on (2) each year debit=0 and credit=20k on (1) each year debit=20k and credit=0 This behavior can be analysed in function create_move on model "account.asset.depreciation.line" opw:702265 --- addons/account_asset/account_asset_invoice.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account_asset/account_asset_invoice.py b/addons/account_asset/account_asset_invoice.py index 2460afd3fea..fe7ab4c7d44 100644 --- a/addons/account_asset/account_asset_invoice.py +++ b/addons/account_asset/account_asset_invoice.py @@ -77,7 +77,11 @@ class AccountInvoiceLine(models.Model): if self.invoice_id.type == 'out_invoice' and self.asset_category_id: self.account_id = self.asset_category_id.account_asset_id.id elif self.invoice_id.type == 'in_invoice' and self.asset_category_id: - self.account_id = self.asset_category_id.account_depreciation_id.id + #DO NOT FORWARDPORT + if self.asset_category_id.account_income_recognition_id: + self.account_id = self.asset_category_id.account_asset_id.id + else: + self.account_id = self.asset_category_id.account_depreciation_id.id @api.onchange('uom_id') def _onchange_uom_id(self):