Browse Source

[MIG] partner_helper: Migration to 10.0 (#386)

* Migrate to V10
* Tests
* Remove method args not necessary with new api
14.0
MonsieurB 8 years ago
committed by Florian da Costa
parent
commit
82f7cb1a92
  1. 63
      partner_helper/README.rst
  2. 21
      partner_helper/__init__.py
  3. 52
      partner_helper/__manifest__.py
  4. 37
      partner_helper/partner.py
  5. 5
      partner_helper/tests/__init__.py
  6. 22
      partner_helper/tests/test_split_address.py

63
partner_helper/README.rst

@ -0,0 +1,63 @@
.. 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.

21
partner_helper/__init__.py

@ -1,22 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# Copyright 2014 Akretion
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner # noqa
from . import partner

52
partner_helper/__manifest__.py

@ -1,64 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# Copyright 2014 Akretion
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Partner Helper',
'version': '8.0.0.1.0',
'version': '10.0.0.1.0',
'author': "Akretion,Odoo Community Association (OCA)",
'maintainer': 'Akretion',
'category': 'Warehouse',
'depends': [
'base',
],
'description': """
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():
Contributors
------------
* Sébastien BEAU <sebastien.beau@akretion.com>
* David BEAL <david.beal@akretion.com>
""",
'summary': "Add specific helper methods",
'website': 'http://www.akretion.com/',
'data': [],
'tests': [],
'installable': False,
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': False,

37
partner_helper/partner.py

@ -1,25 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
# Copyright 2014 Akretion
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.osv import orm
from odoo import models
def split_char(char, output_number, size):
@ -39,22 +23,21 @@ def split_char(char, output_number, size):
return result
class ResPartner(orm.Model):
class ResPartner(models.Model):
_inherit = "res.partner"
def _get_split_address(
self, cr, uid, partner, output_number, max_size, context=None):
def _get_split_address(self, output_number, max_size):
""" This method allows to get a number of street fields according to
your choice. Default is 2 large fields in Odoo (128 chars).
In some countries you may use 3 or 4 shorter street fields.
example:
res = self.pool['res.partner']._get_split_address(
cr, uid, picking.partner_id, 3, 35, context=context)
address['street'], address['street2'], address['street3'] = res
res = self.env['res.partner']._get_split_address( 3, 35)
street1, street2, street3 = res
"""
street = partner.street or ''
street2 = partner.street2 or ''
self.ensure_one()
street = self.street or ''
street2 = self.street2 or ''
if len(street) <= max_size and len(street2) <= max_size:
result = ['' for i in range(0, output_number)]
result[0] = street

5
partner_helper/tests/__init__.py

@ -0,0 +1,5 @@
# -*- 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

22
partner_helper/tests/test_split_address.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase
import logging
_logger = logging.getLogger(__name__)
class TestSplit(TransactionCase):
def setUp(self):
super(TestSplit, self).setUp()
self.partnerX = self.env.ref('base.res_partner_12')
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)
self.assertEqual('278 route pitoresque de la vallee de', address1)
self.assertEqual(u"l'ours qui fuit les chasseurs ", address2)
self.assertTrue(len(address1) <= 40)
self.assertTrue(len(address2) <= 40)
Loading…
Cancel
Save