Ir al contenido
Menú
Se marcó esta pregunta

i modified the _cart_update function of website_sale to update the field price_unit of sale.order.line. But if i write to the sale.order.line the functional fields of the sale.order.line like price_subtotal are not updated after write?!?

sol_obj = self.pool.get('sale.order.line') 
sol_obj.write(cr, SUPERUSER_ID, [line_id], {'price_unit': 10, }, context=context) 
Avatar
Descartar
Mejor respuesta

def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None):

    context = context or
    res = super(sale_order, self)._website_product_id_change(cr, uid, ids, order_id, product_id, qty=qty, line_id=line_id, context=context)

    res.update({'price_unit': 10})

    return res

Avatar
Descartar
Autor

Thank you very much for the solution - it works. But i really don't get it why?!? i know that _website_product_id_change is used to set the values for writes later on - but why cant i update a sales order line later ?!? Would be really really nice to get a tip why this works but changing sale.order.line later in the process dont.

perhaps not totally correct but : with onchange you are using the current cache of view (you write not in database) then fields function is updated if it depends of field you change, if you write directly in database cache is not changed and function field not too. bye

Publicaciones relacionadas Respuestas Vistas Actividad
2
dic 24
21069
0
sept 24
1005
3
ago 24
2084
0
feb 24
1401
0
feb 24
983