From 7461c1bfec523c583ea2d19d20283681a826f6a0 Mon Sep 17 00:00:00 2001 From: "Luis M. Ontalba" Date: Thu, 8 Jun 2017 09:13:10 +0200 Subject: [PATCH] [MIG] crm_location: Migrated to 10.0 --- crm_location/README.rst | 21 ++++++---- crm_location/__init__.py | 23 +---------- crm_location/__manifest__.py | 33 ++++------------ crm_location/models/__init__.py | 23 +---------- crm_location/models/crm_lead.py | 42 +++++--------------- crm_location/tests/__init__.py | 4 ++ crm_location/tests/test_crm_location.py | 52 +++++++++++++++++++++++++ crm_location/views/crm_lead_view.xml | 6 +-- 8 files changed, 90 insertions(+), 114 deletions(-) create mode 100644 crm_location/tests/__init__.py create mode 100644 crm_location/tests/test_crm_location.py diff --git a/crm_location/README.rst b/crm_location/README.rst index 9a1cde943d3..21f9cea14bc 100644 --- a/crm_location/README.rst +++ b/crm_location/README.rst @@ -17,21 +17,28 @@ To install this module, you need: * crm * base_location located in OCA/partner-contact repo +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/111/10.0 + Bug Tracker =========== -Bugs are tracked on `GitHub 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 -`here `_. +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. Contributors ------------ * Endika Iglesias -* Rafael Blasco - +* Rafael Blasco +* Luis M. Ontalba Maintainer ---------- @@ -46,4 +53,4 @@ 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 http://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/crm_location/__init__.py b/crm_location/__init__.py index b5c82df182c..4d8ae82d6d7 100644 --- a/crm_location/__init__.py +++ b/crm_location/__init__.py @@ -1,25 +1,4 @@ # -*- coding: utf-8 -*- -# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright : -# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) -# Endika Iglesias -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import models diff --git a/crm_location/__manifest__.py b/crm_location/__manifest__.py index 483ba88e5ff..736f39d5019 100644 --- a/crm_location/__manifest__.py +++ b/crm_location/__manifest__.py @@ -1,39 +1,20 @@ # -*- coding: utf-8 -*- -# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright : -# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) -# Endika Iglesias -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2015 Antiun Ingenieria - Endika Iglesias +# Copyright 2017 Tecnativa - Luis Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { 'name': 'CRM location', 'category': 'Customer Relationship Management', - 'version': '8.0.1.0.0', + 'version': '10.0.1.0.0', 'depends': [ 'crm', 'base_location', ], 'data': ['views/crm_lead_view.xml'], - 'author': 'Antiun Ingeniería S.L., ' + 'author': 'Tecnativa, ' 'Odoo Community Association (OCA)', - 'website': 'http://www.antiun.com', + 'website': 'https://www.tecnativa.com', 'license': 'AGPL-3', - 'installable': False, + 'installable': True, } diff --git a/crm_location/models/__init__.py b/crm_location/models/__init__.py index 04bcd2f1eb0..a2258dbb77f 100644 --- a/crm_location/models/__init__.py +++ b/crm_location/models/__init__.py @@ -1,25 +1,4 @@ # -*- coding: utf-8 -*- -# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright : -# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) -# Endika Iglesias -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import crm_lead diff --git a/crm_location/models/crm_lead.py b/crm_location/models/crm_lead.py index d69afbf126f..b976591fb89 100644 --- a/crm_location/models/crm_lead.py +++ b/crm_location/models/crm_lead.py @@ -1,34 +1,15 @@ # -*- coding: utf-8 -*- -# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright : -# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) -# Endika Iglesias -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2015 Antiun Ingenieria - Endika Iglesias +# Copyright 2017 Tecnativa - Luis Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, fields, api +from odoo import api, fields, models class CrmLead(models.Model): _inherit = 'crm.lead' - @api.one + @api.multi @api.onchange('location_id') def on_change_city(self): if self.location_id: @@ -44,12 +25,7 @@ def on_change_city(self): help='Use the city name or the zip code to search the location', ) - @api.multi - def on_change_partner_id(self, partner_id): - res = super(CrmLead, self).on_change_partner_id(partner_id) - if 'value' not in res: - res['value'] = {} - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - res['value']['location_id'] = partner.zip_id.id - return {'value': res['value']} + @api.onchange('partner_id') + def onchange_partner_id_crm_location(self): + if self.partner_id: + self.location_id = self.partner_id.zip_id.id diff --git a/crm_location/tests/__init__.py b/crm_location/tests/__init__.py new file mode 100644 index 00000000000..d1c4c63b7ac --- /dev/null +++ b/crm_location/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from . import test_crm_location diff --git a/crm_location/tests/test_crm_location.py b/crm_location/tests/test_crm_location.py new file mode 100644 index 00000000000..45622cbcc15 --- /dev/null +++ b/crm_location/tests/test_crm_location.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Luis M. Ontalba +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from odoo.tests import common + + +class TestCrmLocation(common.SavepointCase): + + @classmethod + def setUpClass(cls): + super(TestCrmLocation, cls).setUpClass() + cls.country = cls.env['res.country'].create({ + 'name': 'Country test', + }) + cls.state = cls.env['res.country.state'].create({ + 'name': 'Test state', + 'code': 'Test state code', + 'country_id': cls.country.id, + }) + cls.location = cls.env['res.better.zip'].create({ + 'name': '12345', + 'city': 'Test city', + 'country_id': cls.country.id, + 'code': 'Test code', + 'state_id': cls.state.id, + }) + cls.lead = cls.env['crm.lead'].create({ + 'name': 'Test lead', + }) + cls.partner = cls.env['res.partner'].create({ + 'name': 'Test partner name', + }) + + def test_on_change_city(self): + lead = self.lead + location = self.location + lead.location_id = location.id + lead.on_change_city() + self.assertEqual(lead.zip, location.name) + self.assertEqual(lead.city, location.city) + self.assertEqual(lead.state_id, location.state_id) + self.assertEqual(lead.country_id, location.country_id) + + def test_onchange_partner_id_crm_location(self): + lead = self.lead + partner = self.partner + location = self.location + partner.zip_id = location.id + lead.partner_id = partner.id + lead.onchange_partner_id_crm_location() + self.assertEqual(lead.location_id, partner.zip_id) diff --git a/crm_location/views/crm_lead_view.xml b/crm_location/views/crm_lead_view.xml index 31fc9c0d9d2..f6c233e4094 100644 --- a/crm_location/views/crm_lead_view.xml +++ b/crm_location/views/crm_lead_view.xml @@ -1,6 +1,5 @@ - - + Add city completion helper field @@ -30,5 +29,4 @@ - - +