~angelmoya/product-extra-addons/nan_product_pack

« back to all changes in this revision

Viewing changes to product_multi_price/product_price_fields.py

  • Committer: Benoit Guillot
  • Date: 2012-09-05 13:40:51 UTC
  • Revision ID: benoit.guillot@akretion.com.br-20120905134051-pchufhl1rz3ximdx
[FIX] product_multi_price : field basedon should be required

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        'basedon_field_id' : fields.many2one('ir.model.fields', 'Based on Field ID', domain = [('model', '=', 'product.product'), ('ttype', '=', 'selection')]),
42
42
        'product_coef_field_id' : fields.many2one('ir.model.fields', 'Product Coef Field ID', domain = [('model', '=', 'product.product'), ('ttype', '=', 'float')]),
43
43
        'categ_coef_field_id' : fields.many2one('ir.model.fields', 'Category Coef Field ID', domain = [('model', '=', 'product.category'), ('ttype', '=', 'float')]),
44
 
        'default_basedon':fields.selection([('categ_coef','Price on category coefficient'),('product_coef','Price on product coefficient'),('manual','Manual price')], 'Based on by default'),
 
44
        'default_basedon':fields.selection([('categ_coef','Price on category coefficient'),('product_coef','Price on product coefficient'),('manual','Manual price')], 'Based on by default', required=True),
45
45
        'currency_id': fields.many2one('res.currency', "Currency", required=True, help="The currency the field is expressed in."),
46
46
        'inc_price_field_id' : fields.many2one('ir.model.fields', 'Price Included Field ID', domain = [('model', '=', 'product.product'), ('ttype', '=', 'float')]),
47
47
    }
60
60
    _order = "sequence, name"
61
61
 
62
62
    def _create_price_type(self, cr, uid, vals, context=None):
63
 
        field = (vals.get('field_name', False) or 'x_pm_price_' + vals['name'].replace(' ', '_')).lower()
 
63
        field = (vals.get('field_name', False) or 'x_pm_price_' + vals['name'].replace(' ', '_').replace('-', '_')).lower()
64
64
        name = (_('Price')) + ' ' + (vals.get('field_name', False) or vals['name']).capitalize()
65
65
        type_obj = self.pool.get('product.price.type')
66
66
        price_type_ids = type_obj.search(cr, uid, [
136
136
                    model_id = product_model_id
137
137
                    model = 'product.product'
138
138
                field_vals = {
139
 
                    'name': (vals.get('field_name', False) or 'x_pm_' + field + '_' + vals['name'].replace(' ', '_')).lower() ,
 
139
                    'name': (vals.get('field_name', False) or 'x_pm_' + field + '_' + vals['name'].replace(' ', '_').replace('-', '_')).lower() ,
140
140
                    'model_id':model_id,
141
141
                    'model':model,
142
142
                    'field_description': (vals.get('field_name', False) or vals['name']).capitalize() + ' ' + field,
147
147
                if field == 'basedon':
148
148
                    field_vals['ttype'] = 'selection'
149
149
                    field_vals['selection'] = "[('categ_coef','Price on category coefficient'),('product_coef','Price on product coefficient'),('manual','Manual price')]"
 
150
                    field_vals['required'] = True
150
151
                vals[field + '_field_id'] = self.pool.get('ir.model.fields').create(cr, uid, field_vals)
151
152
                default_vals={}
152
153
                if field == 'basedon' and vals.get('default_basedon', False):