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

Functional fields not update on write() -- for sales.order.line (price_subtotal)

By
Michael Karrer
on 3/23/15, 5:28 PM 934 views

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) 
2

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/23/15, 6:25 PM

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

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.

Michael Karrer
on 3/23/15, 6:55 PM

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

Cyril Gaspard (GEM)
on 3/23/15, 7:12 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: 3/23/15, 5:28 PM
Seen: 934 times
Last updated: 3/23/15, 6:52 PM