Browse Source

MIGR partner_helper: to v12

pull/746/head
David Beal 6 years ago
parent
commit
03a01b7b5f
  1. 64
      partner_helper/README.rst
  2. 6
      partner_helper/__init__.py
  3. 6
      partner_helper/__manifest__.py
  4. 1
      partner_helper/models/__init__.py
  5. 9
      partner_helper/models/partner.py
  6. 3
      partner_helper/readme/CONTRIBUTORS.rst
  7. 11
      partner_helper/readme/DESCRIPTION.rst
  8. 4
      partner_helper/tests/__init__.py
  9. 24
      partner_helper/tests/test_split_address.py

64
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
<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 smash it by providing detailed and welcomed feedback.
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Sébastien BEAU <sebastien.beau@akretion.com>
* David BEAL <david.beal@akretion.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.
Update automatically by oca engine

6
partner_helper/__init__.py

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner
from . import models

6
partner_helper/__manifest__.py

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# 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,
}

1
partner_helper/models/__init__.py

@ -0,0 +1 @@
from . import partner

9
partner_helper/partner.py → partner_helper/models/partner.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# 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(

3
partner_helper/readme/CONTRIBUTORS.rst

@ -0,0 +1,3 @@
* Akretion:
* Sébastien Beau <sebastien.beau@akretion.com>

11
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

4
partner_helper/tests/__init__.py

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_split_address

24
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)
Loading…
Cancel
Save