Browse Source

MIG 10.0 partner_helper

pull/402/head
Angel Moya Pardo 8 years ago
parent
commit
a34592a642
  1. 74
      partner_helper/README.rst
  2. 23
      partner_helper/__init__.py
  3. 23
      partner_helper/__manifest__.py
  4. 7
      partner_helper/models/__init__.py
  5. 35
      partner_helper/models/partner.py

74
partner_helper/README.rst

@ -0,0 +1,74 @@
.. 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
Usage
=====
.. 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/10.0
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 smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
partner_contact/issues/new?body=module:%20
base_location%0Aversion:%20
10.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Credits
=======
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>
* Angel Moya <angel.moya@pesol.es>
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.

23
partner_helper/__init__.py

@ -1,22 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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/>.
#
##############################################################################
# © 2017 Angel Moya <angel.moya@pesol.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner # noqa
from . import models

23
partner_helper/__manifest__.py

@ -1,24 +1,7 @@
# -*- coding: utf-8 -*- # -*- 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/>.
#
##############################################################################
# © 2014 Sébastien BEAU <sebastien.beau@akretion.com>
# © 2017 Angel Moya <angel.moya@pesol.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Partner Helper', 'name': 'Partner Helper',
'version': '8.0.0.1.0', 'version': '8.0.0.1.0',

7
partner_helper/models/__init__.py

@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014 Sébastien BEAU <sebastien.beau@akretion.com>
# © 2017 Angel Moya <angel.moya@pesol.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner

35
partner_helper/partner.py → partner_helper/models/partner.py

@ -1,25 +1,9 @@
# -*- coding: utf-8 -*- # -*- 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/>.
#
##############################################################################
# © 2014 Sébastien BEAU <sebastien.beau@akretion.com>
# © 2017 Angel Moya <angel.moya@pesol.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.osv import orm
from openerp import models, api
def split_char(char, output_number, size): def split_char(char, output_number, size):
@ -39,11 +23,11 @@ def split_char(char, output_number, size):
return result return result
class ResPartner(orm.Model):
class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
def _get_split_address(
self, cr, uid, partner, output_number, max_size, context=None):
@api.multi
def _get_split_address(self, output_number, max_size):
""" This method allows to get a number of street fields according to """ This method allows to get a number of street fields according to
your choice. Default is 2 large fields in Odoo (128 chars). your choice. Default is 2 large fields in Odoo (128 chars).
In some countries you may use 3 or 4 shorter street fields. In some countries you may use 3 or 4 shorter street fields.
@ -53,8 +37,9 @@ class ResPartner(orm.Model):
cr, uid, picking.partner_id, 3, 35, context=context) cr, uid, picking.partner_id, 3, 35, context=context)
address['street'], address['street2'], address['street3'] = res address['street'], address['street2'], address['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: if len(street) <= max_size and len(street2) <= max_size:
result = ['' for i in range(0, output_number)] result = ['' for i in range(0, output_number)]
result[0] = street result[0] = street
Loading…
Cancel
Save