diff options
| author | oco-odoo <oco@odoo.com> | 2020-07-30 10:47:41 +0000 |
|---|---|---|
| committer | oco-odoo <oco@odoo.com> | 2020-08-10 08:14:23 +0000 |
| commit | be63b448450772f161ba95aefeb40aa3d8cea334 (patch) | |
| tree | 3d05d2ab7ee7752703ac7e0a94e3374f7a119d27 /addons/point_of_sale/models | |
| parent | 2be6e37aca290d642b0db25f1e8674669f865f70 (diff) | |
[FIX] account, point_of_sale: correct tax_audit computation for pos returns
https://github.com/odoo/enterprise/pull/12091 changed the way the tax report computes its totals wit account moves resulting for return operations in pos. This commit does the same on tax_audit field, so that it stays consistent with the report.
closes odoo/odoo#55664
X-original-commit: 67b3d70c8425dee17731e7b94bcb4797d4b06a97
Related: odoo/enterprise#12320
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Diffstat (limited to 'addons/point_of_sale/models')
| -rw-r--r-- | addons/point_of_sale/models/account_move.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index 0874ab2ea7f..c23902ec113 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -35,3 +35,15 @@ class AccountMoveLine(models.Model): if order: price_unit = order._get_pos_anglo_saxon_price_unit(self.product_id, self.move_id.partner_id.id, self.quantity) return price_unit + + def _get_refund_tax_audit_condition(self, aml): + # Overridden so that the returns can be detected as credit notes by the tax audit computation + rslt = super()._get_refund_tax_audit_condition(aml) + + if aml.move_id.is_invoice(): + # We don't need to check the pos orders for this move line if an invoice + # is linked to it ; we know that the invoice type tells us whether it's a refund + return rslt + + pos_orders_count = self.env['pos.order'].search_count([('account_move', '=', aml.move_id.id)]) + return rslt or (pos_orders_count and aml.debit > 0) |
