Skip to content

Commit

Permalink
[MIG] base_location: Migration to 13.0
Browse files Browse the repository at this point in the history
* Standard procedure
* Change v13 specifics
* Adapt tests + correct some practices
  • Loading branch information
pedrobaeza committed Sep 30, 2019
1 parent 6f1a16e commit 2fdc70e
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 110 deletions.
10 changes: 5 additions & 5 deletions base_location/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Location management (aka Better ZIP)
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/12.0/base_location
:target: https://github.com/OCA/partner-contact/tree/13.0/base_location
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-base_location
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-base_location
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/12.0
:target: https://runbot.odoo-community.org/runbot/134/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -63,7 +63,7 @@ Bug Tracker
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.
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:%20base_location%0Aversion:%2012.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:%20base_location%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.

Expand Down Expand Up @@ -110,6 +110,6 @@ 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.

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/12.0/base_location>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/base_location>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions base_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2016 Nicolas Bessi, Camptocamp SA
# Copyright 2018 Tecnativa - Pedro M. Baeza
# Copyright 2018-2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Location management (aka Better ZIP)',
'version': '12.0.1.0.1',
'version': '13.0.1.0.0',
'depends': [
'base_address_city',
'contacts',
Expand Down
66 changes: 0 additions & 66 deletions base_location/migrations/12.0.1.0.0/post-migration.py

This file was deleted.

15 changes: 0 additions & 15 deletions base_location/migrations/12.0.1.0.0/pre-migration.py

This file was deleted.

1 change: 0 additions & 1 deletion base_location/models/res_city_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ResCityZip(models.Model):
'The zip code must be unique within it\'s city'),
]

@api.multi
@api.depends('name', 'city_id')
def _compute_new_display_name(self):
for rec in self:
Expand Down
3 changes: 1 addition & 2 deletions base_location/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ class ResCompany(models.Model):
string='ZIP Location',
compute='_compute_address',
inverse='_inverse_zip_id',
oldname="better_zip_id",
help='Use the city name or the zip code to search the location',
)

country_enforce_cities = fields.Boolean(
related='country_id.enforce_cities'
related='partner_id.country_id.enforce_cities',
)

def _get_company_address_fields(self, partner):
Expand Down
6 changes: 3 additions & 3 deletions base_location/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Location management (aka Better ZIP)</h1>
!! This file is generated by oca-gen-addon-readme !!
!! 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/12.0/base_location"><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-12-0/partner-contact-12-0-base_location"><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/12.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="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/13.0/base_location"><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-base_location"><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>This module introduces a zip model that allows you to manage locations in a better way.</p>
<p>The zips will allow the users to complete automatically all address-related fields by just filling the zip.</p>
<p>Also allows different search filters.</p>
Expand Down Expand Up @@ -412,7 +412,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<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.
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:%20base_location%0Aversion:%2012.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:%20base_location%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>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -454,7 +454,7 @@ <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/12.0/base_location">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/base_location">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>
</div>
</div>
Expand Down
21 changes: 7 additions & 14 deletions base_location/tests/test_base_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class TestBaseLocation(common.SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
country_obj = cls.env['res.country.state']
state_obj = cls.env['res.country.state']
city_obj = cls.env['res.city']
zip_obj = cls.env['res.city.zip']
cls.partner_obj = cls.env['res.partner']
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.state_vd = country_obj.create({
cls.state_vd = state_obj.create({
'name': 'Vaud',
'code': 'VD',
'country_id': cls.env.ref('base.ch').id,
Expand All @@ -28,12 +28,12 @@ def setUpClass(cls):
})
cls.company = cls.env.ref('base.main_company')

cls.state_bcn = country_obj.create({
cls.state_bcn = state_obj.create({
'name': 'Barcelona',
'code': '08',
'country_id': cls.env.ref('base.es').id,
})
cls.state_madrid = country_obj.create({
cls.state_madrid = state_obj.create({
'name': 'Madrid',
'code': '28',
'country_id': cls.env.ref('base.es').id,
Expand Down Expand Up @@ -67,7 +67,6 @@ def test_onchange_partner_city_completion(self):
partner1 = self.partner_obj.new({
'name': 'Camptocamp',
})
self.barcelona.city_id.country_id.enforce_cities = True
partner1.zip_id = self.barcelona
partner1._onchange_zip_id()
self.assertEqual(partner1.zip, self.barcelona.name)
Expand Down Expand Up @@ -107,14 +106,10 @@ def test_company_address_fields(self):

def test_company_address_fields_inverse(self):
"""Test inverse fields from res.company"""
company = self.env['res.company'].new({
company = self.env['res.company'].create({
'name': 'Test',
'partner_id': self.partner_obj.new({}).id
# Partner must be initiated in order to be filled
})
company.update({
'zip_id': self.barcelona.id,
})
company.zip_id = self.barcelona.id
company._inverse_city_id()
company._inverse_zip_id()
self.assertEqual(company.zip_id, company.partner_id.zip_id)
Expand Down Expand Up @@ -179,13 +174,11 @@ def test_constrains_partner_city(self):

def test_partner_onchange_country(self):
"""Test partner onchange country_id"""
country_es = self.env.ref('base.es')
country_es.enforce_cities = True
partner = self.partner_obj.new({
'name': 'TEST',
'zip_id': self.lausanne.id
})
partner.country_id = country_es
partner.country_id = self.env.ref('base.es')
partner._onchange_country_id()
self.assertFalse(partner.zip_id)

Expand Down
1 change: 0 additions & 1 deletion base_location/views/res_city_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<field name="name">Cities</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.city</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_ids"
eval="[(5,0,0),
Expand Down
1 change: 0 additions & 1 deletion base_location/views/res_city_zip_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<record id="action_zip_tree" model="ir.actions.act_window">
<field name="name">Locations</field>
<field name="res_model">res.city.zip</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field ref="city_zip_tree" name="view_id"/>
<field name="search_view_id" ref="view_city_zip_filter"/>
Expand Down

0 comments on commit 2fdc70e

Please sign in to comment.