Browse Source
Merge pull request #126 from gurneyalex/7.0-street3
Merge pull request #126 from gurneyalex/7.0-street3
[7.0] Add module 'partner_address_street_3'pull/211/head
Pedro M. Baeza
9 years ago
8 changed files with 344 additions and 0 deletions
-
57partner_address_street3/README.rst
-
21partner_address_street3/__init__.py
-
38partner_address_street3/__openerp__.py
-
21partner_address_street3/model/__init__.py
-
57partner_address_street3/model/partner.py
-
21partner_address_street3/tests/__init__.py
-
88partner_address_street3/tests/test_street_3.py
-
41partner_address_street3/view/partner_view.xml
@ -0,0 +1,57 @@ |
|||||
|
.. 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 |
||||
|
|
||||
|
=========================== |
||||
|
3rd line on partner address |
||||
|
=========================== |
||||
|
|
||||
|
This module extends the base res.partner model by supplying a 3rd line on |
||||
|
addresses (`street3`) |
||||
|
|
||||
|
|
||||
|
.. 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/7.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 |
||||
|
<https://github.com/OCA/ |
||||
|
partner-contact/issues/new?body=module:%20 |
||||
|
partner_address_street3%0Aversion:%20 |
||||
|
7.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Images |
||||
|
------ |
||||
|
|
||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Nicolas Bessi <nicolas.bessi@camptocamp.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
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 https://odoo-community.org. |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import model |
@ -0,0 +1,38 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{ |
||||
|
'name': 'Street3 in addresses', |
||||
|
'version': '7.0.0.1.0', |
||||
|
'author': 'Camptocamp, Odoo Community Association (OCA)', |
||||
|
'maintainer': 'Camptocamp', |
||||
|
'category': 'Sales', |
||||
|
'complexity': 'easy', |
||||
|
'depends': ['base'], |
||||
|
'description': """Add a third field to the address""", |
||||
|
'website': 'http://www.camptocamp.com', |
||||
|
'data': ['view/partner_view.xml'], |
||||
|
'demo': [], |
||||
|
'test': [], |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'license': 'AGPL-3', |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import partner |
@ -0,0 +1,57 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from openerp.osv import orm, fields |
||||
|
from openerp.addons.base.res import res_partner |
||||
|
|
||||
|
|
||||
|
class res_partner(orm.Model): |
||||
|
"""Add third field in address""" |
||||
|
|
||||
|
_inherit = "res.partner" |
||||
|
_columns = { |
||||
|
'street3': fields.char('Street 3'), |
||||
|
} |
||||
|
|
||||
|
def _address_fields(self, cr, uid, context=None): |
||||
|
""" Returns the list of address fields that are synced from the parent |
||||
|
when the `use_parent_address` flag is set. """ |
||||
|
res = super(res_partner, self |
||||
|
)._address_fields(cr, uid, context=context) |
||||
|
res.append('street3') |
||||
|
return res |
||||
|
|
||||
|
def _commercial_fields(self, cr, uid, context=None): |
||||
|
fields = super(res_partner, self |
||||
|
)._commercial_fields(cr, uid, context=context) |
||||
|
fields.append('street3') |
||||
|
return fields |
||||
|
|
||||
|
|
||||
|
class res_country(orm.Model): |
||||
|
"""Override default adresses formatting of coutries""" |
||||
|
|
||||
|
_inherit = 'res.country' |
||||
|
|
||||
|
_defaults = { |
||||
|
'address_format': ("%(street)s\n%(street2)s\n%(street3)s\n" |
||||
|
"%(city)s %(state_code)s %(zip)s\n" |
||||
|
"%(country_name)s"), |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import test_street_3 |
@ -0,0 +1,88 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Author: Nicolas Bessi |
||||
|
# Copyright 2014 Camptocamp SA |
||||
|
# |
||||
|
# 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
import openerp.tests.common as test_common |
||||
|
|
||||
|
|
||||
|
class TestStreet3(test_common.TransactionCase): |
||||
|
|
||||
|
def test_partner(self): |
||||
|
part_model = self.registry('res.partner') |
||||
|
country_model = self.registry('res.country') |
||||
|
country_id = country_model.create( |
||||
|
self.cr, |
||||
|
self.uid, |
||||
|
{ |
||||
|
'name': 'Donut Land', |
||||
|
'code': 'DNL', |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
self.assertTrue(country_id) |
||||
|
|
||||
|
create_data = { |
||||
|
'name': 'Homer Simpson', |
||||
|
'city': 'Springfield', |
||||
|
'street': '742 Evergreen Terrace', |
||||
|
'street2': 'Donut Lane', |
||||
|
'street3': 'Tho', |
||||
|
'country_id': country_id, |
||||
|
'is_company': True |
||||
|
} |
||||
|
|
||||
|
homer_id = part_model.create( |
||||
|
self.cr, |
||||
|
self.uid, |
||||
|
create_data |
||||
|
) |
||||
|
|
||||
|
homer = part_model.browse( |
||||
|
self.cr, |
||||
|
self.uid, |
||||
|
homer_id, |
||||
|
) |
||||
|
|
||||
|
self.assertEqual( |
||||
|
homer.country_id.address_format, |
||||
|
("%(street)s\n%(street2)s\n%(street3)s\n" |
||||
|
"%(city)s %(state_code)s %(zip)s\n" |
||||
|
"%(country_name)s") |
||||
|
) |
||||
|
|
||||
|
create_data = { |
||||
|
'name': 'Bart Simpson', |
||||
|
'is_company': False, |
||||
|
'parent_id': homer.id, |
||||
|
'use_parent_address': True |
||||
|
} |
||||
|
|
||||
|
bart_id = part_model.create( |
||||
|
self.cr, |
||||
|
self.uid, |
||||
|
create_data |
||||
|
) |
||||
|
|
||||
|
bart = part_model.browse( |
||||
|
self.cr, |
||||
|
self.uid, |
||||
|
bart_id, |
||||
|
) |
||||
|
|
||||
|
self.assertTrue(bart.street3, 'Tho') |
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="add_stree3_in_form_view" model="ir.ui.view"> |
||||
|
<field name="name">add stree3 in form view</field> |
||||
|
<field name="model">res.partner</field> |
||||
|
<field name="inherit_id" ref="base.view_partner_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath |
||||
|
expr="//form[@string='Partners']/sheet/group/group/div/field[@name='street2']" |
||||
|
position="after"> |
||||
|
<field name="street3" |
||||
|
attrs="{'readonly': [('use_parent_address','=',True)]}"/> |
||||
|
</xpath> |
||||
|
|
||||
|
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street2']" |
||||
|
position="after"> |
||||
|
<field name="street3"/> |
||||
|
</xpath> |
||||
|
|
||||
|
<xpath expr="//kanban/field[@name='street2']" |
||||
|
position="after"> |
||||
|
<field name="street3"/> |
||||
|
</xpath> |
||||
|
|
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="add_street_3_in_kanban" model="ir.ui.view"> |
||||
|
<field name="name">add street 3 in kanban</field> |
||||
|
<field name="model">res.partner</field> |
||||
|
<field name="inherit_id" ref="base.res_partner_kanban_view"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<field name="street2" position="after"> |
||||
|
<field name="street3"/> |
||||
|
</field> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue