Browse Source

[MIG] 13.0 partner_contact_lang

14.0
Pedro 5 years ago
committed by newtratip
parent
commit
a846dc762c
  1. 16
      partner_contact_lang/README.rst
  2. 2
      partner_contact_lang/__init__.py
  3. 8
      partner_contact_lang/__manifest__.py
  4. 2
      partner_contact_lang/i18n/partner_contact_lang.pot
  5. 2
      partner_contact_lang/models/__init__.py
  6. 15
      partner_contact_lang/models/res_partner.py
  7. 1
      partner_contact_lang/readme/CONTRIBUTORS.rst
  8. 3
      partner_contact_lang/readme/DESCRIPTION.rst
  9. 20
      partner_contact_lang/static/description/index.html
  10. 2
      partner_contact_lang/tests/__init__.py
  11. 8
      partner_contact_lang/tests/test_partner_contact_lang.py
  12. 41
      partner_contact_lang/views/res_partner_view.xml

16
partner_contact_lang/README.rst

@ -11,16 +11,16 @@ Manage language in contacts
:target: https://odoo-community.org/page/development-status :target: https://odoo-community.org/page/development-status
:alt: Beta :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/11.0/partner_contact_lang
:target: https://github.com/OCA/partner-contact/tree/13.0/partner_contact_lang
:alt: OCA/partner-contact :alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-partner_contact_lang
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_contact_lang
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/11.0
:target: https://runbot.odoo-community.org/runbot/134/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -35,6 +35,9 @@ contact language management:
language and this parent company is assigned. language and this parent company is assigned.
#. When the company changes the language, it fills with the same language all #. When the company changes the language, it fills with the same language all
the contacts that don't have any. the contacts that don't have any.
#. Show the language in the inner narrowed Contact form and
set the new conctact with a different language if needed.
#. Search and also group contacts by their language.
**Table of contents** **Table of contents**
@ -53,7 +56,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_. 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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_lang%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_lang%0Aversion:%2013.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. Do not contact contributors directly about support or help with technical issues.
@ -74,6 +77,7 @@ Contributors
* Vicent Cubells * Vicent Cubells
* David Vidal * David Vidal
* Cristina Martín * Cristina Martín
* Pedro Evaristo Gonzalez Sanchez <pedro.gonzalez@pesol.es>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -88,6 +92,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/11.0/partner_contact_lang>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/partner_contact_lang>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
partner_contact_lang/__init__.py

@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models from . import models

8
partner_contact_lang/__manifest__.py

@ -1,14 +1,16 @@
# Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com> # Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com> # Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2020 Pesol - Pedro Evaristo Gonzalez Sanchez <pedro.gonzalez@pesol.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Manage language in contacts", "name": "Manage language in contacts",
"version": "11.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Sales", "category": "Sales",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Tecnativa," "Odoo Community Association (OCA)", "author": "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact/", "website": "https://github.com/OCA/partner-contact/",
"depends": ["base",],
"depends": ["base"],
"data": ["views/res_partner_view.xml"],
"installable": True, "installable": True,
} }

2
partner_contact_lang/i18n/partner_contact_lang.pot

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"

2
partner_contact_lang/models/__init__.py

@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import res_partner from . import res_partner

15
partner_contact_lang/models/res_partner.py

@ -1,6 +1,6 @@
# Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com> # Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com> # Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models from odoo import api, models
@ -8,12 +8,11 @@ from odoo import api, models
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
@api.multi
def write(self, vals): def write(self, vals):
"""Propagate a language change in the partner to the child contacts.""" """Propagate a language change in the partner to the child contacts."""
res = super(ResPartner, self).write(vals) res = super(ResPartner, self).write(vals)
if vals.get("lang"): if vals.get("lang"):
childs = self.search([("id", "child_of", self.ids), ("lang", "=", False),])
childs = self.search([("id", "child_of", self.ids), ("lang", "=", False)])
if childs: if childs:
childs.write({"lang": vals["lang"]}) childs.write({"lang": vals["lang"]})
return res return res
@ -23,7 +22,11 @@ class ResPartner(models.Model):
"""Change language if the parent company changes and there's no """Change language if the parent company changes and there's no
language defined yet""" language defined yet"""
res = super(ResPartner, self).onchange_parent_id() res = super(ResPartner, self).onchange_parent_id()
if self.parent_id and self.parent_id != self and not self.lang:
val = res.setdefault("value", {})
val["lang"] = self.parent_id.lang
if (
self.parent_id
and self.parent_id != self
and not self.lang
and self.parent_id.lang
):
self.lang = self.parent_id.lang
return res return res

1
partner_contact_lang/readme/CONTRIBUTORS.rst

@ -4,3 +4,4 @@
* Vicent Cubells * Vicent Cubells
* David Vidal * David Vidal
* Cristina Martín * Cristina Martín
* Pedro Evaristo Gonzalez Sanchez <pedro.gonzalez@pesol.es>

3
partner_contact_lang/readme/DESCRIPTION.rst

