Browse Source

Merge pull request #187 from yvaucher/9.0-port-base_location

[9.0][PORT] port base location
pull/204/head
Pedro M. Baeza 9 years ago
parent
commit
6703d3337b
  1. 7
      README.md
  2. 27
      base_location/README.rst
  3. 8
      base_location/__openerp__.py
  4. 4
      base_location/tests/__init__.py
  5. 50
      base_location/tests/test_completion.py
  6. 2
      base_location/views/better_zip_view.xml
  7. 13
      base_location/views/partner_view.xml

7
README.md

@ -15,6 +15,12 @@ Here you should find community modules that:
* Etc.
[//]: # (addons)
Available addons
----------------
addon | version | summary
--- | --- | ---
[base_location](base_location/) | 9.0.1.0.0 | Enhanced zip/npa management system
Unported addons
---------------
addon | version | summary
@ -22,7 +28,6 @@ addon | version | summary
[account_partner_merge](account_partner_merge/) | 1.0 (unported) | Account Partner Merge
[base_contact](base_contact/) | 8.0.2.0.0 (unported) | [DEPRECATED] Manage your contacts separately
[base_continent](base_continent/) | 8.0.1.0.0 (unported) | Continent management
[base_location](base_location/) | 8.0.1.0.0 (unported) | Enhanced zip/npa management system
[base_location_geonames_import](base_location_geonames_import/) | 8.0.0.2.0 (unported) | Import better zip entries from Geonames
[base_location_nuts](base_location_nuts/) | 8.0.1.0.0 (unported) | NUTS Regions
[base_partner_merge](base_partner_merge/) | 8.0.0.1.0 (unported) | Base Partner Merge

27
base_location/README.rst

@ -1,3 +1,8 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=======================
Enhanced ZIP management
=======================
@ -7,6 +12,23 @@ It enables zip, city, state and country auto-completion on partners and companie
Also allows different search filters.
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/134/9.0
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 `here <https://github.com/OCA/
partner_contact/issues/new?body=module:%20
base_location%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
@ -14,11 +36,12 @@ Credits
Contributors
------------
* Nicolas Bessi. (Copyright Camptocamp SA)
* Nicolas Bessi (Camptocamp)
* Ignacio Ibeas (Acysos S.L.)
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Alejandro Santana <alejandrosantana@anubia.es>
- Sandy Carter <sandy.carter@savoirfairelinux.com>
* Sandy Carter <sandy.carter@savoirfairelinux.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
Icon
----

8
base_location/__openerp__.py

@ -22,7 +22,7 @@
##############################################################################
{
'name': 'Location management (aka Better ZIP)',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'depends': ['base'],
'author': "Camptocamp,"
"ACYSOS S.L.,"
@ -31,10 +31,12 @@
"Odoo Community Association (OCA)",
'license': "AGPL-3",
'contributors': [
'Nicolas Bessi <nicolas.bessi@camptocamp.com>',
'Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>',
'Ignacio Ibeas (Acysos S.L.)',
'Alejandro Santana <alejandrosantana@anubia.es>',
'Sandy Carter <sandy.carter@savoirfairelinux.com>',
'Yannick Vaucher <yannick.vaucher@camptocamp.com>',
],
'summary': '''Enhanced zip/npa management system''',
'website': 'http://www.camptocamp.com',
@ -47,6 +49,6 @@
'demo': [
'demo/better_zip.xml',
],
'installable': False,
'active': False,
'installable': True,
'auto_install': False,
}

4
base_location/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2015 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_completion

50
base_location/tests/test_completion.py

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# © 2015 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""Test a city completion and onchanges."""
from openerp.tests.common import TransactionCase
class TestCompletion(TransactionCase):
def test_onchange_better_zip_state_id(self):
""" Test onchange on res.better.zip """
usa_MA = self.env.ref('base.state_us_34')
self.better_zip1.state_id = usa_MA
self.better_zip1.onchange_state_id()
self.assertEqual(self.better_zip1.country_id, usa_MA.country_id)
def test_onchange_partner_city_completion(self):
self.partner1.zip_id = self.better_zip1
self.partner1.onchange_zip_id()
self.assertEqual(self.partner1.zip, self.better_zip1.name)
self.assertEqual(self.partner1.city, self.better_zip1.city)
self.assertEqual(self.partner1.state_id, self.better_zip1.state_id)
self.assertEqual(self.partner1.country_id, self.better_zip1.country_id)
def test_onchange_company_city_completion(self):
self.company.better_zip_id = self.better_zip1
self.company.on_change_city()
self.assertEqual(self.company.zip, self.better_zip1.name)
self.assertEqual(self.company.city, self.better_zip1.city)
self.assertEqual(self.company.state_id, self.better_zip1.state_id)
self.assertEqual(self.company.country_id, self.better_zip1.country_id)
def setUp(self):
super(TestCompletion, self).setUp()
state_vd = self.env['res.country.state'].create({
'name': 'Vaud',
'code': 'VD',
'country_id': self.ref('base.ch'),
})
self.company = self.env.ref('base.main_company')
self.better_zip1 = self.env['res.better.zip'].create({
'name': 1000,
'city': 'Lausanne',
'state_id': state_vd.id,
'country_id': self.ref('base.ch'),
})
self.partner1 = self.env['res.partner'].create({
'name': 'Camptocamp',
})

2
base_location/views/better_zip_view.xml

@ -6,7 +6,7 @@
<field name="name">res.better.zip.form</field>
<field name="model">res.better.zip</field>
<field name="arch" type="xml">
<form string="ZIP" version="7.0">
<form string="ZIP">
<group col="4">
<field name="name"/>
<field name="code"/>

13
base_location/views/partner_view.xml

@ -7,17 +7,16 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<div class="address_format" position="before">
<field name="city" position="before">
<field name="zip_id"
options="{'create_name_field': 'city'}"
options="{'create_name_field': 'city', 'no_open': True, 'no_create': True}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</div>
<xpath expr="//field[@name='child_ids']/form//div[@class='address_format']" position="before">
<field name="zip_id" options="{'create_name_field': 'city'}"
</field>
<xpath expr="//field[@name='child_ids']/form//field[@name='city']" position="before">
<field name="zip_id"
options="{'create_name_field': 'city', 'no_open': True, 'no_create': True}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</xpath>
</field>

Loading…
Cancel
Save