Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

I get an error when I try to make a record in quotation. In fact, I add the column supllier_id in sale_order_line and I changed the method product_id_change.

By
tansadio
on 10/8/14, 3:23 AM 754 views

Here is my code:

class sale_order_line(osv.Model):
    _name = 'sale.order.line'
    _inherit ='sale.order.line'
    
    _columns = {
        
         #'order_line_tpl_id': fields.related('product_id', 'product_tmpl_id', type='many2one', string='Order Line tmpl'),
         #'supplier_id': fields.related('order_line_tpl_id', 'name', type='many2one', relation='res.partner',  string='Supplier', domain=[('supplier', '=', True)]),
         'supplier_id': fields.many2one('product.supplierinfo', 'Supplier'),
         'product_tmpl_id': fields.related('supplier_id', 'product_tmpl_id', type='many2one', string='Order Line tmpl',readonly=True,ondelete='restrict'),

    }

    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,
            date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
            
        res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
            partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
        
        product_obj = self.pool.get('product.product')
        supp_info_obj = self.pool.get('product.supplierinfo')
        supp_info_ids = supp_info_obj.search(cr, uid, [('product_tmpl_id', '=', product)])
        #product_ids = product_obj.search(cr, uid, [('seller_ids', 'in', supp_info_ids)])
        domain = {
            'supplier_id':[('id', 'in', supp_info_ids)],
        }
        res['domain'].update(domain)
        
        # Je mets à jour le champ name de sale_order_line
        supp_info_obj = supp_info_obj.browse(cr, uid, product, context=context)
        
        if not flag:
            if supp_info_obj.date_code:
                res['value']['name'] += '\n'+ '[Date Code] => ' + `supp_info_obj.date_code`
            
            if supp_info_obj.price:
                res['value']['name'] += '\n'+ '[Price] => ' + `supp_info_obj.price`
                
            if supp_info_obj.norme_rohs:
                res['value']['name'] += '\n'+ '[Rohs Norm] => ' + `supp_info_obj.norme_rohs`
                
            if supp_info_obj.packaging:
                res['value']['name'] += '\n'+ '[Packaging] => ' +`supp_info_obj.packaging`
                
        
        return res
        
sale_order_line()

 

 

And here is my error:

 

  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/models.py", line 1323, in default_get
    value = record[name]
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/models.py", line 5403, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/fields.py", line 710, in __get__
    record.add_default_value(self)
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/models.py", line 1368, in add_default_value
    field.determine_default(self)
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/fields.py", line 1380, in determine_default
    super(Many2one, self).determine_default(record)
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/fields.py", line 818, in determine_default
    record._cache[self] = SpecialValue(self.null(record.env))
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/fields.py", line 1285, in null
    return env[self.comodel_name]
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/api.py", line 719, in __getitem__
    return self.registry[model_name]._browse(self, ())
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/modules/registry.py", line 100, in __getitem__
    return self.models[model_name]
KeyError: None

Help me PLEASE

0
tansadio
On 10/8/14, 4:22 AM

I found what was wrong.
In fact product_tmpl_id column that I added in sale_order_line that caused the error.

Glad to hear that you found what caused your error. Can I ask how you fixed it?

Michael Watchorn
on 11/11/14, 3:43 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/8/14, 3:23 AM
Seen: 754 times
Last updated: 3/16/15, 8:10 AM