Browse Source

APR 30: [FIX] Bug fixed 'sale_discount_total'

pull/317/merge
Cybrosys Technologies 2 months ago
parent
commit
af93750601
  1. 2
      sale_discount_total/__manifest__.py
  2. 6
      sale_discount_total/doc/RELEASE_NOTES.md
  3. 34
      sale_discount_total/models/sale_order.py
  4. 15
      sale_discount_total/static/description/index.html

2
sale_discount_total/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': 'Sale Discount on Total Amount', 'name': 'Sale Discount on Total Amount',
'version': '17.0.1.1.0', 'version': '17.0.1.1.1',
'category': 'Sales Management', 'category': 'Sales Management',
'summary': "Discount on Total in Sale and Invoice With Discount Limit " 'summary': "Discount on Total in Sale and Invoice With Discount Limit "
"and Approval", "and Approval",

6
sale_discount_total/doc/RELEASE_NOTES.md

@ -5,8 +5,12 @@
#### ADD #### ADD
- Initial commit for Sale Discount On Total Amount - Initial commit for Sale Discount On Total Amount
#### 14.03.2024 #### 14.03.2024
#### Version 17.0.1.1.0 #### Version 17.0.1.1.0
#### ADD #### ADD
- Added margin in sale orders - Added margin in sale orders
#### 24.04.2025
#### Version 17.0.1.0.1
#### BUGFIX
- Prevented overwriting of line-level discounts

34
sale_discount_total/models/sale_order.py

@ -110,24 +110,26 @@ class SaleOrder(models.Model):
@api.onchange('discount_type', 'discount_rate', 'order_line') @api.onchange('discount_type', 'discount_rate', 'order_line')
def supply_rate(self): def supply_rate(self):
"""This function calculates supply rates based on change of """This function calculates supply rates based on change of
discount_type, discount_rate and invoice_line_ids""" discount_type, discount_rate and invoice_line_ids"""
for order in self: for order in self:
if order.discount_type == 'percent': if order.discount_rate > 0:
for line in order.order_line: if order.discount_type == 'percent':
line.discount = order.discount_rate for line in order.order_line:
else: line.discount = order.discount_rate
total = 0.0
for line in order.order_line:
total += round((line.product_uom_qty * line.price_unit))
if order.discount_rate != 0:
discount = (
order.discount_rate / total) * 100 if total > 0 else 0
else: else:
discount = order.discount_rate total = 0.0
for line in order.order_line: for line in order.order_line:
line.discount = discount total += round((line.product_uom_qty * line.price_unit))
new_sub_price = (line.price_unit * (discount / 100)) if total > 0:
line.total_discount = line.price_unit - new_sub_price discount = (order.discount_rate / total) * 100
else:
discount = 0.0
for line in order.order_line:
line.discount = discount
new_sub_price = (line.price_unit * (discount / 100))
line.total_discount = line.price_unit - new_sub_price
else:
pass
def _prepare_invoice(self, ): def _prepare_invoice(self, ):
"""Super sale order class and update with fields""" """Super sale order class and update with fields"""

15
sale_discount_total/static/description/index.html

@ -285,6 +285,21 @@
</p> </p>
</div> </div>
</div> </div>
<div class="col-mg-12 active" style="padding: 1rem 4rem;">
<div class="py-3"
style="font-weight: 500;background-color: #fff; border-radius: 4px; padding: 1rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="d-flex mb-3"
style="font-size: 0.8rem; font-weight: 500;"><span>Version
17.0.1.1.1</span><span
class="px-2">|</span><span
style="color: #714B67;font-weight: 600;">Released on:24th Apr 2025</span>
</div>
<p class="m-0"
style=" color:#718096!important; font-size:1rem !important;line-height: 28px;">
Prevented overwriting of line-level discounts
</p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save