| @ -0,0 +1,49 @@ | |||
| .. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg | |||
|     :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html | |||
|     :alt: License: AGPL-3 | |||
| 
 | |||
| Product Discount Limit | |||
| ====================== | |||
| This module allow to set discount limit for products and product categories | |||
| 
 | |||
| Configuration | |||
| ============= | |||
| * No additional configurations needed | |||
| 
 | |||
| Company | |||
| ------- | |||
| * `Cybrosys Techno Solutions <https://cybrosys.com/>`__ | |||
| 
 | |||
| License | |||
| ------- | |||
| Affero General Public License, Version 3 (AGPL v3). | |||
| (https://www.gnu.org/licenses/agpl-3.0-standalone.html) | |||
| 
 | |||
| Credits | |||
| ------- | |||
| * Developers: (V16) JANISH BABU EK, | |||
|               (V17) ANURUDH P, | |||
|               (V18) Ammu Raj, Ayana KP, | |||
| 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: Ammu Raj (odoo@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,44 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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': 'Product Discount Limit', | |||
|     'version': '18.0.1.0.0', | |||
|     'category': 'Sales', | |||
|     'summary': """Limit of Product Discount""", | |||
|     'description': 'This module allow to set ' | |||
|                    'discount limit for products and product categories.', | |||
|     'author': 'Cybrosys Techno Solutions', | |||
|     'company': 'Cybrosys Techno Solutions', | |||
|     'maintainer': 'Cybrosys Techno Solutions', | |||
|     'website': 'https://www.cybrosys.com', | |||
|     'depends': ['sale'], | |||
|     'data': [ | |||
|         'views/product_template_views.xml', | |||
|         'views/product_category_views.xml', | |||
|         'views/res_users_views.xml', | |||
|     ], | |||
|     'images': ['static/description/banner.jpg'], | |||
|     'license': 'AGPL-3', | |||
|     'installable': True, | |||
|     'auto_install': False, | |||
|     'application': False, | |||
| } | |||
| @ -0,0 +1,7 @@ | |||
| ## Module <product_discount_limit> | |||
| 
 | |||
| #### 19.10.2024 | |||
| #### Version 18.0.1.0.0 | |||
| #### ADD | |||
| 
 | |||
| - Initial commit for Product Discount Limit | |||
| @ -0,0 +1,25 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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 product_category | |||
| from . import product_template | |||
| from . import res_users | |||
| from . import sale_order_line | |||
| @ -0,0 +1,31 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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 fields, models | |||
| 
 | |||
| 
 | |||
| class ProductCategory(models.Model): | |||
|     """Inherited product.category to add field Discount Limit""" | |||
|     _inherit = 'product.category' | |||
| 
 | |||
|     desc_limit = fields.Float(string="Discount Limit(%)", | |||
|                               help="If it is specified,user can't give a " | |||
|                                    "discount greater the amount") | |||
| @ -0,0 +1,31 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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 fields, models | |||
| 
 | |||
| 
 | |||
| class ProductTemplate(models.Model): | |||
|     """Inherited product.template to add field Discount Limit""" | |||
|     _inherit = 'product.template' | |||
| 
 | |||
|     desc_limit = fields.Float(string="Discount Limit(%)", | |||
|                               help="If it is specified,user can't give a " | |||
|                                    "discount greater the amount") | |||
| @ -0,0 +1,31 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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 fields, models | |||
| 
 | |||
| 
 | |||
| class ResUsers(models.Model): | |||
|     """Inherited res.users to add field to allow discount over limit""" | |||
|     _inherit = 'res.users' | |||
| 
 | |||
|     allow_discount = fields.Boolean(string="Allow Discount Over Limit", | |||
|                                     help="If it is True, discount Limit will " | |||
|                                          "not affect the user") | |||
| @ -0,0 +1,43 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ################################################################################ | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | |||
| #    Author: Ammu Raj (odoo@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 api, exceptions, models, _ | |||
| 
 | |||
| 
 | |||
| class SalesOrderLine(models.Model): | |||
|     """Inherited sale.order.line for checking the limit of discount | |||
|     allowed for product and category""" | |||
|     _inherit = 'sale.order.line' | |||
| 
 | |||
|     @api.onchange('discount') | |||
|     def _onchange_discount(self): | |||
|         """Checking the limit of discount allowed for products and category""" | |||
|         if not self.env.user.allow_discount: | |||
|             desc_limit = self.product_id.product_tmpl_id.desc_limit or \ | |||
|                          self.product_id.categ_id.desc_limit | |||
|             if desc_limit and self.discount > desc_limit: | |||
|                 raise exceptions.UserError( | |||
|                     _('You are not allowed to apply discount more than %s ' | |||
|                       'percentage on this %s. Please contact your ' | |||
|                       'administrator', | |||
|                       desc_limit, | |||
|                       'product' if self.product_id.product_tmpl_id else | |||
|                       'category')) | |||
| 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: 738 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: 912 KiB | 
| After Width: | Height: | Size: 1.3 MiB | 
| After Width: | Height: | Size: 46 KiB | 
| After Width: | Height: | Size: 44 KiB | 
| After Width: | Height: | Size: 46 KiB | 
| After Width: | Height: | Size: 85 KiB | 
| After Width: | Height: | Size: 108 KiB | 
| After Width: | Height: | Size: 133 KiB | 
| After Width: | Height: | Size: 103 KiB | 
| After Width: | Height: | Size: 119 KiB | 
| After Width: | Height: | Size: 42 KiB | 
| After Width: | Height: | Size: 95 KiB | 
| After Width: | Height: | Size: 184 KiB | 
| After Width: | Height: | Size: 880 KiB | 
| After Width: | Height: | Size: 734 KiB | 
| After Width: | Height: | Size: 52 KiB | 
| @ -0,0 +1,19 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
|     <!--    Extended product_category_form_view--> | |||
|     <record id="product_category_form_view" model="ir.ui.view"> | |||
|         <field name="name">product.category.view.form.inherit.product.discount.limit</field> | |||
|         <field name="model">product.category</field> | |||
|         <field name="inherit_id" ref="product.product_category_form_view"/> | |||
|         <field name="priority">10</field> | |||
|         <field name="arch" type="xml"> | |||
|             <group name="first" position="after"> | |||
|                 <group> | |||
|                     <group name="discount" string="Discount"> | |||
|                         <field name="desc_limit"/> | |||
|                     </group> | |||
|                 </group> | |||
|             </group> | |||
|         </field> | |||
|     </record> | |||
| </odoo> | |||
| @ -0,0 +1,15 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
| <!--    Extended product_template_only_form_view--> | |||
|     <record id="product_template_only_form_view" model="ir.ui.view"> | |||
|         <field name="name">product.template.view.form.inherit.product.discount.limit</field> | |||
|         <field name="model">product.template</field> | |||
|         <field name="inherit_id" ref="product.product_template_only_form_view"/> | |||
|         <field name="priority">10</field> | |||
|         <field name="arch" type="xml"> | |||
|             <xpath expr="//field[@name='barcode']" position="after"> | |||
|                 <field name="desc_limit"/> | |||
|             </xpath> | |||
|         </field> | |||
|     </record> | |||
| </odoo> | |||
| @ -0,0 +1,19 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
| <!--    Extended view_users_form--> | |||
|     <record id="view_users_form" model="ir.ui.view"> | |||
|         <field name="name">res.users.view.form.inherit.product.discount.limit</field> | |||
|         <field name="model">res.users</field> | |||
|         <field name="inherit_id" ref="base.view_users_form"/> | |||
|         <field name="priority">10</field> | |||
|         <field name="arch" type="xml"> | |||
|             <page name="access_rights" position="inside"> | |||
|                 <group> | |||
|                     <group name="others" string="Others"> | |||
|                         <field name="allow_discount" string="Allow Discount Over Limit"/> | |||
|                     </group> | |||
|                 </group> | |||
|             </page> | |||
|         </field> | |||
|     </record> | |||
| </odoo> | |||