summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authoroco-odoo <oco@odoo.com>2020-07-30 10:47:41 +0000
committeroco-odoo <oco@odoo.com>2020-08-10 08:14:23 +0000
commitbe63b448450772f161ba95aefeb40aa3d8cea334 (patch)
tree3d05d2ab7ee7752703ac7e0a94e3374f7a119d27 /addons
parent2be6e37aca290d642b0db25f1e8674669f865f70 (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')
-rw-r--r--addons/account/models/account_move.py9
-rw-r--r--addons/point_of_sale/models/account_move.py12
2 files changed, 20 insertions, 1 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 495006bc812..4c60fdeb948 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -3473,7 +3473,7 @@ class AccountMoveLine(models.Model):
# Cash basis entries are always treated as misc operations, applying the tag sign directly to the balance
type_multiplicator = 1
else:
- type_multiplicator = (record.journal_id.type == 'sale' and -1 or 1) * (record.move_id.move_type in ('in_refund', 'out_refund') and -1 or 1)
+ type_multiplicator = (record.journal_id.type == 'sale' and -1 or 1) * (self._get_refund_tax_audit_condition(record) and -1 or 1)
tag_amount = type_multiplicator * (tag.tax_negate and -1 or 1) * record.balance
@@ -3489,6 +3489,13 @@ class AccountMoveLine(models.Model):
record.tax_audit = audit_str
+ def _get_refund_tax_audit_condition(self, aml):
+ """ Returns the condition to be used for the provided move line to tell
+ whether or not it comes from a refund operation.
+ This is overridden by pos in order to treat returns properly.
+ """
+ return aml.move_id.move_type in ('in_refund', 'out_refund') and -1 or 1
+
# -------------------------------------------------------------------------
# CONSTRAINT METHODS
# -------------------------------------------------------------------------
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)