Merge lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field into lp:~product-core-editors/openerp-product-attributes/7.0

Proposed by Florian da Costa
Status: Needs review
Proposed branch: lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field
Merge into: lp:~product-core-editors/openerp-product-attributes/7.0
Diff against target: 34 lines (+7/-3)
1 file modified
base_custom_attributes/custom_attributes.py (+7/-3)
To merge this branch: bzr merge lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field
Reviewer Review Type Date Requested Status
Laetitia Gangloff (Acsone) (community) Needs Resubmitting
Product Core Editors Pending
Review via email: mp+214690@code.launchpad.net

Description of the change

The function _build_attribute_field which is useful to create a view from the attributes takes an attribute.location as a parameter.
The goal of this merge is simply to replace this parameter by an attribute.attribute, which is much more generic.

For example in my case, I am creating a module using attribute.attribute but I do not need to create attribute set or attribute group. In result, attribute.location dont exist so I can't use the _build_attribute_field function to create my view.

To post a comment you must log in.
Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

This project is now hosted on https://github.com/OCA/product-attribute. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting

Unmerged revisions

238. By Florian da Costa

[REF] Refactore _build_attribute_field function so it takes an attribute.attribute as parameter instead of an attribute.location, because it is more generic

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'base_custom_attributes/custom_attributes.py'
--- base_custom_attributes/custom_attributes.py 2013-12-11 15:03:14 +0000
+++ base_custom_attributes/custom_attributes.py 2014-04-08 08:55:28 +0000
@@ -143,7 +143,11 @@
143 _description = "Attribute"143 _description = "Attribute"
144 _inherits = {'ir.model.fields': 'field_id'}144 _inherits = {'ir.model.fields': 'field_id'}
145145
146 #Deprecated remove on V8
146 def _build_attribute_field(self, cr, uid, page, attribute, context=None):147 def _build_attribute_field(self, cr, uid, page, attribute, context=None):
148 return self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id, context=context)
149
150 def _build_attribute_attribute_field(self, cr, uid, page, attribute, context=None):
147 parent = etree.SubElement(page, 'group', colspan="2", col="4")151 parent = etree.SubElement(page, 'group', colspan="2", col="4")
148 kwargs = {'name': "%s" % attribute.name}152 kwargs = {'name': "%s" % attribute.name}
149 if attribute.ttype in ['many2many', 'text']:153 if attribute.ttype in ['many2many', 'text']:
@@ -166,8 +170,8 @@
166 ids = [op.value_ref.id for op in attribute.option_ids]170 ids = [op.value_ref.id for op in attribute.option_ids]
167 kwargs['domain'] = "[('id', 'in', %s)]" % ids171 kwargs['domain'] = "[('id', 'in', %s)]" % ids
168 else:172 else:
169 kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id173 kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.id
170 kwargs['context'] = "{'default_attribute_id': %s}" % attribute.attribute_id.id174 kwargs['context'] = "{'default_attribute_id': %s}" % attribute.id
171 kwargs['required'] = str(attribute.required or175 kwargs['required'] = str(attribute.required or
172 attribute.required_on_views)176 attribute.required_on_views)
173 field = etree.SubElement(parent, 'field', **kwargs)177 field = etree.SubElement(parent, 'field', **kwargs)
@@ -188,7 +192,7 @@
188 for attribute in group.attribute_ids:192 for attribute in group.attribute_ids:
189 if attribute.name not in toupdate_fields:193 if attribute.name not in toupdate_fields:
190 toupdate_fields.append(attribute.name)194 toupdate_fields.append(attribute.name)
191 self._build_attribute_field(cr, uid, page, attribute,195 self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id,
192 context=context)196 context=context)
193 return notebook, toupdate_fields197 return notebook, toupdate_fields
194198

Subscribers

People subscribed via source and target branches