Browse Source

Sep 3 [UPDT] : Updated 'sale_order_discount_approval_odoo'

pull/397/merge
AjmalCybro 3 weeks ago
parent
commit
531a4e7d16
  1. 2
      sale_order_discount_approval_odoo/__manifest__.py
  2. 4
      sale_order_discount_approval_odoo/doc/RELEASE_NOTES.md
  3. 2
      sale_order_discount_approval_odoo/models/__init__.py
  4. 43
      sale_order_discount_approval_odoo/models/sale_order.py
  5. BIN
      sale_order_discount_approval_odoo/static/description/assets/screenshots/s09.png
  6. 30
      sale_order_discount_approval_odoo/static/description/index.html

2
sale_order_discount_approval_odoo/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'Sale Order Discount Approval',
'version': '18.0.1.0.0',
'version': '18.0.1.0.1',
'category': 'Sales',
'summary': 'Sale Order Discount Approval based on the Allowed discount values',
'description': """Module for discount approval of sales orders if

4
sale_order_discount_approval_odoo/doc/RELEASE_NOTES.md

@ -4,3 +4,7 @@
#### Version 18.0.1.0.0
#### ADD
- Initial commit for Sale Order Discount Approval
#### 14.10.2024
#### Version 18.0.1.0.1
#### UPDATE
- Updated the workflow to set the approval stage by also comparing the global discount.

2
sale_order_discount_approval_odoo/models/__init__.py

@ -3,7 +3,7 @@
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO

43
sale_order_discount_approval_odoo/models/sale_order.py

@ -35,19 +35,46 @@ class SaleOrder(models.Model):
help='The discount approver')
def action_confirm(self):
"""Method for confirming the sale order discount and sending mail for
the approver if approval limit crossed"""
"""Confirm sale order with discount approval check.
- If line/global discount exceeds user limit set 'waiting_for_approval'
- Else proceed normally.
"""
self.ensure_one()
res = super().action_confirm()
to_approve = False
discount_vals = self.order_line.mapped('discount')
user_discount = self.env.user.allow_discount
discount_product = self.env.company.sale_discount_product_id
approval_users = self.env.ref(
'sale_order_discount_approval_odoo.sale_order_discount_approval_odoo_group_manager').users
user_discount = self.env.user.allow_discount
if self.env.user.is_discount_control == True:
for rec in discount_vals:
if rec > user_discount:
# -------------------------------
# 1. Line-based discount check
# -------------------------------
if self.env.user.is_discount_control:
for line in self.order_line:
if line.discount > user_discount:
to_approve = True
break
# -------------------------------
# 2. Global discount check
# -------------------------------
if not to_approve and discount_product:
discount_line = self.order_line.filtered(lambda l: l.product_id == discount_product)
if discount_line:
discount_amount = abs(discount_line.price_unit)
# base total before discount
base_total = sum(
l.product_uom_qty * l.price_unit for l in self.order_line if l.product_id != discount_product)
if base_total > 0:
global_discount_pct = (discount_amount / base_total) * 100
if global_discount_pct > user_discount:
to_approve = True
# -------------------------------
# 3. Apply result
# -------------------------------
if to_approve:
action_id = self.env.ref(
'sale.action_quotations_with_onboarding').id
@ -75,6 +102,8 @@ class SaleOrder(models.Model):
self.state = 'waiting_for_approval'
return res
def action_waiting_approval(self):
"""Method for approving the sale order discount"""
self.approval_user_id = self.env.user.id

BIN
sale_order_discount_approval_odoo/static/description/assets/screenshots/s09.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

30
sale_order_discount_approval_odoo/static/description/index.html

@ -654,6 +654,36 @@
</div>
</div>
</div>
<div class="position-relative mb-4"
style="border-radius:10px; background-color:#f4f4f4">
<div class="p-md-5 p-3 position-relative">
<div class="row">
<div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
font-weight: 700;">
<span style="color:#121212; font-size:calc(1.1rem + 1vw)">Check for
</span>
<span style="color: var(--primary-color); font-size:calc(1.1rem + 1vw)">Global Discount.</span>
</h1>
</div>
<div class="col-md-12 mb-4">
<p style="font-weight:400; font-size:16px; line-height:150%; text-align:center; color:var(--text-color-light)">
Discount will be checked for approval also
</p>
</div>
<div class="col-md-12 text-center">
<div class="d-inline-block p-3 shadow-sm"
style="background-color:#fff; border-radius:10px">
<img alt="" class="img-fluid"
loading="lazy"
src="./assets/screenshots/s09.png"
style="min-height: 1px;">
</div>
</div>
</div>
</div>
</div>
</div>
<div aria-labelledby="feature-tab"
class="tab-pane fade show py-1" id="feature"

Loading…
Cancel
Save