From 64200cd3dc13020c02f88934b1705c396820859f Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 5 Dec 2014 18:31:04 +0100 Subject: [PATCH 1/6] Add module 'partner_address_street_3'. Backported from 8.0 --- partner_address_street3/__init__.py | 21 +++++ partner_address_street3/__openerp__.py | 38 ++++++++ partner_address_street3/model/__init__.py | 21 +++++ partner_address_street3/model/partner.py | 57 ++++++++++++ partner_address_street3/tests/__init__.py | 21 +++++ .../tests/test_street_3.py | 88 +++++++++++++++++++ partner_address_street3/view/partner_view.xml | 41 +++++++++ 7 files changed, 287 insertions(+) create mode 100644 partner_address_street3/__init__.py create mode 100644 partner_address_street3/__openerp__.py create mode 100644 partner_address_street3/model/__init__.py create mode 100644 partner_address_street3/model/partner.py create mode 100644 partner_address_street3/tests/__init__.py create mode 100644 partner_address_street3/tests/test_street_3.py create mode 100644 partner_address_street3/view/partner_view.xml diff --git a/partner_address_street3/__init__.py b/partner_address_street3/__init__.py new file mode 100644 index 000000000..6ac610f01 --- /dev/null +++ b/partner_address_street3/__init__.py @@ -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 . +# +############################################################################## +from . import model diff --git a/partner_address_street3/__openerp__.py b/partner_address_street3/__openerp__.py new file mode 100644 index 000000000..bcf37ddc1 --- /dev/null +++ b/partner_address_street3/__openerp__.py @@ -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 . +# +############################################################################## +{ + 'name': 'Street3 in addresses', + 'version': '0.1', + 'author': 'Camptocamp', + '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, +} diff --git a/partner_address_street3/model/__init__.py b/partner_address_street3/model/__init__.py new file mode 100644 index 000000000..b4349f625 --- /dev/null +++ b/partner_address_street3/model/__init__.py @@ -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 . +# +############################################################################## +from . import partner diff --git a/partner_address_street3/model/partner.py b/partner_address_street3/model/partner.py new file mode 100644 index 000000000..6b7fb1676 --- /dev/null +++ b/partner_address_street3/model/partner.py @@ -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 . +# +############################################################################## +from openerp.osv import orm, fields +from openerp.addons.base.res import res_partner + +ADDRESS_FIELDS = ('street', 'street2', 'street3', 'zip', 'city', 'state_id', 'country_id') + +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. """ + return list(ADDRESS_FIELDS) + + 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"), + } + + diff --git a/partner_address_street3/tests/__init__.py b/partner_address_street3/tests/__init__.py new file mode 100644 index 000000000..3e6e82972 --- /dev/null +++ b/partner_address_street3/tests/__init__.py @@ -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 . +# +############################################################################## +from . import test_street_3 diff --git a/partner_address_street3/tests/test_street_3.py b/partner_address_street3/tests/test_street_3.py new file mode 100644 index 000000000..ee329bd55 --- /dev/null +++ b/partner_address_street3/tests/test_street_3.py @@ -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 . +# +############################################################################## +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') diff --git a/partner_address_street3/view/partner_view.xml b/partner_address_street3/view/partner_view.xml new file mode 100644 index 000000000..d4bc15020 --- /dev/null +++ b/partner_address_street3/view/partner_view.xml @@ -0,0 +1,41 @@ + + + + + add stree3 in form view + res.partner + + + + + + + + + + + + + + + + + + + add street 3 in kanban + res.partner + + + + + + + + + + From 74c967adb6e172dede8b9af5b3cab9b88f576e5e Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 5 Dec 2014 18:32:37 +0100 Subject: [PATCH 2/6] PEP8 corrections --- partner_address_street3/model/partner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/partner_address_street3/model/partner.py b/partner_address_street3/model/partner.py index 6b7fb1676..25667e337 100644 --- a/partner_address_street3/model/partner.py +++ b/partner_address_street3/model/partner.py @@ -21,7 +21,9 @@ from openerp.osv import orm, fields from openerp.addons.base.res import res_partner -ADDRESS_FIELDS = ('street', 'street2', 'street3', 'zip', 'city', 'state_id', 'country_id') +ADDRESS_FIELDS = ('street', 'street2', 'street3', 'zip', 'city', + 'state_id', 'country_id') + class res_partner(orm.Model): """Add third field in address""" From 9ebf7ca395ffb0b413090793e7901fa1545dd1b4 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 5 Dec 2014 19:11:34 +0100 Subject: [PATCH 3/6] Method '_address_fields' should super and then add 'street3'. --- partner_address_street3/model/partner.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/partner_address_street3/model/partner.py b/partner_address_street3/model/partner.py index 25667e337..2a444be02 100644 --- a/partner_address_street3/model/partner.py +++ b/partner_address_street3/model/partner.py @@ -21,9 +21,6 @@ from openerp.osv import orm, fields from openerp.addons.base.res import res_partner -ADDRESS_FIELDS = ('street', 'street2', 'street3', 'zip', 'city', - 'state_id', 'country_id') - class res_partner(orm.Model): """Add third field in address""" @@ -36,7 +33,11 @@ class res_partner(orm.Model): 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. """ - return list(ADDRESS_FIELDS) + 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 From 7c6a711b521ce661114ea7851a46882dfc435cc3 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 15 Dec 2015 10:27:53 +0100 Subject: [PATCH 4/6] fix flake8 warnings --- partner_address_street3/model/partner.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/partner_address_street3/model/partner.py b/partner_address_street3/model/partner.py index 2a444be02..51a95b917 100644 --- a/partner_address_street3/model/partner.py +++ b/partner_address_street3/model/partner.py @@ -38,7 +38,6 @@ class res_partner(orm.Model): res.append('street3') return res - def _commercial_fields(self, cr, uid, context=None): fields = super(res_partner, self )._commercial_fields(cr, uid, context=context) @@ -56,5 +55,3 @@ class res_country(orm.Model): "%(city)s %(state_code)s %(zip)s\n" "%(country_name)s"), } - - From 61acab29490ab688069d5d5b510a6abc1d8e34eb Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 15 Dec 2015 10:33:36 +0100 Subject: [PATCH 5/6] added README.rst --- partner_address_street3/README.rst | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 partner_address_street3/README.rst diff --git a/partner_address_street3/README.rst b/partner_address_street3/README.rst new file mode 100644 index 000000000..d0b765593 --- /dev/null +++ b/partner_address_street3/README.rst @@ -0,0 +1,58 @@ +.. 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 + +======================= +partner address street3 +======================= + +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 +`_. 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 +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Firstname Lastname +* Second Person + +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. From ff1843ac7312ad82aa36e6007a840bd6d337551b Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Wed, 16 Dec 2015 08:14:25 +0100 Subject: [PATCH 6/6] fix openerp.py and README --- partner_address_street3/README.rst | 9 ++++----- partner_address_street3/__openerp__.py | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/partner_address_street3/README.rst b/partner_address_street3/README.rst index d0b765593..31432d804 100644 --- a/partner_address_street3/README.rst +++ b/partner_address_street3/README.rst @@ -2,9 +2,9 @@ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -======================= -partner address street3 -======================= +=========================== +3rd line on partner address +=========================== This module extends the base res.partner model by supplying a 3rd line on addresses (`street3`) @@ -39,8 +39,7 @@ Images Contributors ------------ -* Firstname Lastname -* Second Person +* Nicolas Bessi Maintainer ---------- diff --git a/partner_address_street3/__openerp__.py b/partner_address_street3/__openerp__.py index bcf37ddc1..0d9287bc1 100644 --- a/partner_address_street3/__openerp__.py +++ b/partner_address_street3/__openerp__.py @@ -20,8 +20,8 @@ ############################################################################## { 'name': 'Street3 in addresses', - 'version': '0.1', - 'author': 'Camptocamp', + 'version': '7.0.0.1.0', + 'author': 'Camptocamp, Odoo Community Association (OCA)', 'maintainer': 'Camptocamp', 'category': 'Sales', 'complexity': 'easy',