From a34592a642845ef29240afc65adbee8da315119a Mon Sep 17 00:00:00 2001 From: Angel Moya Pardo Date: Thu, 30 Mar 2017 13:19:40 +0200 Subject: [PATCH] MIG 10.0 partner_helper --- partner_helper/README.rst | 74 ++++++++++++++++++++++++++ partner_helper/__init__.py | 23 ++------ partner_helper/__manifest__.py | 23 ++------ partner_helper/models/__init__.py | 7 +++ partner_helper/{ => models}/partner.py | 35 ++++-------- 5 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 partner_helper/README.rst create mode 100644 partner_helper/models/__init__.py rename partner_helper/{ => models}/partner.py (54%) diff --git a/partner_helper/README.rst b/partner_helper/README.rst new file mode 100644 index 000000000..d5e0e7471 --- /dev/null +++ b/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 `_. + 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 `_. + + Credits + ======= + + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ +* Sébastien BEAU +* David BEAL +* Angel Moya + + +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. diff --git a/partner_helper/__init__.py b/partner_helper/__init__.py index 590716ea0..ca6ad3931 100644 --- a/partner_helper/__init__.py +++ b/partner_helper/__init__.py @@ -1,22 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Author: Sébastien BEAU -# 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 . -# -############################################################################## +# © 2017 Angel Moya +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import partner # noqa +from . import models diff --git a/partner_helper/__manifest__.py b/partner_helper/__manifest__.py index a8410b6e3..29de0c1cd 100644 --- a/partner_helper/__manifest__.py +++ b/partner_helper/__manifest__.py @@ -1,24 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Author: Sébastien BEAU -# 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 . -# -############################################################################## - +# © 2014 Sébastien BEAU +# © 2017 Angel Moya +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Partner Helper', 'version': '8.0.0.1.0', diff --git a/partner_helper/models/__init__.py b/partner_helper/models/__init__.py new file mode 100644 index 000000000..acb756ded --- /dev/null +++ b/partner_helper/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2014 Sébastien BEAU +# © 2017 Angel Moya +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from . import partner diff --git a/partner_helper/partner.py b/partner_helper/models/partner.py similarity index 54% rename from partner_helper/partner.py rename to partner_helper/models/partner.py index 569bf5dc7..0c7593804 100644 --- a/partner_helper/partner.py +++ b/partner_helper/models/partner.py @@ -1,25 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Author: Sébastien BEAU -# 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 . -# -############################################################################## +# © 2014 Sébastien BEAU +# © 2017 Angel Moya +# 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): @@ -39,11 +23,11 @@ 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): + @api.multi + 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. @@ -53,8 +37,9 @@ class ResPartner(orm.Model): cr, uid, picking.partner_id, 3, 35, context=context) 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: result = ['' for i in range(0, output_number)] result[0] = street