openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #07021
[Merge] lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl into lp:partner-contact-management
David BEAL has proposed merging lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl into lp:partner-contact-management.
Requested reviews:
Partner and Contact Core Editors (partner-contact-core-editors)
For more details, see:
https://code.launchpad.net/~akretion-team/partner-contact-management/7.0-partner-helper-dbl/+merge/221501
Add specific methods to deal with address
On this commit get_split_address()
to deal with 2 streets fields in Odoo/openerp and X streets fields for data exchange : carrier, logistic, etc.
--
https://code.launchpad.net/~akretion-team/partner-contact-management/7.0-partner-helper-dbl/+merge/221501
Your team Partner and Contact Core Editors is requested to review the proposed merge of lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl into lp:partner-contact-management.
=== added directory 'partner_helper'
=== added file 'partner_helper/__init__.py'
--- partner_helper/__init__.py 1970-01-01 00:00:00 +0000
+++ partner_helper/__init__.py 2014-05-30 09:03:28 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# 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/>.
+#
+##############################################################################
+
+from . import partner # noqa
=== added file 'partner_helper/__openerp__.py'
--- partner_helper/__openerp__.py 1970-01-01 00:00:00 +0000
+++ partner_helper/__openerp__.py 2014-05-30 09:03:28 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# 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/>.
+#
+##############################################################################
+
+{
+ 'name': 'Partner Helper',
+ 'version': '0.1',
+ 'author': 'Akretion',
+ 'maintainer': 'Akretion',
+ 'category': 'Warehouse',
+ 'depends': [
+ 'base',
+ ],
+ 'description': """
+Partner Helper
+==============
+
+Description
+-----------
+* Add specific methods to deal with address
+
+
+Contributors
+------------
+* Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+* David BEAL <david.beal@xxxxxxxxxxxx>
+
+
+ """,
+ 'website': 'http://www.akretion.com/',
+ 'data': [],
+ 'tests': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': False,
+}
=== added file 'partner_helper/partner.py'
--- partner_helper/partner.py 1970-01-01 00:00:00 +0000
+++ partner_helper/partner.py 2014-05-30 09:03:28 +0000
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# 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/>.
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+def split_char(char, output_number, size):
+ words = char.split(' ')
+ result = []
+ word = words.pop(0)
+ for index in range(0, output_number):
+ result.append(word)
+ word = ''
+ while len(words) > 0:
+ word = words.pop(0)
+ if len(result[index] + ' %s' % word) > size:
+ break
+ else:
+ result[index] += ' %s' % word
+ word = ''
+ return result
+
+
+class res_partner(orm.Model):
+ _inherit = "res.partner"
+
+ def get_split_address(
+ self, cr, uid, address, output_number, max_size, context=None):
+ street = address.street or ''
+ street2 = address.street2 or ''
+ if len(street) <= max_size and len(street2) <= max_size:
+ result = ['' for i in range(0, output_number)]
+ result[0] = street
+ result[1] = street2
+ return result
+ elif street <= max_size:
+ return [street] + split_char(street2, output_number - 1, max_size)
+ else:
+ return split_char('%s %s' % (street, street2), output_number, max_size)
+
Follow ups