[FIX] point_of_sale: apply tax repartition lines on amount
Since implementation of repartition lines on tax in accounting, the amount on the tax is not always the effective amount to apply on price of a product. You can have a tax with amount of 20% for example, and two repartition lines of 100% and -100%, that will lead to have to apply 0% on the tax. So we are computing the effective amount on the tax by multiplying the amount of tax by the sum of repartition lines factor. closes odoo/odoo#36140 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -25,3 +25,12 @@ class AccountTax(models.Model):
|
||||
'You must close the POS sessions before modifying the tax.'
|
||||
))
|
||||
return super(AccountTax, self).write(vals)
|
||||
|
||||
def get_real_tax_amount(self):
|
||||
tax_list = []
|
||||
for tax in self:
|
||||
tax_repartition_lines = tax.invoice_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax')
|
||||
total_factor = sum(tax_repartition_lines.mapped('factor'))
|
||||
real_amount = tax.amount * total_factor
|
||||
tax_list.append({'id': tax.id, 'amount': real_amount})
|
||||
return tax_list
|
||||
|
||||
@@ -242,6 +242,19 @@ exports.PosModel = Backbone.Model.extend({
|
||||
return self.taxes_by_id[child_tax_id];
|
||||
});
|
||||
});
|
||||
return new Promise(function (resolve, reject) {
|
||||
var tax_ids = _.pluck(self.taxes, 'id');
|
||||
rpc.query({
|
||||
model: 'account.tax',
|
||||
method: 'get_real_tax_amount',
|
||||
args: [tax_ids],
|
||||
}).then(function (taxes) {
|
||||
_.each(taxes, function (tax) {
|
||||
self.taxes_by_id[tax.id].amount = tax.amount;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
},{
|
||||
model: 'pos.session',
|
||||
|
||||
Reference in New Issue
Block a user