@ -0,0 +1,50 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-AGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
Sale Order Discount Approval |
||||
|
============================ |
||||
|
App for Providing Discount by user and approving the discount in sale order. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configurations needed |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
GNU Affero General Public License, Version 3 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: |
||||
|
(V16) VYSHNAV AR, |
||||
|
(V17) Gayathri V, |
||||
|
(V18) Nivedhya T |
||||
|
Contact : odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-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 |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
@ -0,0 +1,46 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-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 |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Sale Order Discount Approval', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Sales', |
||||
|
'summary': 'Sale Order Discount Approval based on the Allowed discount values', |
||||
|
'description': """Module for discount approval of sales orders if |
||||
|
discount limit exceeded of allowed discount of user.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': [ |
||||
|
'sale_management', |
||||
|
], |
||||
|
'data': [ |
||||
|
'security/sale_order_discount_approval_odoo_groups.xml', |
||||
|
'views/res_users_views.xml', |
||||
|
'views/sale_order_views.xml', |
||||
|
], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'application': False, |
||||
|
'auto_install': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <sale_order_discount_approval_odoo> |
||||
|
|
||||
|
#### 14.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial commit for Sale Order Discount Approval |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-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 |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import res_users |
||||
|
from . import sale_order |
@ -0,0 +1,33 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-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 |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import models, fields |
||||
|
|
||||
|
|
||||
|
class ResUsers(models.Model): |
||||
|
"""This is used to inherit 'res.users' to add new fields""" |
||||
|
_inherit = 'res.users' |
||||
|
|
||||
|
is_discount_control = fields.Boolean(string='Discount Control', |
||||
|
help='Which is used to identify isit ' |
||||
|
'for discount control') |
||||
|
allow_discount = fields.Float(string='Allow Discount', |
||||
|
help='Allowed discount percentage') |
@ -0,0 +1,81 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-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 |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import models, fields |
||||
|
|
||||
|
|
||||
|
class SaleOrder(models.Model): |
||||
|
"""This is used to inherit 'sale.order' to add new fields and |
||||
|
functionality""" |
||||
|
_inherit = 'sale.order' |
||||
|
|
||||
|
state = fields.Selection( |
||||
|
selection_add=[('waiting_for_approval', 'Waiting For Approval'), |
||||
|
('sale',)]) |
||||
|
approval_user_id = fields.Many2one('res.users', |
||||
|
string='Discount Approved By', |
||||
|
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""" |
||||
|
res = super().action_confirm() |
||||
|
to_approve = False |
||||
|
discount_vals = self.order_line.mapped('discount') |
||||
|
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: |
||||
|
to_approve = True |
||||
|
break |
||||
|
if to_approve: |
||||
|
action_id = self.env.ref( |
||||
|
'sale.action_quotations_with_onboarding').id |
||||
|
redirect_link = f"/web#id={self.id}&cids=1&menu_id=178&action={action_id}" \ |
||||
|
"&model=sale.order&view_type=form" |
||||
|
url = self.env['ir.config_parameter'].sudo().get_param( |
||||
|
'web.base.url') + redirect_link |
||||
|
for user in approval_users: |
||||
|
mail_body = f"""<p>Hello,</p> <p>New sale order '{self.name}' |
||||
|
created with Discount by '{self.env.user.name}' need your approval |
||||
|
on it.</p> <p>To Approve, Cancel Order, Click on the Following |
||||
|
Link: <a href='{url}' style="display: inline-block; |
||||
|
padding: 10px; text-decoration: none; font-size: 12px; |
||||
|
background-color: #875A7B; color: #fff; border-radius: 5px; |
||||
|
"><strong>Click Me</strong></a> </p> <p>Thank You.</p>""" |
||||
|
mail_values = { |
||||
|
'subject': f"{self.name} Discount Approval Request", |
||||
|
'body_html': mail_body, |
||||
|
'email_to': user.partner_id.email, |
||||
|
'email_from': self.env.user.partner_id.email, |
||||
|
'model': 'sale.order', |
||||
|
} |
||||
|
mail_id = self.env['mail.mail'].sudo().create(mail_values) |
||||
|
mail_id.send() |
||||
|
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 |
||||
|
self.state = 'sale' |
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!--Security category for the sale order discount approval--> |
||||
|
<record id="sale_order_discount_approval_odoo_category" model="ir.module.category"> |
||||
|
<field name="name">Sale Order Discount Approval</field> |
||||
|
<field name="description">Category for Discount Approval</field> |
||||
|
</record> |
||||
|
<!--Approval Manager user group for the sale order discount approval--> |
||||
|
<record id="sale_order_discount_approval_odoo_group_manager" model="res.groups"> |
||||
|
<field name="name">Discount Approval Manager</field> |
||||
|
<field name="category_id" |
||||
|
ref="sale_order_discount_approval_odoo_category"/> |
||||
|
</record> |
||||
|
</odoo> |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 263 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 183 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 741 KiB |
After Width: | Height: | Size: 49 KiB |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- This is used to add new fields to res.users--> |
||||
|
<record id="view_users_form" model="ir.ui.view"> |
||||
|
<field name="name"> |
||||
|
res.users.view.form.inherit.sale.order.discount.approval.odoo |
||||
|
</field> |
||||
|
<field name="model">res.users</field> |
||||
|
<field name="inherit_id" ref="base.view_users_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//notebook/page[@name='preferences']" position="after"> |
||||
|
<page string="Discount Control" name="discount_control"> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="is_discount_control"/> |
||||
|
<field name="allow_discount" |
||||
|
invisible="is_discount_control == False"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
</page> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- This is used to add new fields to sale.order--> |
||||
|
<record id="view_order_form" model="ir.ui.view"> |
||||
|
<field name="name"> |
||||
|
sale.order.view.form.inherit.sale.order.discount.approval.odoo |
||||
|
</field> |
||||
|
<field name="model">sale.order</field> |
||||
|
<field name="inherit_id" ref="sale.view_order_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//header/button[@name='action_confirm']" |
||||
|
position="after"> |
||||
|
<button name="action_waiting_approval" |
||||
|
id="action_waiting_approval" |
||||
|
data-hotkey="v" string="Approve" class="btn-primary" |
||||
|
type="object" |
||||
|
groups="sale_order_discount_approval_odoo.sale_order_discount_approval_odoo_group_manager" |
||||
|
invisible="state not in ['waiting_for_approval']"/> |
||||
|
</xpath> |
||||
|
<xpath expr="//header/button[@name='action_confirm']" |
||||
|
position="replace"> |
||||
|
<button name="action_confirm" id="action_confirm" |
||||
|
data-hotkey="v" string="Confirm" class="btn-primary" |
||||
|
type="object" context="{'validate_analytic': True}" |
||||
|
invisible="state not in ['sent']"/> |
||||
|
</xpath> |
||||
|
<xpath expr="//header/button[@name='action_cancel']" |
||||
|
position="replace"> |
||||
|
<button name="action_cancel" type="object" string="Cancel" |
||||
|
groups="sale_order_discount_approval_odoo.sale_order_discount_approval_odoo_group_manager" |
||||
|
invisible="state not in ['draft', 'sent','sale','waiting_for_approval'] or id == False" |
||||
|
data-hotkey="z"/> |
||||
|
</xpath> |
||||
|
<xpath |
||||
|
expr="//notebook/page[@name='other_information']/group/group[@name='sales_person']/field[@name='team_id']" |
||||
|
position="after"> |
||||
|
<field name="approval_user_id"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |