Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] sale_commission_geo_assign: Migration to 14.0 #348

Merged
merged 6 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions sale_commission_geo_assign/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
===================================
Sales commissions - Geo assignation
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github
:target: https://github.com/OCA/commission/tree/10.0/sale_commission_geo_assign
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/commission-10-0/commission-10-0-sale_commission_geo_assign
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/165/10.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Configure sales agents assigning them to a specific geographical area.

Then, automatically assign agents to customers, according to their geographical area.

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to

Sales > Commissions Management > Agents

For every agent, you can set Countries, States or ZIP range

Usage
=====

Go to

Sales > Customers

Select the customers you want to assign agents to and click

Action > Geo assign agents

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_geo_assign%0Aversion:%2010.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
~~~~~~~

* Agile Business Group

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.

.. |maintainer-eLBati| image:: https://github.com/eLBati.png?size=40px
:target: https://github.com/eLBati
:alt: eLBati

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-eLBati|

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/10.0/sale_commission_geo_assign>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions sale_commission_geo_assign/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import models
from . import wizard
24 changes: 24 additions & 0 deletions sale_commission_geo_assign/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2018 Lorenzo Battistini <https://github.com/eLBati>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Sales commissions - Geo assignation",
"summary": "Assign agents to partners according to their location",
"version": "14.0.1.0.0",
"development_status": "Production/Stable",
"category": "Sales Management",
"website": "https://github.com/OCA/commission",
"author": "Agile Business Group, Odoo Community Association (OCA)",
"maintainers": ["eLBati"],
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"sale_commission",
],
"data": [
"security/ir.model.access.csv",
"views/res_partner_view.xml",
"wizard/wizard_geo_assign_partner_view.xml",
],
}
147 changes: 147 additions & 0 deletions sale_commission_geo_assign/i18n/sale_commission_geo_assign.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_commission_geo_assign
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_commission_geo_assign
#: model:ir.ui.view,arch_db:sale_commission_geo_assign.wizard_geo_assign_partner_view
msgid "Apply"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.ui.view,arch_db:sale_commission_geo_assign.wizard_geo_assign_partner_view
msgid "Cancel"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_check_existing_agents
msgid "Check existing agents"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_partner_agent_country_ids
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_users_agent_country_ids
msgid "Countries"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_partner_agent_country_ids
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_users_agent_country_ids
msgid "Countries where this agent operates"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_create_uid
msgid "Created by"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_create_date
msgid "Created on"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_display_name
msgid "Display Name"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.actions.act_window,name:sale_commission_geo_assign.wizard_geo_assign_partner_action
#: model:ir.ui.view,arch_db:sale_commission_geo_assign.wizard_geo_assign_partner_view
msgid "Geo assign agents"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_id
msgid "ID"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,help:sale_commission_geo_assign.field_wizard_geo_assign_partner_check_existing_agents
msgid "If checked, partners with already assigned agents will be blocked. Otherwise, found agents will be added"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner___last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_write_uid
msgid "Last Updated by"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_wizard_geo_assign_partner_write_date
msgid "Last Updated on"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.ui.view,arch_db:sale_commission_geo_assign.view_res_partner_filter_geo_assign
msgid "No Agents Assigned"
msgstr ""

#. module: sale_commission_geo_assign
#: code:addons/sale_commission_geo_assign/wizard/wizard_geo_assign_partner.py:24
#, python-format
msgid "No agents found in the system"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model,name:sale_commission_geo_assign.model_res_partner
msgid "Partner"
msgstr ""

#. module: sale_commission_geo_assign
#: code:addons/sale_commission_geo_assign/wizard/wizard_geo_assign_partner.py:28
#, python-format
msgid "Partner %s already has agents. You should remove them or deselect 'Check existing agents'"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_partner_agent_state_ids
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_users_agent_state_ids
msgid "States"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_partner_agent_state_ids
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_users_agent_state_ids
msgid "States where this agent operates"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_partner_agent_zip_from
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_partner_agent_zip_to
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_users_agent_zip_from
#: model:ir.model.fields,help:sale_commission_geo_assign.field_res_users_agent_zip_to
msgid "ZIP range where this agent operates"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_partner_agent_zip_from
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_users_agent_zip_from
msgid "Zip From"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_partner_agent_zip_to
#: model:ir.model.fields,field_description:sale_commission_geo_assign.field_res_users_agent_zip_to
msgid "Zip To"
msgstr ""

#. module: sale_commission_geo_assign
#: model:ir.model,name:sale_commission_geo_assign.model_wizard_geo_assign_partner
msgid "wizard.geo.assign.partner"
msgstr ""

3 changes: 3 additions & 0 deletions sale_commission_geo_assign/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from . import res_partner
51 changes: 51 additions & 0 deletions sale_commission_geo_assign/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models


class Partner(models.Model):
_inherit = "res.partner"

agent_country_ids = fields.Many2many(
"res.country", string="Countries", help="Countries where this agent operates"
)
agent_state_ids = fields.Many2many(
"res.country.state", string="States", help="States where this agent operates"
)
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")

@api.onchange("agent_country_ids")
def onchange_countries(self):
if self.agent_country_ids:
domain = [("country_id", "in", self.agent_country_ids.ids)]
else:
domain = []
return {"domain": {"agent_state_ids": domain}}

def is_assignable(self, partner):
# Check if agent (self) is assignable to 'partner'
self.ensure_one()
if (
not self.agent_country_ids
and not self.agent_state_ids
and not self.agent_zip_from
and not self.agent_zip_to
):
# if no criteria set on agent, agent is excluded
return False
if self.agent_country_ids and partner.country_id not in self.agent_country_ids:
return False
if self.agent_state_ids and partner.state_id not in self.agent_state_ids:
return False
if (
self.agent_zip_from
and (partner.zip or "").upper() < self.agent_zip_from.upper()
):
return False
if (
self.agent_zip_to
and (partner.zip or "").upper() > self.agent_zip_to.upper()
):
return False
return True
5 changes: 5 additions & 0 deletions sale_commission_geo_assign/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Go to

Sales > Commissions Management > Agents

For every agent, you can set Countries, States or ZIP range
1 change: 1 addition & 0 deletions sale_commission_geo_assign/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* iwkse <https://ooops404.com>
3 changes: 3 additions & 0 deletions sale_commission_geo_assign/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Configure sales agents assigning them to a specific geographical area.

Then, automatically assign agents to customers, according to their geographical area.
7 changes: 7 additions & 0 deletions sale_commission_geo_assign/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Go to

Sales > Customers

Select the customers you want to assign agents to and click

Action > Geo assign agents
2 changes: 2 additions & 0 deletions sale_commission_geo_assign/security/ir.model.access.csv
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_wizard_geo_assign_partner","access.wizard.geo.assign.partner","model_wizard_geo_assign_partner","base.group_partner_manager",1,1,1,0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading