I got error can't adapt type NewId when I cave a new document in odoo

22 Views Asked by At

I have this py and it's show an error everytime I create new document and want to save it. This is the py script

@api.multi
@api.depends('product_id','order_id')
def _get_cost_price_currency_update2(self):
    for record in self:
        param2 =()
        query2 = '''SELECT hpp_update,cost_price_set_lock
                        FROM sale_order_line
                        WHERE order_id = %s AND product_id = %s
                 '''
        param2 +=(record.order_id.id,record.product_id.id)
        self.env.cr.execute(query2,param2)
        query_result_lines2= self.env.cr.dictfetchall()

        for line in query_result_lines2:
            cost_price_set_lock_2 = line['cost_price_set_lock']
        record.cost_price_set_lock_2 = cost_price_set_lock_2

cost_price_set_lock_2 = fields.Float(string='HPP Lock', compute=_get_cost_price_currency_update2)

This is the error

File "/opt/odoo/odoo-server/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
ProgrammingError: can't adapt type 'NewId'

How to remove the can't adapt type 'NewId' error? Thanks

0

There are 0 best solutions below