~extra-addons-commiter/product-extra-addons/oerp6.1-stable

« back to all changes in this revision

Viewing changes to product_custom_attributes/product_attribute.py

  • Committer: Benoit Guillot
  • Date: 2012-08-27 09:08:03 UTC
  • Revision ID: benoit.guillot@akretion.com.br-20120827090803-kkilrbi8uip6mmv0
[FIX] product_custom_attributes : fix error message and fix creation of attributes via attribute groups

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import netsvc
24
24
#You should install the library Unicode2Ascii, you can find it in the akretion github repository
25
25
from unicode2ascii import Unicode2Ascii
 
26
from tools.translate import _
26
27
 
27
28
class attribute_option(osv.osv):
28
29
    _name = "attribute.option"
107
108
        'sequence': fields.integer('Sequence'),
108
109
    }
109
110
 
 
111
    def create(self, cr, uid, vals, context=None):
 
112
        for attribute in vals['attribute_ids']:
 
113
            if attribute[2] and not attribute[2].get('attribute_set_id'):
 
114
                attribute[2]['attribute_set_id'] = vals['attribute_set_id']
 
115
        return super(attribute_group, self).create(cr, uid, vals, context)
 
116
 
110
117
 
111
118
class attribute_set(osv.osv):
112
119
 
126
133
        return set_id
127
134
 
128
135
    def write(self, cr, uid, ids, vals, context=None):
 
136
        if isinstance(ids, (int, long)):
 
137
            ids = [ids]
129
138
        for set_id in ids:
130
139
            full_vals = vals.copy()
131
140
            for group in full_vals['attribute_group_ids']: