Odoo Help


How make looping (for) with different object

on 12/8/15, 10:34 PM 892 views


How make looping with different object ???

i have file .py :

class wtc_purchase_order(osv.osv):
    _inherit = 'purchase.order'

def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
    res = super(wtc_purchase_order, self).onchange_partner_id(cr, uid, ids, partner_id, context=context)
    if not partner_id:
        return {}
    if context is None:
        context = {}
    product_suppinfo = self.pool.get('product.supplierinfo')
    ids_procs = product_suppinfo.search(cr, uid, [('name', '=', partner_id)], context=context)    
    procs_ids = product_suppinfo.browse(cr, uid, ids_procs)
    ids_prod_tmpl = []
    for product_ids in procs_ids:

    obj_product = self.pool.get('product.product')
    ids_product = obj_product.search(cr, uid, [('product_tmpl_id','in',ids_prod_tmpl)], context=context)
    detail_prod = obj_product.browse(cr, uid, ids_product)
    line = []
    for det_prod in detail_prod:
        for det_tax in procs_ids:

            line.append([0, False, {'product_id': det_prod,
                'name': det_prod.name,
                'date_planned': time.strftime("%Y-%m-%d"),
                'product_qty': 0,
                'product_uom': det_prod.uom_po_id.id,
                'order_id': ids,
                'price_unit': 0,
                'cprice_id': 0,
                'taxes_id': det_tax.tax_id.id,
                'account_analytic_id': False,
    return res

but when i compile, error !. 

this is message error :

Traceback (most recent call last):
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 499, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 516, in dispatch
    result = self._call_function(**self.params)
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 282, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 279, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 732, in __call__
    return self.method(*args, **kw)
  File "/home/heru/Odoo/openerp-8.0/openerp/http.py", line 375, in response_wrap
    response = f(*args, **kw)
  File "/home/heru/Odoo/Addons/Koin_Bumi/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/heru/Odoo/Addons/Koin_Bumi/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/api.py", line 360, in old_api
    result = method(recs, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5709, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5648, in _onchange_eval
    self.update(self._convert_to_cache(method_res['value'], validate=False))
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5196, in _convert_to_cache
    for name, value in values.iteritems()
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5197, in <dictcomp>
    if name in fields
  File "/home/heru/Odoo/openerp-8.0/openerp/fields.py", line 1452, in convert_to_cache
    result += result.new(command[2])
  File "/home/heru/Odoo/openerp-8.0/openerp/api.py", line 235, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5288, in new
    record._cache.update(record._convert_to_cache(values, update=True))
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5196, in _convert_to_cache
    for name, value in values.iteritems()
  File "/home/heru/Odoo/openerp-8.0/openerp/models.py", line 5197, in <dictcomp>
    if name in fields
  File "/home/heru/Odoo/openerp-8.0/openerp/fields.py", line 1474, in convert_to_cache
    raise ValueError("Wrong value for %s: %s" % (self, value))
ValueError: Wrong value for purchase.order.line.taxes_id: 7

anybody, can tell me what is the solution for my case ?

thanks in advance.

<sorry my language is bad>


please check account_tax table and make sure there is id 7 ?

Baiju KS
on 12/9/15, 6:13 AM

Baiju KS ==> yes id is correct. Baiju, so, what next step for fix my problem ?

on 12/9/15, 6:57 AM

please check the type of field "taxes_id" in the object which you are updating values

Baiju KS
on 12/9/15, 10:42 AM

Baiju ==>> type field "taxes_id" is many2many Baiju ...

on 12/9/15, 5:17 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

2 follower(s)


Asked: 12/8/15, 10:34 PM
Seen: 892 times
Last updated: 12/9/15, 12:21 AM