Skip to content

Commit

Permalink
ADD sale_commission_geo_assign
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Oct 30, 2018
1 parent 1d45131 commit bd309a1
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 0 deletions.
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.
5 changes: 5 additions & 0 deletions sale_commission_geo_assign/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# 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 @@
# -*- coding: utf-8 -*-
# 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": "10.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": [
"views/res_partner_view.xml",
"wizard/wizard_geo_assign_partner_view.xml",
],
}
4 changes: 4 additions & 0 deletions sale_commission_geo_assign/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

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

from odoo import models, fields, api


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

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

@api.onchange('country_ids')
def onchange_countries(self):
if self.country_ids:
domain = [('country_id', 'in', self.country_ids.ids)]
else:
domain = []
return {'domain': {
'state_ids': domain
}}

@api.multi
def verify_agent(self, 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
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
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
Loading

0 comments on commit bd309a1

Please sign in to comment.