[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) <jcb@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user