From 4ce3588b202ddda41bebcf15612fee22f9244b64 Mon Sep 17 00:00:00 2001 From: uso-odoo Date: Wed, 31 May 2023 05:26:37 +0000 Subject: [PATCH] [FIX] point_of_sale: prevent traceback when value of line.discount is 100 When the value line.discount = 100 in 'get_total_discount' method, the traceback is generated. The main reason is because of 'BODMAS Rule - Bracket, Order, Division, Multiplication, Addition, and Subtraction Steps To Produce:- 1. Install point_of_sale module 2. Go to Point Of Sale Configuration 3. Make 'Line Discounts' True and save it 4. Create New Storable Product, ordered quantity with 100 cost and sales price then remove taxes and Vendor Taxes 5. Open POS Session and select the newly created product 6. Apply discount = 100 % and validate payment and close the session 7. Go to Reporting > Sales Details, and add the date range based on the current pos order, click on the 'Print' button. Traceback will be generated. Applying these changes will resolve this issue. sentry-4216418906 closes odoo/odoo#124364 X-original-commit: db81e242d250d244fa5ed87e0c05911a43ab32d4 Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/models/pos_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 39a3c84518b..0c767e2db2b 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -2030,8 +2030,8 @@ class PosSession(models.Model): def get_total_discount(self): amount = 0 for line in self.env['pos.order.line'].search([('order_id', 'in', self.order_ids.ids), ('discount', '>', 0)]): - original_price = line.price_subtotal_incl / (1 - line.discount / 100) - amount += original_price * line.discount / 100 + original_price = line.tax_ids.compute_all(line.price_unit, line.currency_id, line.qty, product=line.product_id, partner=line.order_id.partner_id)['total_included'] + amount += original_price - line.price_subtotal_incl return amount