-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
21 changed files
with
877 additions
and
4 deletions.
There are no files selected for viewing
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
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,92 @@ | ||
========================================= | ||
Sale Commission Geo Assign Product Domain | ||
========================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c1e975a6df363c2305b48f499b520ac68c97d53570ad5f3f3b4654db2befc99c | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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_geo_assign_product_domain | ||
: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_geo_assign_product_domain | ||
: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| | ||
|
||
This is a bridge module between sale_commission_product_criteria_domain and sale_commission_geo_assign. It allows to address the following use case: | ||
|
||
- Assign Agent 1 to customers with address in Spain, and restrict Agent 1's applicable commission type lines to those related to group "Spain"; | ||
|
||
- Assign Agent 1 to customers with address in Italy, and restrict Agent 1's applicable commission type lines to those related to group "Italy". | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
In agents with assigned commission type "Product criteria (with restrictions)" it's now possible to set more than one geographic criteria for assignation. Each geo-assignation line must have at least one commission type line group set. | ||
|
||
Usage | ||
===== | ||
|
||
Use server action "Add agents with geo assign" on partners as per sale_commission_geo_assign behavior. Lines in table "Commission items group" will be populated with the commission item groups set in agent's geo-assignation criteria. | ||
|
||
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_geo_assign_product_domain%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 | ||
~~~~~~~~~~~~ | ||
|
||
* PyTech SRL <[email protected]> | ||
* Ooops404 <[email protected]> | ||
|
||
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_geo_assign_product_domain>`_ 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,5 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from . import wizards |
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,26 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale Commission Geo Assign Product Domain", | ||
"summary": "Bridge module between " | ||
"sale_commission_product_criteria_domain and " | ||
"sale_commission_geo_assign", | ||
"version": "14.0.1.0.0", | ||
"author": "PyTech SRL, Ooops404, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/commission", | ||
"category": "Sales Management", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"sale_commission_geo_assign", | ||
"sale_commission_product_criteria_domain", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/res_partner_view.xml", | ||
], | ||
"demo": [], | ||
"application": False, | ||
"installable": True, | ||
"auto_install": True, | ||
} |
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,5 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import res_partner | ||
from . import res_partner_commission_group |
26 changes: 26 additions & 0 deletions
26
sale_commission_geo_assign_product_domain/models/res_partner.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,26 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
commission_geo_group_ids = fields.One2many( | ||
comodel_name="res.partner.commission.group", | ||
inverse_name="partner_id", | ||
ondelete="cascade", | ||
) | ||
|
||
@api.onchange("commission_type") | ||
def _onchange_commission_type(self): | ||
if self.commission_type == "product_restricted": | ||
self.write( | ||
{ | ||
"agent_country_ids": False, | ||
"agent_state_ids": False, | ||
"agent_zip_from": False, | ||
"agent_zip_to": False, | ||
} | ||
) |
46 changes: 46 additions & 0 deletions
46
sale_commission_geo_assign_product_domain/models/res_partner_commission_group.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,46 @@ | ||
# Copyright 2023 Ooops404 | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartnerCommissionGroup(models.Model): | ||
_name = "res.partner.commission.group" | ||
_description = "Partner Commission Groups by Geolocation" | ||
|
||
partner_id = fields.Many2one("res.partner", required=True) | ||
country_ids = fields.Many2many("res.country", string="Country") | ||
state_ids = fields.Many2many("res.country.state", string="State") | ||
zip_from = fields.Char("Zip From", help="ZIP range where this agent operates") | ||
zip_to = fields.Char("Zip To", help="ZIP range where this agent operates") | ||
|
||
commission_group_ids = fields.Many2many( | ||
"commission.items.group", | ||
required=True, | ||
domain="[('id', 'in', allowed_commission_group_ids)]", | ||
) | ||
|
||
allowed_commission_group_ids = fields.Many2many( | ||
related="partner_id.allowed_commission_group_ids" | ||
) | ||
|
||
def is_assignable(self, partner): | ||
# Check if line (self) is assignable to 'partner' | ||
self.ensure_one() | ||
if ( | ||
not self.country_ids | ||
and not self.state_ids | ||
and not self.zip_from | ||
and not self.zip_to | ||
): | ||
# if no criteria set on agent, agent is excluded | ||
return False | ||
if self.country_ids and partner.country_id not in self.country_ids: | ||
return False | ||
if self.state_ids and partner.state_id not in self.state_ids: | ||
return False | ||
if self.zip_from and (partner.zip or "").upper() < self.zip_from.upper(): | ||
return False | ||
if self.zip_to and (partner.zip or "").upper() > self.zip_to.upper(): | ||
return False | ||
return True |
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 @@ | ||
In agents with assigned commission type "Product criteria (with restrictions)" it's now possible to set more than one geographic criteria for assignation. Each geo-assignation line must have at least one commission type line group set. |
2 changes: 2 additions & 0 deletions
2
sale_commission_geo_assign_product_domain/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 @@ | ||
* PyTech SRL <[email protected]> | ||
* Ooops404 <[email protected]> |
5 changes: 5 additions & 0 deletions
5
sale_commission_geo_assign_product_domain/readme/DESCRIPTION.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,5 @@ | ||
This is a bridge module between sale_commission_product_criteria_domain and sale_commission_geo_assign. It allows to address the following use case: | ||
|
||
- Assign Agent 1 to customers with address in Spain, and restrict Agent 1's applicable commission type lines to those related to group "Spain"; | ||
|
||
- Assign Agent 1 to customers with address in Italy, and restrict Agent 1's applicable commission type lines to those related to group "Italy". |
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 @@ | ||
Use server action "Add agents with geo assign" on partners as per sale_commission_geo_assign behavior. Lines in table "Commission items group" will be populated with the commission item groups set in agent's geo-assignation criteria. |
2 changes: 2 additions & 0 deletions
2
sale_commission_geo_assign_product_domain/security/ir.model.access.csv
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 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_res_partner_commission_group,access_res_partner_commission_group,model_res_partner_commission_group,sales_team.group_sale_manager,1,1,1,1 |
Binary file added
BIN
+9.23 KB
sale_commission_geo_assign_product_domain/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.