[FIX] account: fix account_reconciliation_widget when a tax is used. compute_all() now expects browse_records as parameters

This commit is contained in:
qdp-odoo
2016-08-29 18:03:05 +02:00
parent b30bc58627
commit a267d8205b
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -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).
@@ -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;