From c989ff23d55b3aa7ae71363714f90c57f8925db6 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Thu, 14 Sep 2023 17:29:08 +0200 Subject: [PATCH] [IMP] sale_commission_geo_assign: improve geo assignment wizard --- sale_commission_geo_assign/README.rst | 19 +++- .../models/res_partner.py | 2 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 2 + sale_commission_geo_assign/readme/USAGE.rst | 14 ++- .../static/description/index.html | 55 ++++++----- .../tests/test_sale_commission_geo_assign.py | 97 +++++++++++++++---- .../views/res_partner_view.xml | 31 +++--- .../wizard/wizard_geo_assign_partner.py | 37 +++++-- .../wizard/wizard_geo_assign_partner_view.xml | 14 ++- 10 files changed, 200 insertions(+), 72 deletions(-) diff --git a/sale_commission_geo_assign/README.rst b/sale_commission_geo_assign/README.rst index 743a37adb..76633f1bf 100644 --- a/sale_commission_geo_assign/README.rst +++ b/sale_commission_geo_assign/README.rst @@ -7,7 +7,7 @@ Sales commissions - Geo assignation !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:e5b8d9c524a1a7e7c6d2340c01f7feb4eb4499037913921c2bca92e811ac530c + !! source digest: sha256:3ac49498e2384e8c24d7c886e656c261d2f82485a67806cc42e0f1e7648a0681 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png @@ -32,6 +32,8 @@ Configure sales agents assigning them to a specific geographical area. Then, automatically assign agents to customers, according to their geographical area. +A "Do not allow update with Geo Assign" setting can be activated in partner to prevent server action from editing set agents. + **Table of contents** .. contents:: @@ -49,13 +51,23 @@ For every agent, you can set Countries, States or ZIP range Usage ===== -Go to +Go to Sales > Agents > open a record: in tab "Agent information", set geographic criteria. + +When using server action, this agent will be assigned to customers whose address match the set criteria. + +To assign agents, go to: Sales > Customers Select the customers you want to assign agents to and click -Action > Geo assign agents +Action > Add agents with geo assign + +- Activating flag "Replace existing agents" will remove agents set in partner and replace them according to geographic criteria. + +- Activating flag "Do not add new agents if agents are already assigned" will prevent assignation if agents are already set in partner. + +- Deactivating both flags will simply add agents to existing ones in partner according to geographic criteria. Bug Tracker =========== @@ -79,6 +91,7 @@ Contributors ~~~~~~~~~~~~ * iwkse +* PyTech SRL Maintainers ~~~~~~~~~~~ diff --git a/sale_commission_geo_assign/models/res_partner.py b/sale_commission_geo_assign/models/res_partner.py index 5d2bd540f..b7df64b91 100644 --- a/sale_commission_geo_assign/models/res_partner.py +++ b/sale_commission_geo_assign/models/res_partner.py @@ -15,6 +15,8 @@ class Partner(models.Model): agent_zip_from = fields.Char("Zip From", help="ZIP range where this agent operates") agent_zip_to = fields.Char("Zip To", help="ZIP range where this agent operates") + no_geo_assign_update = fields.Boolean("Do not allow update with Geo Assign") + @api.onchange("agent_country_ids") def onchange_countries(self): if self.agent_country_ids: diff --git a/sale_commission_geo_assign/readme/CONTRIBUTORS.rst b/sale_commission_geo_assign/readme/CONTRIBUTORS.rst index 7a216c144..f172b67d7 100644 --- a/sale_commission_geo_assign/readme/CONTRIBUTORS.rst +++ b/sale_commission_geo_assign/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * iwkse +* PyTech SRL diff --git a/sale_commission_geo_assign/readme/DESCRIPTION.rst b/sale_commission_geo_assign/readme/DESCRIPTION.rst index 80481ed63..bb3b71b6d 100644 --- a/sale_commission_geo_assign/readme/DESCRIPTION.rst +++ b/sale_commission_geo_assign/readme/DESCRIPTION.rst @@ -1,3 +1,5 @@ Configure sales agents assigning them to a specific geographical area. Then, automatically assign agents to customers, according to their geographical area. + +A "Do not allow update with Geo Assign" setting can be activated in partner to prevent server action from editing set agents. diff --git a/sale_commission_geo_assign/readme/USAGE.rst b/sale_commission_geo_assign/readme/USAGE.rst index bdd227399..720f92398 100644 --- a/sale_commission_geo_assign/readme/USAGE.rst +++ b/sale_commission_geo_assign/readme/USAGE.rst @@ -1,7 +1,17 @@ -Go to +Go to Sales > Agents > open a record: in tab "Agent information", set geographic criteria. + +When using server action, this agent will be assigned to customers whose address match the set criteria. + +To assign agents, go to: Sales > Customers Select the customers you want to assign agents to and click -Action > Geo assign agents +Action > Add agents with geo assign + +- Activating flag "Replace existing agents" will remove agents set in partner and replace them according to geographic criteria. + +- Activating flag "Do not add new agents if agents are already assigned" will prevent assignation if agents are already set in partner. + +- Deactivating both flags will simply add agents to existing ones in partner according to geographic criteria. diff --git a/sale_commission_geo_assign/static/description/index.html b/sale_commission_geo_assign/static/description/index.html index 680e87ed1..b2333d753 100644 --- a/sale_commission_geo_assign/static/description/index.html +++ b/sale_commission_geo_assign/static/description/index.html @@ -1,20 +1,20 @@ - + - + Sales commissions - Geo assignation