Merge lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl into lp:~partner-contact-core-editors/partner-contact-management/7.0

Proposed by David BEAL (ak)
Status: Merged
Merged at revision: 41
Proposed branch: lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl
Merge into: lp:~partner-contact-core-editors/partner-contact-management/7.0
Diff against target: 168 lines (+153/-0)
3 files modified
base_partner_helper/__init__.py (+22/-0)
base_partner_helper/__openerp__.py (+64/-0)
base_partner_helper/partner.py (+67/-0)
To merge this branch: bzr merge lp:~akretion-team/partner-contact-management/7.0-partner-helper-dbl
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Sébastien BEAU - http://www.akretion.com test, review Approve
Review via email: mp+221501@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
3. By David BEAL (ak)

[FIX] change method name to match convention

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, David,

I see this a very light functionality to include it as "partner general tools" or partner helper. You don't even document in what helps on module description, so for me, I don't see suitable to include on the repository, but I'm going to mark my review to Abstain to let others judge.

Regards.

review: Abstain (code review)
4. By David BEAL (ak)

[IMP] add comments on __openerp__.py

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Hi Pedro,

Thank you for your review. You're right, feature is small and module name is a little large.
But it avoid to grow up excessively the number of module in Odoo for small features.

Thanks to the community to review and suggest to add other useful methods

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

As it's a small abstract feature, I think it make sense to create a helper module for all similary one. The aim is just to have one module which is a toolbox with all abstract feature (not user feature) that can be use everythere.
Description is clear now so I approve

review: Approve (test, review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

OK, let's use this module as is as an umbrella for future partner related functionality.

One last thing: please rename to base_partner_helper to match current convention on naming (Odoo is talking even to create a base_partner split from base module).

Regards.

review: Needs Fixing (code review)
5. By David BEAL (ak)

[FIX] change module name to base partner_helper

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Hi Pedro

module is renamed and ready for merge

Thank you

Regards

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Great, thanks.

Regards.

review: Approve (code review)
Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Hi Pedro,

It seems this module can be merged in this branch, 2 approves now.

Could you proceed it.

Launchpad is yet the master for this repo. Not for a long time.

Thank you

Regards

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'base_partner_helper'
2=== added file 'base_partner_helper/__init__.py'
3--- base_partner_helper/__init__.py 1970-01-01 00:00:00 +0000
4+++ base_partner_helper/__init__.py 2014-06-19 09:40:29 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Sébastien BEAU <sebastien.beau@akretion.com>
10+# Copyright 2014 Akretion
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+from . import partner # noqa
28
29=== added file 'base_partner_helper/__openerp__.py'
30--- base_partner_helper/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ base_partner_helper/__openerp__.py 2014-06-19 09:40:29 +0000
32@@ -0,0 +1,64 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Author: Sébastien BEAU <sebastien.beau@akretion.com>
37+# Copyright 2014 Akretion
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU Affero General Public License as
41+# published by the Free Software Foundation, either version 3 of the
42+# License, or (at your option) any later version.
43+#
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU Affero General Public License for more details.
48+#
49+# You should have received a copy of the GNU Affero General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+#
52+##############################################################################
53+
54+{
55+ 'name': 'Partner Helper',
56+ 'version': '0.1',
57+ 'author': 'Akretion',
58+ 'maintainer': 'Akretion',
59+ 'category': 'Warehouse',
60+ 'depends': [
61+ 'base',
62+ ],
63+ 'description': """
64+Partner Helper
65+==============
66+The purpose of this module is to gather generic partner methods in the same module.
67+It avoid to grow up excessively the number of module in Odoo for small features.
68+
69+Description
70+-----------
71+Add specific helper methods to deal with partners:
72+
73+* _get_split_address():
74+ This method allows to get a number of street fields according to
75+ your choice. 2 fields by default in Odoo with 128 width chars.
76+ In some countries you have constraints on width of street fields and you
77+ should use 3 or 4 shorter fields.
78+ You also need of this feature to avoid headache with overflow printing task
79+
80+* other_method():
81+
82+Contributors
83+------------
84+* Sébastien BEAU <sebastien.beau@akretion.com>
85+* David BEAL <david.beal@akretion.com>
86+
87+
88+ """,
89+ 'website': 'http://www.akretion.com/',
90+ 'data': [],
91+ 'tests': [],
92+ 'installable': True,
93+ 'auto_install': False,
94+ 'license': 'AGPL-3',
95+ 'application': False,
96+}
97
98=== added file 'base_partner_helper/partner.py'
99--- base_partner_helper/partner.py 1970-01-01 00:00:00 +0000
100+++ base_partner_helper/partner.py 2014-06-19 09:40:29 +0000
101@@ -0,0 +1,67 @@
102+# -*- coding: utf-8 -*-
103+##############################################################################
104+#
105+# Author: Sébastien BEAU <sebastien.beau@akretion.com>
106+# Copyright 2014 Akretion
107+#
108+# This program is free software: you can redistribute it and/or modify
109+# it under the terms of the GNU Affero General Public License as
110+# published by the Free Software Foundation, either version 3 of the
111+# License, or (at your option) any later version.
112+#
113+# This program is distributed in the hope that it will be useful,
114+# but WITHOUT ANY WARRANTY; without even the implied warranty of
115+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+# GNU Affero General Public License for more details.
117+#
118+# You should have received a copy of the GNU Affero General Public License
119+# along with this program. If not, see <http://www.gnu.org/licenses/>.
120+#
121+##############################################################################
122+
123+from openerp.osv import orm
124+
125+
126+def split_char(char, output_number, size):
127+ words = char.split(' ')
128+ result = []
129+ word = words.pop(0)
130+ for index in range(0, output_number):
131+ result.append(word)
132+ word = ''
133+ while len(words) > 0:
134+ word = words.pop(0)
135+ if len(result[index] + ' %s' % word) > size:
136+ break
137+ else:
138+ result[index] += ' %s' % word
139+ word = ''
140+ return result
141+
142+
143+class ResPartner(orm.Model):
144+ _inherit = "res.partner"
145+
146+ def _get_split_address(
147+ self, cr, uid, partner, output_number, max_size, context=None):
148+ """ This method allows to get a number of street fields according to
149+ your choice. Default is 2 large fields in Odoo (128 chars).
150+ In some countries you may use 3 or 4 shorter street fields.
151+
152+ example:
153+ res = self.pool['res.partner']._get_split_address(
154+ cr, uid, picking.partner_id, 3, 35, context=context)
155+ address['street'], address['street2'], address['street3'] = res
156+ """
157+ street = partner.street or ''
158+ street2 = partner.street2 or ''
159+ if len(street) <= max_size and len(street2) <= max_size:
160+ result = ['' for i in range(0, output_number)]
161+ result[0] = street
162+ result[1] = street2
163+ return result
164+ elif street <= max_size:
165+ return [street] + split_char(street2, output_number - 1, max_size)
166+ else:
167+ return split_char('%s %s' % (street, street2), output_number, max_size)
168+

Subscribers

People subscribed via source and target branches

to status/vote changes: