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
1=== modified file 'base_custom_attributes/custom_attributes.py'
2--- base_custom_attributes/custom_attributes.py 2013-12-11 15:03:14 +0000
3+++ base_custom_attributes/custom_attributes.py 2014-04-08 08:55:28 +0000
4@@ -143,7 +143,11 @@
5 _description = "Attribute"
6 _inherits = {'ir.model.fields': 'field_id'}
7
8+ #Deprecated remove on V8
9 def _build_attribute_field(self, cr, uid, page, attribute, context=None):
10+ return self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id, context=context)
11+
12+ def _build_attribute_attribute_field(self, cr, uid, page, attribute, context=None):
13 parent = etree.SubElement(page, 'group', colspan="2", col="4")
14 kwargs = {'name': "%s" % attribute.name}
15 if attribute.ttype in ['many2many', 'text']:
16@@ -166,8 +170,8 @@
17 ids = [op.value_ref.id for op in attribute.option_ids]
18 kwargs['domain'] = "[('id', 'in', %s)]" % ids
19 else:
20- kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id
21- kwargs['context'] = "{'default_attribute_id': %s}" % attribute.attribute_id.id
22+ kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.id
23+ kwargs['context'] = "{'default_attribute_id': %s}" % attribute.id
24 kwargs['required'] = str(attribute.required or
25 attribute.required_on_views)
26 field = etree.SubElement(parent, 'field', **kwargs)
27@@ -188,7 +192,7 @@
28 for attribute in group.attribute_ids:
29 if attribute.name not in toupdate_fields:
30 toupdate_fields.append(attribute.name)
31- self._build_attribute_field(cr, uid, page, attribute,
32+ self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id,
33 context=context)
34 return notebook, toupdate_fields
35

Subscribers

People subscribed via source and target branches