Merge lp:~camptocamp/openerp-product-attributes/6.1-fix-1259215-quickcreate-lep into lp:~product-core-editors/openerp-product-attributes/6.1

Proposed by Leonardo Pistone
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 197
Merged at revision: 196
Proposed branch: lp:~camptocamp/openerp-product-attributes/6.1-fix-1259215-quickcreate-lep
Merge into: lp:~product-core-editors/openerp-product-attributes/6.1
Diff against target: 48 lines (+17/-4)
1 file modified
base_custom_attributes/custom_attributes.py (+17/-4)
To merge this branch: bzr merge lp:~camptocamp/openerp-product-attributes/6.1-fix-1259215-quickcreate-lep
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no tests Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Review via email: mp+198619@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Leonardo,

Thanks for the contrib !

I think on line 15, context is a kwarg, then could you correct that to context=context ?

Thanks, otherwise LGTM.

Regards,

Joël

review: Approve (code review, no tests)
197. By Leonardo Pistone

[imp] context -> context=context

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks for the review Joël. I fixed the context=context.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM thanks for the fix

review: Approve (code review, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_custom_attributes/custom_attributes.py'
2--- base_custom_attributes/custom_attributes.py 2013-12-11 14:53:28 +0000
3+++ base_custom_attributes/custom_attributes.py 2013-12-12 15:35:23 +0000
4@@ -245,21 +245,33 @@
5 "but not in the database"),
6 }
7
8+ def name_create(self, cr, uid, name, context=None):
9+ if context is None:
10+ context = {}
11+ rec_id = self.create(cr, uid, {
12+ 'field_description': name,
13+ 'name': 'x_{0}'.format(name),
14+ }, context=context)
15+ return self.name_get(cr, uid, [rec_id], context=context)[0]
16+
17 def create(self, cr, uid, vals, context=None):
18 if vals.get('relation_model_id'):
19 relation = self.pool.get('ir.model').read(
20 cr, uid, [vals.get('relation_model_id')], ['model'])[0]['model']
21 else:
22 relation = 'attribute.option'
23- if vals['attribute_type'] == 'select':
24+ if vals.get('attribute_type') == 'select':
25 vals['ttype'] = 'many2one'
26 vals['relation'] = relation
27- elif vals['attribute_type'] == 'multiselect':
28+ elif vals.get('attribute_type') == 'multiselect':
29 vals['ttype'] = 'many2many'
30 vals['relation'] = relation
31 vals['serialized'] = True
32 else:
33- vals['ttype'] = vals['attribute_type']
34+ vals['ttype'] = (
35+ vals.get('attribute_type')
36+ or self._defaults.get('attribute_type')
37+ )
38
39 if vals.get('serialized'):
40 field_obj = self.pool.get('ir.model.fields')
41@@ -322,7 +334,8 @@
42 return None
43
44 _defaults = {
45- 'model_id': _get_default_model
46+ 'model_id': _get_default_model,
47+ 'attribute_type': 'char',
48 }
49
50

Subscribers

People subscribed via source and target branches