openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05773
[Merge] lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field into lp:openerp-product-attributes
Florian da Costa has proposed merging lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field into lp:openerp-product-attributes.
Requested reviews:
Product Core Editors (product-core-editors)
For more details, see:
https://code.launchpad.net/~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field/+merge/214690
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.
--
https://code.launchpad.net/~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field/+merge/214690
Your team Product Core Editors is requested to review the proposed merge of lp:~florian-dacosta/openerp-product-attributes/custom_base_attribute_ref__build_attribute_field into lp:openerp-product-attributes.
=== 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 @@
_description = "Attribute"
_inherits = {'ir.model.fields': 'field_id'}
+ #Deprecated remove on V8
def _build_attribute_field(self, cr, uid, page, attribute, context=None):
+ return self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id, context=context)
+
+ def _build_attribute_attribute_field(self, cr, uid, page, attribute, context=None):
parent = etree.SubElement(page, 'group', colspan="2", col="4")
kwargs = {'name': "%s" % attribute.name}
if attribute.ttype in ['many2many', 'text']:
@@ -166,8 +170,8 @@
ids = [op.value_ref.id for op in attribute.option_ids]
kwargs['domain'] = "[('id', 'in', %s)]" % ids
else:
- kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id
- kwargs['context'] = "{'default_attribute_id': %s}" % attribute.attribute_id.id
+ kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.id
+ kwargs['context'] = "{'default_attribute_id': %s}" % attribute.id
kwargs['required'] = str(attribute.required or
attribute.required_on_views)
field = etree.SubElement(parent, 'field', **kwargs)
@@ -188,7 +192,7 @@
for attribute in group.attribute_ids:
if attribute.name not in toupdate_fields:
toupdate_fields.append(attribute.name)
- self._build_attribute_field(cr, uid, page, attribute,
+ self._build_attribute_attribute_field(cr, uid, page, attribute.attribute_id,
context=context)
return notebook, toupdate_fields
Follow ups