diff --git a/crm_sector/README.rst b/crm_sector/README.rst index 1e8871c314ba..a4b4a6c27839 100644 --- a/crm_sector/README.rst +++ b/crm_sector/README.rst @@ -12,7 +12,7 @@ This module adds the concept of economic sector for leads and opportunities. .. 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/8.0 + :target: https://runbot.odoo-community.org/runbot/111/10.0 Bug Tracker @@ -38,6 +38,7 @@ Contributors * Rafael Blasco * Antonio Espinosa * Javier Iniesta +* Luis M. Ontalba Maintainer ---------- diff --git a/crm_sector/__init__.py b/crm_sector/__init__.py index ba0257333912..a77a6fcbc5d3 100644 --- a/crm_sector/__init__.py +++ b/crm_sector/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/crm_sector/__openerp__.py b/crm_sector/__manifest__.py similarity index 95% rename from crm_sector/__openerp__.py rename to crm_sector/__manifest__.py index 2e969643ba20..c695123d00cd 100644 --- a/crm_sector/__openerp__.py +++ b/crm_sector/__manifest__.py @@ -5,7 +5,7 @@ { "name": "CRM Sector", "summary": "Link leads/opportunities to sectors", - "version": "8.0.1.0.0", + "version": "10.0.1.0.0", "category": "Customer Relationship Management", "website": "http://www.antiun.com", "author": "Antiun Ingeniería, " diff --git a/crm_sector/models/__init__.py b/crm_sector/models/__init__.py index c74f300c9f07..77232a4b8e7b 100644 --- a/crm_sector/models/__init__.py +++ b/crm_sector/models/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingenieria S.L. - Javier Iniesta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import crm_lead diff --git a/crm_sector/models/crm_lead.py b/crm_sector/models/crm_lead.py index 2708bb6ce7b1..afe6f5e863fe 100644 --- a/crm_sector/models/crm_lead.py +++ b/crm_sector/models/crm_lead.py @@ -2,14 +2,14 @@ # © 2015 Antiun Ingenieria S.L. - Javier Iniesta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields, api, exceptions, _ +from odoo import _, api, exceptions, fields, models class CrmLead(models.Model): _inherit = 'crm.lead' sector_id = fields.Many2one(comodel_name='res.partner.sector', - string='Main Sector', oldname='sector') + string='Main Sector') secondary_sector_ids = fields.Many2many( comodel_name='res.partner.sector', string="Secondary Sectors", @@ -19,19 +19,18 @@ class CrmLead(models.Model): @api.constrains('sector_id', 'secondary_sector_ids') def _check_sectors(self): if self.sector_id in self.secondary_sector_ids: - raise exceptions.Warning(_('The secondary sectors must be ' + raise exceptions.UserError(_('The secondary sectors must be ' 'different from the main sector.')) - @api.model - def _lead_create_contact(self, lead, name, is_company, parent_id=False): + @api.multi + def _lead_create_contact(self, name, is_company, + parent_id=False): """Propagate sector to created partner. """ - partner_id = super(CrmLead, self)._lead_create_contact( - lead, name, is_company, parent_id) - secondary_sector_ids = [] - for sector in lead.secondary_sector_ids: - secondary_sector_ids.append((4, sector.id, 0)) - self.env['res.partner'].browse(partner_id).write( - {'sector_id': lead.sector_id.id, - 'secondary_sector_ids': secondary_sector_ids}) - return partner_id + partner = super(CrmLead, self)._lead_create_contact( + name, is_company, parent_id) + partner.write({ + 'sector_id': self.sector_id.id, + 'secondary_sector_ids': [(6, 0, self.secondary_sector_ids.ids)], + }) + return partner diff --git a/crm_sector/tests/__init__.py b/crm_sector/tests/__init__.py index f81c7bead0e0..9dda74db5769 100644 --- a/crm_sector/tests/__init__.py +++ b/crm_sector/tests/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingenieria S.L. - Javier Iniesta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_crm_lead diff --git a/crm_sector/tests/test_crm_lead.py b/crm_sector/tests/test_crm_lead.py index 1bec966df313..a6c375a62fb8 100644 --- a/crm_sector/tests/test_crm_lead.py +++ b/crm_sector/tests/test_crm_lead.py @@ -2,8 +2,8 @@ # © 2015 Antiun Ingenieria S.L. - Javier Iniesta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.tests.common import TransactionCase -from openerp.exceptions import ValidationError +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError class TestCrmLead(TransactionCase): @@ -26,12 +26,11 @@ def test_lead_create_contact(self): 'name': 'test', 'partner_name': 'test', 'sector_id': sector_1.id, - 'secondary_sector_ids': [(4, sector_2.id, 0), (4, sector_3.id, 0)] + 'secondary_sector_ids': [(4, sector_2.id, 0), (4, sector_3.id, 0)], } lead = self.env['crm.lead'].create(lead_vals) - partner_id = self.env['crm.lead']._lead_create_contact( - lead, lead.partner_name, True) - partner = self.env['res.partner'].browse(partner_id) - self.assertEqual(partner.sector_id.id, lead.sector_id.id) - self.assertListEqual(partner.secondary_sector_ids.ids, - lead.secondary_sector_ids.ids) + partner = lead._lead_create_contact( + lead.partner_name, True, False) + self.assertEqual(partner.sector_id, lead.sector_id) + self.assertEqual( + partner.secondary_sector_ids, lead.secondary_sector_ids) diff --git a/crm_sector/views/crm_lead_view.xml b/crm_sector/views/crm_lead_view.xml index 7c72c6a3ed09..d54c989ca8d6 100644 --- a/crm_sector/views/crm_lead_view.xml +++ b/crm_sector/views/crm_lead_view.xml @@ -1,8 +1,7 @@ - - + Add sector field @@ -22,7 +21,7 @@ crm.lead - + @@ -33,10 +32,10 @@ crm.lead - + - + @@ -62,7 +61,7 @@ crm.lead - + @@ -73,10 +72,10 @@ crm.lead - + - + @@ -84,5 +83,4 @@ - - + diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 000000000000..798e7709644d --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1,2 @@ +partner-contact +