From 962b5f7b3e263008a0b1783a1a40ed998a31a0c4 Mon Sep 17 00:00:00 2001 From: cubells Date: Tue, 12 Sep 2017 20:55:36 +0200 Subject: [PATCH] [MIG] partner_contact_lang: Migration to 10.0 --- partner_contact_lang/README.rst | 5 +- .../{__openerp__.py => __manifest__.py} | 7 +- partner_contact_lang/models/res_partner.py | 22 +- .../static/description/icon.svg | 760 ------------------ .../tests/test_partner_contact_lang.py | 26 +- 5 files changed, 30 insertions(+), 790 deletions(-) rename partner_contact_lang/{__openerp__.py => __manifest__.py} (66%) delete mode 100644 partner_contact_lang/static/description/icon.svg diff --git a/partner_contact_lang/README.rst b/partner_contact_lang/README.rst index 0522bafff..93f212be2 100644 --- a/partner_contact_lang/README.rst +++ b/partner_contact_lang/README.rst @@ -1,5 +1,5 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :target: http://www.gnu.org/licenses/agpl :alt: License: AGPL-3 =========================== @@ -25,7 +25,7 @@ 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/9.0 + :target: https://runbot.odoo-community.org/runbot/134/10.0 Bug Tracker =========== @@ -42,6 +42,7 @@ Contributors ------------ * Pedro M. Baeza +* Vicent Cubells Icon ---- diff --git a/partner_contact_lang/__openerp__.py b/partner_contact_lang/__manifest__.py similarity index 66% rename from partner_contact_lang/__openerp__.py rename to partner_contact_lang/__manifest__.py index 6567618a4..acc9b636d 100644 --- a/partner_contact_lang/__openerp__.py +++ b/partner_contact_lang/__manifest__.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- -# © 2016 Pedro M. Baeza +# Copyright 2016 Pedro M. Baeza +# Copyright 2017 Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Manage language in contacts', - 'version': '9.0.1.0.0', - 'category': 'Partner Management', + 'version': '10.0.1.0.0', + 'category': 'Customer Relationship Management', 'license': 'AGPL-3', 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', diff --git a/partner_contact_lang/models/res_partner.py b/partner_contact_lang/models/res_partner.py index 0b6b612c1..b74a3b394 100644 --- a/partner_contact_lang/models/res_partner.py +++ b/partner_contact_lang/models/res_partner.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2016 Pedro M. Baeza +# Copyright 2016 Pedro M. Baeza +# Copyright 2017 Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import api, models @@ -21,21 +22,12 @@ class ResPartner(models.Model): childs.write({'lang': vals['lang']}) return res - @api.multi - def onchange_parent_id(self, parent_id): + @api.onchange('parent_id') + def onchange_parent_id(self): """Change language if the parent company changes and there's no language defined yet""" - res = super(ResPartner, self).onchange_parent_id(parent_id) - if parent_id and self.parent_id.id != parent_id and not self.lang: - parent = self.browse(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'] = parent.lang + val['lang'] = self.parent_id.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 diff --git a/partner_contact_lang/static/description/icon.svg b/partner_contact_lang/static/description/icon.svg deleted file mode 100644 index 95b972591..000000000 --- a/partner_contact_lang/static/description/icon.svg +++ /dev/null @@ -1,760 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/partner_contact_lang/tests/test_partner_contact_lang.py b/partner_contact_lang/tests/test_partner_contact_lang.py index 945245198..c9940d1b3 100644 --- a/partner_contact_lang/tests/test_partner_contact_lang.py +++ b/partner_contact_lang/tests/test_partner_contact_lang.py @@ -1,29 +1,35 @@ # -*- coding: utf-8 -*- -# © 2016 Pedro M. Baeza +# Copyright 2016 Pedro M. Baeza +# Copyright 2017 Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.tests import common +from odoo.tests import common -class TestPartnerContactLang(common.TransactionCase): - def setUp(self): - super(TestPartnerContactLang, self).setUp() - self.ResPartner = self.env['res.partner'] - self.partner = self.ResPartner.create({ +class TestPartnerContactLang(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestPartnerContactLang, cls).setUpClass() + cls.ResPartner = cls.env['res.partner'] + cls.partner = cls.ResPartner.create({ 'name': 'Partner test', 'lang': 'en_US', }) - self.contact = self.ResPartner.create({ + cls.contact = cls.ResPartner.create({ 'name': 'Contact test', 'lang': False, - 'parent_id': self.partner.id, + 'parent_id': cls.partner.id, }) def test_onchange_parent_id(self): self.contact.parent_id = False - res = self.contact.onchange_parent_id(self.partner.id) + res = self.contact.onchange_parent_id() + self.assertIsNone(res) + self.contact.parent_id = self.partner + res = self.contact.onchange_parent_id() self.assertEqual(res.get('value', {}).get('lang'), 'en_US') def test_write_parent_lang(self): + self.partner.lang = False self.partner.lang = 'en_US' self.assertEqual(self.contact.lang, 'en_US')