@ -8,3 +8,6 @@ contact language management:
language and this parent company is assigned. language and this parent company is assigned.
#. When the company changes the language, it fills with the same language all #. When the company changes the language, it fills with the same language all
the contacts that don't have any. the contacts that don't have any.
#. Show the language in the inner narrowed Contact form and
set the new conctact with a different language if needed.
#. Search and also group contacts by their language.

20
partner_contact_lang/static/description/index.html

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.15.1: https://docutils.sourceforge.net/" />
<title>Manage language in contacts</title> <title>Manage language in contacts</title>
<style type="text/css"> <style type="text/css">
@ -14,7 +14,7 @@
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
*/ */
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/11.0/partner_contact_lang"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-partner_contact_lang"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="https://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.0/partner_contact_lang"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_contact_lang"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Odoo by default propagate language field to the created contacts from their <p>Odoo by default propagate language field to the created contacts from their
form, but it doesn’t allow to change it once created.</p> form, but it doesn’t allow to change it once created.</p>
<p>This module fills this gap, and also provides other facilities for the <p>This module fills this gap, and also provides other facilities for the
@ -375,7 +375,10 @@ contact language management:</p>
<p>#. Put the language of the parent company when the contact doesn’t have a <p>#. Put the language of the parent company when the contact doesn’t have a
language and this parent company is assigned. language and this parent company is assigned.
#. When the company changes the language, it fills with the same language all #. When the company changes the language, it fills with the same language all
the contacts that don’t have any.</p>
the contacts that don’t have any.
#. Show the language in the inner narrowed Contact form and
set the new conctact with a different language if needed.
#. Search and also group contacts by their language.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
@ -401,7 +404,7 @@ the contacts that don’t have any.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_lang%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_lang%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -420,6 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Vicent Cubells</li> <li>Vicent Cubells</li>
<li>David Vidal</li> <li>David Vidal</li>
<li>Cristina Martín</li> <li>Cristina Martín</li>
<li>Pedro Evaristo Gonzalez Sanchez &lt;<a class="reference external" href="mailto:pedro.gonzalez&#64;pesol.es">pedro.gonzalez&#64;pesol.es</a>&gt;</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -431,7 +435,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/11.0/partner_contact_lang">OCA/partner-contact</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.0/partner_contact_lang">OCA/partner-contact</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

2
partner_contact_lang/tests/__init__.py

@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import test_partner_contact_lang from . import test_partner_contact_lang

8
partner_contact_lang/tests/test_partner_contact_lang.py

@ -1,7 +1,7 @@
# Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com> # Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com> # Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com>
# Copyright 2018 Tecnativa - Cristina Martín # Copyright 2018 Tecnativa - Cristina Martín
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests import common from odoo.tests import common
@ -11,9 +11,9 @@ class TestPartnerContactLang(common.SavepointCase):
def setUpClass(cls): def setUpClass(cls):
super(TestPartnerContactLang, cls).setUpClass() super(TestPartnerContactLang, cls).setUpClass()
cls.ResPartner = cls.env["res.partner"] cls.ResPartner = cls.env["res.partner"]
cls.partner = cls.ResPartner.create({"name": "Partner test", "lang": "en_US",})
cls.partner = cls.ResPartner.create({"name": "Partner test", "lang": "en_US"})
cls.contact = cls.ResPartner.create( cls.contact = cls.ResPartner.create(
{"name": "Contact test", "lang": False, "parent_id": cls.partner.id,}
{"name": "Contact test", "lang": False, "parent_id": cls.partner.id}
) )
def test_onchange_parent_id(self): def test_onchange_parent_id(self):
@ -22,7 +22,7 @@ class TestPartnerContactLang(common.SavepointCase):
self.assertIsNone(res) self.assertIsNone(res)
self.contact.parent_id = self.partner self.contact.parent_id = self.partner
res = self.contact.onchange_parent_id() res = self.contact.onchange_parent_id()
self.assertEqual(res.get("value", {}).get("lang"), "en_US")
self.assertEqual(self.contact.lang, "en_US")
def test_write_parent_lang(self): def test_write_parent_lang(self):
"""First empty the field for filling it again afterwards to see if """First empty the field for filling it again afterwards to see if

41
partner_contact_lang/views/res_partner_view.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Copyright 2020 Pesol <pedro.gonzalez@pesol.es>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<record id="view_partner_form" model="ir.ui.view">
<field name="name">view.partner.address.form.extension</field>
<field name="model">res.partner</field>
<field name="priority">100</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='child_ids']/form/sheet/field[@name='lang']"
position="replace"
>
<field name="active_lang_count" invisible="1" />
<group attrs="{'invisible': [('active_lang_count', '&lt;=', 1)]}">
<group>
<field name="lang" />
</group>
</group>
</xpath>
</field>
</record>
<record id="view_res_partner_filter" model="ir.ui.view">
<field name="name">res.partner.filter.extension</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="arch" type="xml">
<xpath expr="//field[@name='parent_id']" position="after">
<field name="lang" />
</xpath>
<xpath expr="//group[@name='group_by']" position="inside">
<filter
name="language"
string="Language"
context="{'group_by' : 'lang'}"
/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save