Merge lp:~camptocamp/partner-contact-management/7.0-port-base_address_category into lp:~partner-contact-core-editors/partner-contact-management/7.0
- 7.0-port-base_address_category
- Merge into 7.0
Proposed by
Alexandre Fayolle - camptocamp
Status: | Superseded |
---|---|
Proposed branch: | lp:~camptocamp/partner-contact-management/7.0-port-base_address_category |
Merge into: | lp:~partner-contact-core-editors/partner-contact-management/7.0 |
Diff against target: |
435 lines (+90/-244) 4 files modified
base_address_category/__init__.py (+13/-21) base_address_category/__openerp__.py (+32/-32) base_address_category/base_address.py (+44/-40) base_address_category/base_address_view.xml (+1/-151) |
To merge this branch: | bzr merge lp:~camptocamp/partner-contact-management/7.0-port-base_address_category |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Needs Fixing | ||
Review via email: mp+144125@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-01-22.
Commit message
Description of the change
[7.0] port base_address_
This is not a real port as this module is not useful in 7.0: the res.partner.address is not longer there.
I've kept the model definitions and removed the views from the model. The
migration process should convert res.partner.
res.partner.
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
review:
Needs Fixing
- 12. By Alexandre Fayolle - camptocamp
-
[REF] base_address_
category: don't subsitute args in query
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'base_address_category/__init__.py' |
2 | --- base_address_category/__init__.py 2011-08-12 12:53:16 +0000 |
3 | +++ base_address_category/__init__.py 2013-01-22 12:34:36 +0000 |
4 | @@ -1,31 +1,23 @@ |
5 | # -*- coding: utf-8 -*- |
6 | ############################################################################## |
7 | # |
8 | -# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) |
9 | +# Copyright (c) 2010-2013 Camptocamp SA (http://www.camptocamp.com) |
10 | # All Right Reserved |
11 | # |
12 | # Author : Nicolas Bessi (Camptocamp), Joel Grand-Guillaume |
13 | # |
14 | -# WARNING: This program as such is intended to be used by professional |
15 | -# programmers who take the whole responsability of assessing all potential |
16 | -# consequences resulting from its eventual inadequacies and bugs |
17 | -# End users who are looking for a ready-to-use solution with commercial |
18 | -# garantees and support are strongly adviced to contract a Free Software |
19 | -# Service Company |
20 | -# |
21 | -# This program is Free Software; you can redistribute it and/or |
22 | -# modify it under the terms of the GNU General Public License |
23 | -# as published by the Free Software Foundation; either version 2 |
24 | -# of the License, or (at your option) any later version. |
25 | -# |
26 | -# This program is distributed in the hope that it will be useful, |
27 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
28 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
29 | -# GNU General Public License for more details. |
30 | -# |
31 | -# You should have received a copy of the GNU General Public License |
32 | -# along with this program; if not, write to the Free Software |
33 | -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
34 | +# This program is free software: you can redistribute it and/or modify |
35 | +# it under the terms of the GNU Affero General Public License as |
36 | +# published by the Free Software Foundation, either version 3 of the |
37 | +# License, or (at your option) any later version. |
38 | +# |
39 | +# This program is distributed in the hope that it will be useful, |
40 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
41 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
42 | +# GNU Affero General Public License for more details. |
43 | +# |
44 | +# You should have received a copy of the GNU Affero General Public License |
45 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
46 | # |
47 | ############################################################################## |
48 | import base_address |
49 | \ No newline at end of file |
50 | |
51 | === modified file 'base_address_category/__openerp__.py' |
52 | --- base_address_category/__openerp__.py 2013-01-14 11:00:13 +0000 |
53 | +++ base_address_category/__openerp__.py 2013-01-22 12:34:36 +0000 |
54 | @@ -1,38 +1,41 @@ |
55 | # -*- coding: utf-8 -*- |
56 | ############################################################################## |
57 | # |
58 | -# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) |
59 | +# Copyright (c) 2010-2013 Camptocamp SA (http://www.camptocamp.com) |
60 | # All Right Reserved |
61 | # |
62 | # Author : Nicolas Bessi (Camptocamp), Joel Grand-Guillaume |
63 | # |
64 | -# WARNING: This program as such is intended to be used by professional |
65 | -# programmers who take the whole responsability of assessing all potential |
66 | -# consequences resulting from its eventual inadequacies and bugs |
67 | -# End users who are looking for a ready-to-use solution with commercial |
68 | -# garantees and support are strongly adviced to contract a Free Software |
69 | -# Service Company |
70 | -# |
71 | -# This program is Free Software; you can redistribute it and/or |
72 | -# modify it under the terms of the GNU General Public License |
73 | -# as published by the Free Software Foundation; either version 2 |
74 | -# of the License, or (at your option) any later version. |
75 | -# |
76 | -# This program is distributed in the hope that it will be useful, |
77 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
78 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
79 | -# GNU General Public License for more details. |
80 | -# |
81 | -# You should have received a copy of the GNU General Public License |
82 | -# along with this program; if not, write to the Free Software |
83 | -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
84 | +# This program is free software: you can redistribute it and/or modify |
85 | +# it under the terms of the GNU Affero General Public License as |
86 | +# published by the Free Software Foundation, either version 3 of the |
87 | +# License, or (at your option) any later version. |
88 | +# |
89 | +# This program is distributed in the hope that it will be useful, |
90 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
92 | +# GNU Affero General Public License for more details. |
93 | +# |
94 | +# You should have received a copy of the GNU Affero General Public License |
95 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
96 | # |
97 | ############################################################################## |
98 | |
99 | { |
100 | - "name" : "Partner Adress Category", |
101 | - "description" : """Add categories on Address like there is on Partner. This is interesting for managing mailling list based on address |
102 | - for example. |
103 | + "name" : "Partner Address Category", |
104 | + "description" : """\ |
105 | + res.partner.address.category |
106 | + ---------------------------- |
107 | + |
108 | + This module is deprecated as of OpenERP 7.0, because that version |
109 | + deprecated res.partner.address, and res.partner already has multi |
110 | + category support (visible as Tags in the user interface). |
111 | + |
112 | + The port of this module to OpenERP 7 keeps the model definitions, but |
113 | + removes the views (for which the base views are no longer |
114 | + available). The migration process should ensure that the |
115 | + res.partner.address.category records are migrated to |
116 | + res.partner.category records. |
117 | """, |
118 | "version" : "1.2", |
119 | "author" : "Camptocamp", |
120 | @@ -41,13 +44,10 @@ |
121 | "depends" : [ |
122 | "base", |
123 | ], |
124 | - "init_xml" : [ |
125 | - "security/security.xml" |
126 | - ], |
127 | - "update_xml" : [ |
128 | - "base_address_view.xml", |
129 | - 'security/ir.model.access.csv', |
130 | - ], |
131 | + "data" : [ |
132 | + "security/security.xml" |
133 | + 'security/ir.model.access.csv', |
134 | + ], |
135 | "active": False, |
136 | - "installable": False |
137 | + "installable": True |
138 | } |
139 | |
140 | === modified file 'base_address_category/base_address.py' |
141 | --- base_address_category/base_address.py 2012-10-17 10:29:21 +0000 |
142 | +++ base_address_category/base_address.py 2013-01-22 12:34:36 +0000 |
143 | @@ -1,59 +1,54 @@ |
144 | # -*- coding: utf-8 -*- |
145 | ############################################################################## |
146 | # |
147 | -# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) |
148 | +# Copyright (c) 2010-2013 Camptocamp SA (http://www.camptocamp.com) |
149 | # All Right Reserved |
150 | # |
151 | # Author : Nicolas Bessi (Camptocamp), Joel Grand-Guillaume |
152 | # |
153 | -# WARNING: This program as such is intended to be used by professional |
154 | -# programmers who take the whole responsability of assessing all potential |
155 | -# consequences resulting from its eventual inadequacies and bugs |
156 | -# End users who are looking for a ready-to-use solution with commercial |
157 | -# garantees and support are strongly adviced to contract a Free Software |
158 | -# Service Company |
159 | -# |
160 | -# This program is Free Software; you can redistribute it and/or |
161 | -# modify it under the terms of the GNU General Public License |
162 | -# as published by the Free Software Foundation; either version 2 |
163 | -# of the License, or (at your option) any later version. |
164 | -# |
165 | -# This program is distributed in the hope that it will be useful, |
166 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
167 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
168 | -# GNU General Public License for more details. |
169 | -# |
170 | -# You should have received a copy of the GNU General Public License |
171 | -# along with this program; if not, write to the Free Software |
172 | -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
173 | +# This program is free software: you can redistribute it and/or modify |
174 | +# it under the terms of the GNU Affero General Public License as |
175 | +# published by the Free Software Foundation, either version 3 of the |
176 | +# License, or (at your option) any later version. |
177 | +# |
178 | +# This program is distributed in the hope that it will be useful, |
179 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
180 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
181 | +# GNU Affero General Public License for more details. |
182 | +# |
183 | +# You should have received a copy of the GNU Affero General Public License |
184 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
185 | +# |
186 | # |
187 | ############################################################################## |
188 | |
189 | |
190 | -from osv import osv, fields |
191 | +from openerp.osv import osv, fields, orm |
192 | |
193 | -class ResPartnerAdressCategory(osv.osv): |
194 | - def name_get(self, cr, uid, ids, context={}): |
195 | +class ResPartnerAdressCategory(orm.Model): |
196 | + def name_get(self, cr, uid, ids, context=None): |
197 | if not len(ids): |
198 | return [] |
199 | - reads = self.read(cr, uid, ids, ['name','parent_id'], context) |
200 | + reads = self.read(cr, uid, ids, ['name', 'parent_id'], context) |
201 | res = [] |
202 | for record in reads: |
203 | name = record['name'] |
204 | if record['parent_id']: |
205 | - name = record['parent_id'][1]+' / '+name |
206 | + name = '%s / %s ' % (record['parent_id'][1], name) |
207 | res.append((record['id'], name)) |
208 | return res |
209 | |
210 | def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, unknow_dict): |
211 | res = self.name_get(cr, uid, ids) |
212 | return dict(res) |
213 | + |
214 | def _check_recursion(self, cr, uid, ids): |
215 | level = 100 |
216 | - while len(ids): |
217 | - cr.execute('select distinct parent_id from res_partner_address_category\ |
218 | - where id in ('+','.join(map(unicode,ids))+')') |
219 | - ids = filter(None, map(lambda x:x[0], cr.fetchall())) |
220 | + while ids: |
221 | + cr.execute('select distinct parent_id ' |
222 | + 'from res_partner_address_category ' |
223 | + 'where id in %s', ids) |
224 | + ids = [parent_id for (parent_id,) in cr.fetchall() if parent_id] |
225 | if not level: |
226 | return False |
227 | level -= 1 |
228 | @@ -65,27 +60,36 @@ |
229 | _name = 'res.partner.address.category' |
230 | _columns = { |
231 | 'name': fields.char('Category Name', required=True, size=64), |
232 | - 'parent_id': fields.many2one('res.partner.address.category', 'Parent Category', select=True), |
233 | - 'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Name'), |
234 | - 'child_ids': fields.one2many('res.partner.address.category', 'parent_id', 'Childs Category'), |
235 | + 'parent_id': fields.many2one('res.partner.address.category', |
236 | + 'Parent Category', |
237 | + select=True), |
238 | + 'complete_name': fields.function(_name_get_fnc, |
239 | + type="char", |
240 | + string='Name'), |
241 | + 'child_ids': fields.one2many('res.partner.address.category', |
242 | + 'parent_id', |
243 | + 'Children Category'), |
244 | 'active' : fields.boolean('Active'), |
245 | } |
246 | _constraints = [ |
247 | - (_check_recursion, 'Error ! You can not create recursive categories.', ['parent_id']) |
248 | + (_check_recursion, |
249 | + 'Error: you can not create recursive categories.', |
250 | + ['parent_id']) |
251 | ] |
252 | _defaults = { |
253 | 'active' : lambda *a: 1, |
254 | } |
255 | _order = 'parent_id,name' |
256 | |
257 | -ResPartnerAdressCategory() |
258 | - |
259 | - |
260 | -class ResPartnerAddress(osv.osv): |
261 | + |
262 | +class ResPartnerAddress(orm.Model): |
263 | _inherit = "res.partner.address" |
264 | |
265 | _columns = { |
266 | - 'category_id': fields.many2many('res.partner.address.category', 'res_partner_address_category_rel', 'adress_id', 'category_id', 'Adress categories'), |
267 | + 'category_id': fields.many2many('res.partner.address.category', |
268 | + 'res_partner_address_category_rel', |
269 | + 'adress_id', |
270 | + 'category_id', |
271 | + 'Address categories'), |
272 | } |
273 | |
274 | -ResPartnerAddress() |
275 | |
276 | === modified file 'base_address_category/base_address_view.xml' |
277 | --- base_address_category/base_address_view.xml 2011-08-12 12:53:16 +0000 |
278 | +++ base_address_category/base_address_view.xml 2013-01-22 12:34:36 +0000 |
279 | @@ -1,154 +1,4 @@ |
280 | <openerp> |
281 | <data> |
282 | - #--------------------------------------------------------------------------------------------------------- |
283 | - # Search Address |
284 | - #--------------------------------------------------------------------------------------------------------- |
285 | - <record id="view_res_partner_address_filter" model="ir.ui.view"> |
286 | - <field name="name">res.partner.address.select</field> |
287 | - <field name="model">res.partner.address</field> |
288 | - <field name="inherit_id" ref="base.view_res_partner_address_filter" /> |
289 | - <field name="type">search</field> |
290 | - <field name="arch" type="xml"> |
291 | - <field name="country_id" position="after" > |
292 | - <field name="category_id" /> |
293 | - </field> |
294 | - </field> |
295 | - </record> |
296 | - |
297 | - |
298 | - #--------------------------------------------------------------------------------------------------------- |
299 | - # Partner form->contact and view of address |
300 | - #--------------------------------------------------------------------------------------------------------- |
301 | - |
302 | - <record model="ir.ui.view" id="view_partner_address_categ_form1_inherit"> |
303 | - <field name="name">res.partner.address.form1.c2c_partner_adress</field> |
304 | - <field name="model">res.partner.address</field> |
305 | - <field name="type">form</field> |
306 | - <field name="inherit_id" ref="base.view_partner_address_form1" /> |
307 | - <field name="priority" eval="17" /> |
308 | - <field name="arch" type="xml"> |
309 | - <xpath expr="/form/group[3]" position="after"> |
310 | - <group colspan="4"> |
311 | - <separator string="Address Categories" colspan="4"/> |
312 | - <field name="category_id" nolabel="1"/> |
313 | - </group> |
314 | - </xpath> |
315 | - </field> |
316 | - </record> |
317 | - |
318 | - |
319 | - <!-- |
320 | - ========================================= |
321 | - the short form used in the partner form |
322 | - ========================================= |
323 | - --> |
324 | - |
325 | - <record model="ir.ui.view" id="view_partner_address_form2_inerit_categ"> |
326 | - <field name="name">res.partner.address.form2_c2c_partner_address</field> |
327 | - <field name="model">res.partner.address</field> |
328 | - <field name="type">form</field> |
329 | - <field name="inherit_id" ref="base.view_partner_address_form2" /> |
330 | - <field name="priority" eval="17" /> |
331 | - <field name="arch" type="xml"> |
332 | - <xpath expr="/form/field[@name='email']" position="after"> |
333 | - <newline/> |
334 | - <separator string="Address Categories" colspan="4"/> |
335 | - <field name="category_id" nolabel="1"/> |
336 | - </xpath> |
337 | - </field> |
338 | - </record> |
339 | - |
340 | - |
341 | - <!-- |
342 | - ========================================= |
343 | - the short form used in the res_partner stdandard form |
344 | - ========================================= |
345 | - --> |
346 | - <record model="ir.ui.view" id="view_partner_form_inherite_categ_infos"> |
347 | - <field name="name">res.partner.form_partner</field> |
348 | - <field name="model">res.partner</field> |
349 | - <field name="type">form</field> |
350 | - <field name="inherit_id" ref="base.view_partner_form" /> |
351 | - <field name="arch" type="xml"> |
352 | - <xpath expr="/form/notebook/page[@string='General']/field[@name='address']/form[@string='Partner Contacts']/group[3]" position="after"> |
353 | - <group colspan="4" > |
354 | - <separator string="Address Categories" colspan="4"/> |
355 | - <field name="category_id" nolabel="1"/> |
356 | - </group> |
357 | - </xpath> |
358 | - </field> |
359 | - </record> |
360 | - |
361 | - <!-- |
362 | - ====================== |
363 | - Adresses categories |
364 | - ====================== |
365 | - --> |
366 | - <record model="ir.ui.view" id="view_partner_address_category_form"> |
367 | - <field name="name">res.partner.address.category.form</field> |
368 | - <field name="model">res.partner.address.category</field> |
369 | - <field name="type">form</field> |
370 | - <field name="arch" type="xml"> |
371 | - <form string="Partner categories"> |
372 | - <field name="name" select="1"/> |
373 | - <field name="active" select="1" /> |
374 | - <field name="parent_id"/> |
375 | - </form> |
376 | - </field> |
377 | - </record> |
378 | - <record model="ir.ui.view" id="view_partner_address_category_list"> |
379 | - <field name="name">res.partner.address.category.list</field> |
380 | - <field name="model">res.partner.address.category</field> |
381 | - <field name="type">tree</field> |
382 | - <field name="priority" eval="6"/> |
383 | - <field name="arch" type="xml"> |
384 | - <tree string="Partner categories"> |
385 | - <field name="complete_name"/> |
386 | - </tree> |
387 | - </field> |
388 | - </record> |
389 | - <record model="ir.ui.view" id="view_partner_address_category_tree"> |
390 | - <field name="name">res.partner.address.category.tree</field> |
391 | - <field name="model">res.partner.address.category</field> |
392 | - <field name="type">tree</field> |
393 | - <field name="field_parent">child_ids</field> |
394 | - <field name="arch" type="xml"> |
395 | - <tree string="Partner Categories"> |
396 | - <field name="name"/> |
397 | - </tree> |
398 | - </field> |
399 | - </record> |
400 | - <record model="ir.actions.act_window" id="action_partner_address_category"> |
401 | - <field name="name">Address categories</field> |
402 | - <field name="type">ir.actions.act_window</field> |
403 | - <field name="res_model">res.partner.address.category</field> |
404 | - <field name="view_type">tree</field> |
405 | - <field name="view_id" ref="view_partner_address_category_tree"/> |
406 | - <field name="domain">[('parent_id','=',False)]</field> |
407 | - </record> |
408 | - <menuitem parent="base.menu_address_book" action="action_partner_address_category" id="menu_partner_address_category"/> |
409 | - |
410 | - <record model="ir.actions.act_window" id="action_partner_by_category"> |
411 | - <field name="res_model">res.partner.address</field> |
412 | - <field name="view_type">form</field> |
413 | - <field name="view_mode">tree,form</field> |
414 | - <field name="domain">[('category_id','child_of', [active_id])]</field> |
415 | - </record> |
416 | - <record model="ir.values" id="ir_action_partner_by_category"> |
417 | - <field name="key2" eval="'tree_but_open'"/> |
418 | - <field name="model" eval="'res.partner.address.category'"/> |
419 | - <field name="name">Open partners</field> |
420 | - <field name="value" eval="'ir.actions.act_window,%d'%action_partner_by_category"/> |
421 | - <field name="object" eval="True"/> |
422 | - </record> |
423 | - |
424 | - <record model="ir.actions.act_window" id="action_partner_address_category_form"> |
425 | - <field name="name">Address categories</field> |
426 | - <field name="type">ir.actions.act_window</field> |
427 | - <field name="res_model">res.partner.address.category</field> |
428 | - <field name="view_type">form</field> |
429 | - </record> |
430 | - <menuitem parent="base.menu_config_address_book" action="action_partner_address_category_form" id="menu_partner_address_category_form"/> |
431 | - |
432 | </data> |
433 | -</openerp> |
434 | \ No newline at end of file |
435 | +</openerp> |
The string interpolation in the query at line 222 should be replaced by the cr.execute() second argument.