-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] sale_commission_agent_restrict_product_criteria
- Loading branch information
Showing
15 changed files
with
601 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
sale_commission_agent_restrict_product_criteria/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
================================================ | ||
Sale Commissions Agent Restrict Product Criteria | ||
================================================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:6e881bf405d5ee94eabd1473b81be573c5ca55af8c1eaca4ae728f2237ef418c | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github | ||
:target: https://github.com/OCA/commission/tree/14.0/sale_commission_agent_restrict_product_criteria | ||
:alt: OCA/commission | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_agent_restrict_product_criteria | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_agent_restrict_product_criteria%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* PyTech SRL | ||
* Ooops404 | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Ooops404 <https://www.ooops404.com>` | ||
* `PyTech SRL <https://www.pytech.it>` | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/14.0/sale_commission_agent_restrict_product_criteria>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
17 changes: 17 additions & 0 deletions
17
sale_commission_agent_restrict_product_criteria/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "Sale Commissions Agent Restrict Product Criteria", | ||
"version": "14.0.1.0.0", | ||
"author": "PyTech SRL, Ooops404, Odoo Community Association (OCA)", | ||
"maintainers": ["pytech-bot"], | ||
"category": "Sales", | ||
"website": "https://github.com/OCA/commission", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"sale_commission_agent_restrict", | ||
"sale_commission_product_criteria_domain", | ||
], | ||
"data": [ | ||
"views/sale_order_views.xml", | ||
], | ||
"installable": True, | ||
} |
2 changes: 2 additions & 0 deletions
2
sale_commission_agent_restrict_product_criteria/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import sale_order | ||
from . import sale_order_line |
38 changes: 38 additions & 0 deletions
38
sale_commission_agent_restrict_product_criteria/models/sale_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
product_domain_ids = fields.Many2many("product.product", string="Products Domain") | ||
|
||
@api.onchange("partner_id") | ||
def _onchange_partner_id(self): | ||
product_ids = self.env["product.product"] | ||
if self.partner_id: | ||
for item in self.partner_id.commission_item_agent_ids: | ||
commission = item.agent_id.commission_id | ||
if commission: | ||
product_ids = self._get_products_from_commission(commission, item) | ||
self.product_domain_ids = product_ids or product_ids.search([]) | ||
|
||
@api.model | ||
def _get_products_from_commission(self, commission, item): | ||
product_ids = self.env["product.product"] | ||
for rule in commission.item_ids.filtered( | ||
lambda x: x.group_id in item.group_ids | ||
): | ||
if rule.applied_on == "3_global": | ||
product_ids = self.env["product.product"].search([]) | ||
break | ||
elif rule.applied_on == "2_product_category": | ||
product_ids |= self.env["product.product"].search( | ||
[("product_tmpl_id.categ_id", "=", rule.categ_id.id)] | ||
) | ||
elif rule.applied_on == "1_product": | ||
product_ids |= self.env["product.product"].search( | ||
[("product_tmpl_id", "=", rule.product_tmpl_id.id)] | ||
) | ||
elif rule.applied_on == "0_product_variant": | ||
product_ids |= rule.product_id | ||
return product_ids | ||
7 changes: 7 additions & 0 deletions
7
sale_commission_agent_restrict_product_criteria/models/sale_order_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
product_domain_ids = fields.Many2many(related="order_id.product_domain_ids") |
Empty file.
2 changes: 2 additions & 0 deletions
2
sale_commission_agent_restrict_product_criteria/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* `Ooops404 <https://www.ooops404.com>` | ||
* `PyTech SRL <https://www.pytech.it>` |
Empty file.
Empty file.
Binary file added
BIN
+9.23 KB
sale_commission_agent_restrict_product_criteria/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.