-
-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] partner_contact_lang: Manage language in contacts (#302)
=========================== Manage language in contacts =========================== Odoo by default propagate language field to the created contacts from their form, but it doesn't allow to change it once created. This module fills this gap, and also provides other facilities for the contact language management: * Put the language of the parent company when the contact doesn't have a language and this parent company is assigned. * When the company changes the language, it fills with the same language all the contacts that don't have any. Usage ===== Go to any partner that is a company and has contacts. Click on one contact and you will be able to edit the language.
- Loading branch information
1 parent
adb466a
commit 6be6679
Showing
10 changed files
with
942 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,63 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
=========================== | ||
Manage language in contacts | ||
=========================== | ||
|
||
Odoo by default propagate language field to the created contacts from their | ||
form, but it doesn't allow to change it once created. | ||
|
||
This module fills this gap, and also provides other facilities for the | ||
contact language management: | ||
|
||
* Put the language of the parent company when the contact doesn't have a | ||
language and this parent company is assigned. | ||
* When the company changes the language, it fills with the same language all | ||
the contacts that don't have any. | ||
|
||
Usage | ||
===== | ||
|
||
Go to any partner that is a company and has contacts. Click on one contact | ||
and you will be able to edit the language. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/134/8.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/partner-contact/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. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
|
||
Icon | ||
---- | ||
* Original Odoo icons. | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Manage language in contacts', | ||
'version': '8.0.1.0.0', | ||
'category': 'Partner Management', | ||
'license': 'AGPL-3', | ||
'author': 'Tecnativa,' | ||
'Odoo Community Association (OCA)', | ||
'website': 'https://www.tecnativa.com', | ||
'depends': [ | ||
'base', | ||
], | ||
'data': [ | ||
'views/res_partner_view.xml', | ||
], | ||
'installable': 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,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import res_partner |
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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import api, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
@api.multi | ||
def write(self, vals): | ||
"""Propagate a language change in the partner to the child contacts.""" | ||
res = super(ResPartner, self).write(vals) | ||
if vals.get('lang'): | ||
childs = self.search([ | ||
('id', 'child_of', self.ids), | ||
('lang', '=', False), | ||
]) | ||
if childs: | ||
childs.write({'lang': vals['lang']}) | ||
return res | ||
|
||
@api.multi | ||
def onchange_address(self, use_parent_address, parent_id): | ||
"""Change language if the parent company changes and there's no | ||
language defined yet""" | ||
res = super(ResPartner, self).onchange_address( | ||
use_parent_address, parent_id) | ||
if parent_id and self.parent_id.id != parent_id and not self.lang: | ||
parent = self.browse(parent_id) | ||
val = res.setdefault('value', {}) | ||
val['lang'] = parent.lang | ||
return res | ||
|
||
@api.multi | ||
@api.onchange('lang') | ||
def onchange_lang(self): | ||
if self.lang: | ||
childs = self.child_ids.filtered(lambda x: not x.lang) | ||
for child in childs: | ||
child.lang = self.lang |
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.