2015-02-27 10:21 GMT+01:00 Simon Klemenc <[email protected]>: > On Friday, February 27, 2015 at 1:14:38 AM UTC+1, Cédric Krier wrote: >> >> On 26 Feb 15:53, Simon Klemenc wrote: >> > hi there, >> > >> > I recognized that when i update the party from a sale, the tax rule is >> not >> > updated for the sales line.. >> > >> > Easy, i thought, just add it to an on_change_party... >> > however, I dont know how i would update relational fields (sale lines) >> > calling line.save() is not really intended here i think and it doesnt >> work >> > aswel... >> > >> > Is there a way to do this? >> >> Not really that's why the party is readonly once there is a line added on >> sale. >> >> All right. > We have sale templates which we reuse quite often and i really need to > update taxes... > so i'll put it somewhere in validate or so... >
I think the "sale_price_list_change_party" [1] may help you. [1] https://bitbucket.org/zikzakmedia/trytond-sale_price_list_change_party > Whats the reason i can't call line.save() in on_change? rpc-readonly? can > i change it? > Because the on_change(_with) methods are readonly. They update the values in the client and they are saved when the user save the record. If you want to modify something when the record is saved, you must to extend the "write()" method. But an on_change method can modify One2Many items. The syntax is quite similar to described here [2]. In development branch, the on_change methods use the active record pattern so they will be more reusable for write() method, for example. [2] http://doc.tryton.org/3.4/trytond/doc/ref/models/fields.html#one2many -- Guillem Barba http://www.guillem.alcarrer.net
