← Back to team overview

openerp-community team mailing list archive

lp:~akretion-team/openerp-product-attributes/7.0-base_custom_attributes-onchange-field-description into lp:openerp-product-attributes

 

Benoit Guillot - http://www.akretion.com has proposed merging lp:~akretion-team/openerp-product-attributes/7.0-base_custom_attributes-onchange-field-description into lp:openerp-product-attributes.

Requested reviews:
  Product Core Editors (product-core-editors)

For more details, see:
https://code.launchpad.net/~akretion-team/openerp-product-attributes/7.0-base_custom_attributes-onchange-field-description/+merge/191362

This proposal fixes the onchange of the field description. 

Indeed, when an attribute is already created, the field name is readonly. 
But if we change the field description, the onchange change the field name, but it is useless because the field name is readonly. It can be confusing for the user to see the field name changing and finaly not once he saves the attibute.

So with the proposal, the onchange doesn't change the field name if the attribute has already been created.
-- 
https://code.launchpad.net/~akretion-team/openerp-product-attributes/7.0-base_custom_attributes-onchange-field-description/+merge/191362
Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== modified file 'base_custom_attributes/custom_attributes.py'
--- base_custom_attributes/custom_attributes.py	2013-10-09 14:34:58 +0000
+++ base_custom_attributes/custom_attributes.py	2013-10-16 09:55:46 +0000
@@ -219,9 +219,9 @@
         vals['state'] = 'manual'
         return super(attribute_attribute, self).create(cr, uid, vals, context)
 
-    def onchange_field_description(self, cr, uid, ids, field_description, context=None):
-        name = u'x_'
-        if field_description:
+    def onchange_field_description(self, cr, uid, ids, field_description, name, create_date, context=None):
+        name = name or u'x_'
+        if field_description and not create_date:
             name = unidecode(u'x_%s' % field_description.replace(' ', '_').lower())
         return  {'value' : {'name' : name}}
 

=== modified file 'base_custom_attributes/custom_attributes_view.xml'
--- base_custom_attributes/custom_attributes_view.xml	2013-10-09 14:34:58 +0000
+++ base_custom_attributes/custom_attributes_view.xml	2013-10-16 09:55:46 +0000
@@ -138,7 +138,7 @@
             <field name="model">attribute.attribute</field>
             <field name="arch" type="xml">
                 <form string="Attribute">
-                    <field name="field_description" on_change="onchange_field_description(field_description, context)"/>
+                    <field name="field_description" on_change="onchange_field_description(field_description, name, create_date, context)"/>
                     <field name="name" attrs="{'readonly':[('create_date', '!=', False)]}" on_change="onchange_name(name, context)"/>
                     <field name="attribute_type" />
                     <field name="model_id" />


Follow ups