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..e19dc901e --- /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': '8.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, +} 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..a4d0f2098 --- /dev/null +++ b/partner_address_street3/model/partner.py @@ -0,0 +1,48 @@ +# -*- 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 + + +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): + fields = super(res_partner, self + )._address_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/static/description/icon.png b/partner_address_street3/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_address_street3/static/description/icon.png differ 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 + + + + + + + + + +