Odoo Help


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.

on 10/8/14, 3:23 AM 1,285 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)],
        # 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



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__
  File "/home/balde/odoo_v8/aoe-80/aoe_base/openerp/models.py", line 1368, in add_default_value
  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

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

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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