Skip to content

Commit

Permalink
[MIG] crm_location: Migrated to 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luismontalba authored and pedrobaeza committed Jun 18, 2017
1 parent e77d85c commit 7461c1b
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 114 deletions.
21 changes: 14 additions & 7 deletions crm_location/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/OCA/crm/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 <https://github.com/OCA/crm/issues/new?body=module:%20crm_location%0Aversion:%201.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/crm/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 <endikaig@antiun.com>
* Rafael Blasco <rafabn@antiun.com>

* Rafael Blasco <rafael.blasco@tecnativa.com>
* Luis M. Ontalba <luis.martinez@tecnativa.com>

Maintainer
----------
Expand All @@ -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.
To contribute to this module, please visit https://odoo-community.org.
23 changes: 1 addition & 22 deletions crm_location/__init__.py
Original file line number Diff line number Diff line change
@@ -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 <endikaig@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models
33 changes: 7 additions & 26 deletions crm_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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 <endikaig@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2015 Antiun Ingenieria - Endika Iglesias <endikaig@antiun.com>
# 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,
}
23 changes: 1 addition & 22 deletions crm_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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 <endikaig@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import crm_lead
42 changes: 9 additions & 33 deletions crm_location/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -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 <endikaig@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2015 Antiun Ingenieria - Endika Iglesias <endikaig@antiun.com>
# 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:
Expand All @@ -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
4 changes: 4 additions & 0 deletions crm_location/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0

from . import test_crm_location
52 changes: 52 additions & 0 deletions crm_location/tests/test_crm_location.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 2 additions & 4 deletions crm_location/views/crm_lead_view.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>

<record id="crm_case_form_view_leads" model="ir.ui.view">
<field name="name">Add city completion helper field</field>
Expand Down Expand Up @@ -30,5 +29,4 @@
</field>
</record>

</data>
</openerp>
</odoo>

0 comments on commit 7461c1b

Please sign in to comment.