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
15 changed files
with
786 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
===================================== | ||
Partner contact sale info propagation | ||
===================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fsale--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/sale-workflow/tree/12.0/partner_contact_sale_info_propagation | ||
:alt: OCA/sale-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-partner_contact_sale_info_propagation | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/167/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module propagates Salesperson and Sales Channel from Company to Contacts | ||
|
||
* Put the *Salesperson* or *Sales Channel* of the parent company when the | ||
contact doesn't have a *Salesperson* or *Sales Channel* and this parent | ||
company is assigned. | ||
* When the company changes the *Salesperson*, it fills with the same | ||
*Salesperson* all the contacts that don't have any or have the previous | ||
*Salesperson* of the parent company. | ||
* When the company changes the *Sales Channel*, it fills with the same | ||
*Sales Channel* all the contacts that don't have any or have the previous | ||
*Sales Channel* of the parent company. | ||
|
||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, if *Contacts Directory* module is installed: | ||
|
||
#. Go to *Contacts -> Contacts* and create a new contact with Company radio | ||
button checked and a Salesperson selected in *Sales & Purchases* tab | ||
#. Edit this record and add a new contact child in *Contacts & Addresses* tab | ||
#. Go to *Contacts -> Contacts* and open the company created | ||
(contact type company) and its contact child and you will see they have the | ||
same *Salesperson* | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20partner_contact_sale_info_propagation%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Ernesto Tejeda | ||
* Pedro M. Baeza | ||
|
||
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/sale-workflow <https://github.com/OCA/sale-workflow/tree/12.0/partner_contact_sale_info_propagation>`_ 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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
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,20 @@ | ||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Partner contact sale info propagation", | ||
"summary": "Propagate Salesperson and Sales Channel " | ||
"from Company to Contacts", | ||
"version": "12.0.1.0.0", | ||
"category": "Sales Management", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"sales_team", | ||
], | ||
"data": [ | ||
"views/res_partner_view.xml", | ||
], | ||
} |
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,20 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_contact_sale_info_propagation | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: Automatically generated\n" | ||
"Language-Team: none\n" | ||
"Language: de\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
|
||
#. module: partner_contact_sale_info_propagation | ||
#: model:ir.model,name:partner_contact_sale_info_propagation.model_res_partner | ||
msgid "Contact" | ||
msgstr "" |
20 changes: 20 additions & 0 deletions
20
partner_contact_sale_info_propagation/i18n/partner_contact_sale_info_propagation.pot
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,20 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_contact_sale_info_propagation | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.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: partner_contact_sale_info_propagation | ||
#: model:ir.model,name:partner_contact_sale_info_propagation.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import res_partner |
69 changes: 69 additions & 0 deletions
69
partner_contact_sale_info_propagation/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,69 @@ | ||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
from lxml import etree | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
@api.multi | ||
def write(self, vals): | ||
"""Propagate Salesperson and Sales Channel change in the partner to the | ||
child contacts.""" | ||
for record in self: | ||
if 'user_id' in vals: | ||
childs = record.mapped('child_ids').filtered( | ||
lambda r: not r.user_id or r.user_id == record.user_id) | ||
if childs: | ||
childs.write({'user_id': vals['user_id']}) | ||
if 'team_id' in vals: | ||
childs = record.mapped('child_ids').filtered( | ||
lambda r: not r.team_id or r.team_id == record.team_id) | ||
if childs: | ||
childs.write({'team_id': vals['team_id']}) | ||
return super(ResPartner, self).write(vals) | ||
|
||
@api.model | ||
def create(self, vals): | ||
if 'parent_id' in vals: | ||
if 'user_id' not in vals: | ||
vals.update(user_id=self.browse(vals['parent_id']).user_id.id) | ||
if 'team_id' not in vals: | ||
vals.update(team_id=self.browse(vals['parent_id']).team_id.id) | ||
return super(ResPartner, self).create(vals) | ||
|
||
@api.onchange('parent_id') | ||
def onchange_parent_id(self): | ||
"""Change Salesperson or Sales Channel if the parent company changes | ||
and there's no Salesperson or Sales Channel defined yet""" | ||
res = super(ResPartner, self).onchange_parent_id() | ||
if self.parent_id and self.parent_id != self: | ||
parent = self.parent_id | ||
if not self.user_id: | ||
res.setdefault('value', {}).update(user_id=parent.user_id) | ||
if not self.team_id: | ||
res.setdefault('value', {}).update(team_id=parent.team_id) | ||
return res | ||
|
||
@api.model | ||
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, | ||
submenu=False): | ||
res = super().fields_view_get( | ||
view_id=view_id, view_type=view_type, toolbar=toolbar, | ||
submenu=submenu, | ||
) | ||
if view_type == 'form': | ||
partner_xml = etree.XML(res['arch']) | ||
partner_fields = partner_xml.xpath("//field[@name='child_ids']") | ||
if partner_fields: | ||
partner_field = partner_fields[0] | ||
context = partner_field.attrib.get("context", "{}").replace( | ||
"{", | ||
"{'default_user_id': user_id, 'default_team_id': team_id,", | ||
1, | ||
) | ||
partner_field.attrib['context'] = context | ||
res['arch'] = etree.tostring(partner_xml) | ||
return res |
4 changes: 4 additions & 0 deletions
4
partner_contact_sale_info_propagation/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,4 @@ | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Ernesto Tejeda | ||
* Pedro M. Baeza |
12 changes: 12 additions & 0 deletions
12
partner_contact_sale_info_propagation/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,12 @@ | ||
This module propagates Salesperson and Sales Channel from Company to Contacts | ||
|
||
* Put the *Salesperson* or *Sales Channel* of the parent company when the | ||
contact doesn't have a *Salesperson* or *Sales Channel* and this parent | ||
company is assigned. | ||
* When the company changes the *Salesperson*, it fills with the same | ||
*Salesperson* all the contacts that don't have any or have the previous | ||
*Salesperson* of the parent company. | ||
* When the company changes the *Sales Channel*, it fills with the same | ||
*Sales Channel* all the contacts that don't have any or have the previous | ||
*Sales Channel* of the parent company. | ||
|
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,8 @@ | ||
To use this module, if *Contacts Directory* module is installed: | ||
|
||
#. Go to *Contacts -> Contacts* and create a new contact with Company radio | ||
button checked and a Salesperson selected in *Sales & Purchases* tab | ||
#. Edit this record and add a new contact child in *Contacts & Addresses* tab | ||
#. Go to *Contacts -> Contacts* and open the company created | ||
(contact type company) and its contact child and you will see they have the | ||
same *Salesperson* |
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.