From a267d8205bf7cabd129a0fea2e7ab5552026b70b Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 29 Aug 2016 18:03:05 +0200 Subject: [PATCH] [FIX] account: fix account_reconciliation_widget when a tax is used. compute_all() now expects browse_records as parameters --- addons/account/models/account.py | 11 +++++++++++ .../static/src/js/account_reconciliation_widgets.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index f306d591d12..6810c543f38 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -651,6 +651,17 @@ class AccountTax(models.Model): if self.amount_type == 'division' and not self.price_include: return base_amount / (1 - self.amount / 100) - base_amount + @api.multi + def json_friendly_compute_all(self, price_unit, currency_id=None, quantity=1.0, product_id=None, partner_id=None): + """ Just converts parameters in browse records and calls for compute_all, because js widgets can't serialize browse records """ + if currency_id: + currency_id = self.env['res.currency'].browse(currency_id) + if product_id: + product_id = self.env['product.product'].browse(product_id) + if partner_id: + partner_id = self.env['res.partner'].browse(partner_id) + return self.compute_all(price_unit, currency=currency_id, quantity=quantity, product=product_id, partner=partner_id) + @api.multi def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None): """ Returns all information required to apply taxes (in self + their children in case of a tax goup). diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js index 6bae3a2415c..ea63221d763 100644 --- a/addons/account/static/src/js/account_reconciliation_widgets.js +++ b/addons/account/static/src/js/account_reconciliation_widgets.js @@ -988,7 +988,7 @@ var abstractReconciliationLine = Widget.extend({ var tax_id = self.tax_id_field.get("value"); if (amount && tax_id) { deferred_tax = self.model_tax - .call("compute_all", [[tax_id], amount, self.get("currency_id")]) + .call("json_friendly_compute_all", [[tax_id], amount, self.get("currency_id")]) .then(function(data){ line_created_being_edited.length = 1; // remove tax lines line_created_being_edited[0].amount_before_tax = amount;