From 4f921d668aba626475c2acf75ecc28af16905d52 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 18 Oct 2017 10:50:18 +0200 Subject: [PATCH] [FIX] account_asset: asset on refund - Create a vendor bill with a line linked to an asset category - Validate the bill => an asset is created - Refund the bill The refund is also linked to an asset category. Therefore, upon validation, a negative asset will be created. The refund should not be linked to the asset category in a first place. The user should cancel/modify the asset manually. opw-775933 --- addons/account_asset/models/account_invoice.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/account_asset/models/account_invoice.py b/addons/account_asset/models/account_invoice.py index f3726a798c0..7d20127b969 100644 --- a/addons/account_asset/models/account_invoice.py +++ b/addons/account_asset/models/account_invoice.py @@ -12,6 +12,16 @@ import odoo.addons.decimal_precision as dp class AccountInvoice(models.Model): _inherit = 'account.invoice' + @api.model + def _refund_cleanup_lines(self, lines): + result = super(AccountInvoice, self)._refund_cleanup_lines(lines) + for i, line in enumerate(lines): + for name, field in line._fields.items(): + if name == 'asset_category_id': + result[i][2][name] = False + break + return result + @api.multi def action_cancel(self): res = super(AccountInvoice, self).action_cancel()