diff options
| author | Andrea Grazioso (agr-odoo) <agr@odoo.com> | 2020-07-15 07:51:57 +0000 |
|---|---|---|
| committer | Andrea Grazioso (agr-odoo) <agr@odoo.com> | 2020-07-23 18:54:23 +0000 |
| commit | 2442892ec171a89d12c2c52e382a9205eb18541a (patch) | |
| tree | d0c942271eeb47f46d29bbdbf20279c94b5a0ca6 | |
| parent | cf741bb7fc76b6947f244e469f344fa442aad23c (diff) | |
[FIX] point_of_sale,pos_cash_rounding: return payment with rounding
In the PoS, activate the cash rounding.
Open a PoS session and make a sale.
Close the session (without validating the entries yet),
Go to the just made order to return the items.
Upon making return payment, it gets stuck, because Odoo offers
to refund the unrounded amount and it doesn't match what the customer
paid.
opw-2289751
closes odoo/odoo#54870
X-original-commit: 0811db53c728c2e159c50c2c9f096a06d3ac3be2
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
| -rw-r--r-- | addons/point_of_sale/models/pos_order.py | 9 | ||||
| -rw-r--r-- | addons/point_of_sale/wizard/pos_payment.py | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 65961226330..ada032ee643 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -354,6 +354,15 @@ class PosOrder(models.Model): 'res_id': self.account_move.id, } + def _is_pos_order_paid(self): + return float_is_zero(self._get_rounded_amount(self.amount_total) - self.amount_paid, precision_rounding=self.currency_id.rounding) + + def _get_rounded_amount(self, amount): + if self.config_id.cash_rounding: + amount = float_round(amount, precision_rounding=self.config_id.rounding_method.rounding, rounding_method=self.config_id.rounding_method.rounding_method) + currency = self.currency_id + return currency.round(amount) if currency else amount + def action_pos_order_paid(self): self.ensure_one() diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index ac753f403f6..40f3741973c 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -49,12 +49,12 @@ class PosMakePayment(models.TransientModel): if not float_is_zero(init_data['amount'], precision_rounding=currency.rounding): order.add_payment({ 'pos_order_id': order.id, - 'amount': currency.round(init_data['amount']) if currency else init_data['amount'], + 'amount': order._get_rounded_amount(init_data['amount']), 'name': init_data['payment_name'], 'payment_method_id': init_data['payment_method_id'][0], }) - if float_is_zero(order.amount_total - order.amount_paid, precision_rounding=currency.rounding): + if order._is_pos_order_paid(): order.action_pos_order_paid() order._create_order_picking() return {'type': 'ir.actions.act_window_close'} |
