diff --git a/partner_helper/README.rst b/partner_helper/README.rst index 28e81cd8d..facbb772b 100644 --- a/partner_helper/README.rst +++ b/partner_helper/README.rst @@ -1,63 +1 @@ -.. 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 Helper -============== - -The purpose of this module is to gather generic partner methods. -It avoids to grow up excessively the number of modules in Odoo -for small features. - -Description ------------ -Add specific helper methods to deal with partners: - -* _get_split_address(): - This method allows to get a number of street fields according to - your choice. 2 fields by default in Odoo with 128 width chars. - In some countries you have constraints on width of street fields and you - should use 3 or 4 shorter fields. - You also need of this feature to avoid headache with overflow printing task - -* other_method(): - - - -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 smash it by providing detailed and welcomed feedback. - - -Images ------- - -* Odoo Community Association: `Icon `_. - - -Contributors ------------- - - * Sébastien BEAU - * David BEAL - - -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. +Update automatically by oca engine diff --git a/partner_helper/__init__.py b/partner_helper/__init__.py index e965bbdc1..0650744f6 100644 --- a/partner_helper/__init__.py +++ b/partner_helper/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# Author: Sébastien BEAU -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from . import partner +from . import models diff --git a/partner_helper/__manifest__.py b/partner_helper/__manifest__.py index 948459aed..04b7a9493 100644 --- a/partner_helper/__manifest__.py +++ b/partner_helper/__manifest__.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # Author: Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Partner Helper', - 'version': '10.0.0.1.0', + 'version': '12.0.0.1.0', 'author': "Akretion,Odoo Community Association (OCA)", 'maintainer': 'Akretion', 'category': 'Warehouse', @@ -12,10 +11,7 @@ ], 'summary': "Add specific helper methods", 'website': 'http://www.akretion.com/', - 'data': [], - 'tests': [], 'installable': True, 'auto_install': False, 'license': 'AGPL-3', - 'application': False, } diff --git a/partner_helper/models/__init__.py b/partner_helper/models/__init__.py new file mode 100644 index 000000000..4da81fa31 --- /dev/null +++ b/partner_helper/models/__init__.py @@ -0,0 +1 @@ +from . import partner diff --git a/partner_helper/partner.py b/partner_helper/models/partner.py similarity index 85% rename from partner_helper/partner.py rename to partner_helper/models/partner.py index 8dd3d0168..5266472d5 100644 --- a/partner_helper/partner.py +++ b/partner_helper/models/partner.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016 Akretion (http://www.akretion.com) -# Author: Sébastien BEAU +# Copyright (C) 2016 Akretion (http://www.akretion.com) +# Author: Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models @@ -32,7 +31,7 @@ class ResPartner(models.Model): In some countries you may use 3 or 4 shorter street fields. example: - res = self.env['res.partner']._get_split_address( 3, 35) + res = self.partner_id._get_split_address(3, 35) street1, street2, street3 = res """ self.ensure_one() @@ -43,7 +42,7 @@ class ResPartner(models.Model): result[0] = street result[1] = street2 return result - elif street <= max_size: + elif len(street) <= max_size: return [street] + split_char(street2, output_number - 1, max_size) else: return split_char( diff --git a/partner_helper/readme/CONTRIBUTORS.rst b/partner_helper/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..2070ebe78 --- /dev/null +++ b/partner_helper/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Akretion: + + * Sébastien Beau diff --git a/partner_helper/readme/DESCRIPTION.rst b/partner_helper/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6a0218d62 --- /dev/null +++ b/partner_helper/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +The purpose of this module is to gather generic partner methods. +It avoids to grow up excessively the number of modules in Odoo +for small features. + +Add methods to Partner model like `_get_split_address()` + + This method allows to get a number of street fields according to + your choice. 2 fields by default in Odoo with 128 width chars. + In some countries you have constraints on width of street fields and you + should use 3 or 4 shorter fields. + You also need of this feature to avoid headache with overflow printing task diff --git a/partner_helper/tests/__init__.py b/partner_helper/tests/__init__.py index d3e589cdc..aa41cb543 100644 --- a/partner_helper/tests/__init__.py +++ b/partner_helper/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# Author: Sébastien BEAU -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import test_split_address diff --git a/partner_helper/tests/test_split_address.py b/partner_helper/tests/test_split_address.py index 19da047fc..acaee0c06 100644 --- a/partner_helper/tests/test_split_address.py +++ b/partner_helper/tests/test_split_address.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase import logging _logger = logging.getLogger(__name__) @@ -9,14 +8,21 @@ class TestSplit(TransactionCase): def setUp(self): super(TestSplit, self).setUp() self.partnerX = self.env.ref('base.res_partner_12') + self.partnerX.street = "278 route pitoresque de la vallee de" \ + " l'ours qui fuit les chasseurs" - def test_init1(self): - address = u"278 route pitoresque de la vallee de" \ - u" l'ours qui fuit les chasseurs" - partner = self.partnerX - partner.street = address - address1, address2 = partner._get_split_address(2, 40) + def test_split1(self): + address1, address2 = self.partnerX._get_split_address(2, 40) self.assertEqual('278 route pitoresque de la vallee de', address1) - self.assertEqual(u"l'ours qui fuit les chasseurs ", address2) + self.assertEqual("l'ours qui fuit les chasseurs ", address2) self.assertTrue(len(address1) <= 40) self.assertTrue(len(address2) <= 40) + + def test_split2(self): + address1, address2, address3 = self.partnerX._get_split_address(3, 25) + self.assertEqual('278 route pitoresque de', address1) + self.assertEqual("la vallee de l'ours qui", address2) + self.assertEqual("fuit les chasseurs ", address3) + self.assertTrue(len(address1) <= 25) + self.assertTrue(len(address2) <= 25) + self.assertTrue(len(address3) <= 25)