Update another field from Function field

87 views
Skip to first unread message

Martín Guzmán

unread,
Aug 30, 2013, 3:39:20 AM8/30/13
to tryto...@googlegroups.com
Hi all! I'm trying to change the value of a field inside a Function field getter. When I tried to call the write method I get this: "InternalError: cannot execute UPDATE in a read-only transaction". Is there a way to do it? If you can't, how can I update a field each time a view is refreshed?

Thanks for advance.

Martín Guzmán

Cédric Krier

unread,
Aug 30, 2013, 4:02:09 AM8/30/13
to tryto...@googlegroups.com
On 30/08/13 00:39 -0700, Martín Guzmán wrote:
> Hi all! I'm trying to change the value of a field inside a Function field
> getter. When I tried to call the write method I get this: "InternalError:
> cannot execute UPDATE in a read-only transaction". Is there a way to do
> it?

You could change every read calls from readonly to not-readonly:

http://doc.tryton.org/2.8/trytond/doc/ref/models/models.html?highlight=rpc#trytond.model.Model.__rpc__

But I hardly descourage you to do so because it will break the design of
Tryton.

> If you can't, how can I update a field each time a view is refreshed?

You can not but could you elaborate on why you want to do this.

--
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: cedric...@b2ck.com
Website: http://www.b2ck.com/

Martín Guzmán

unread,
Sep 2, 2013, 12:24:38 PM9/2/13
to tryto...@googlegroups.com

> If you can't, how can I update a field each time a view is refreshed?

You can not but could you elaborate on why you want to do this.


I created a field function that calculates the priority of buying a product according to the needs of my company. What I'm trying to do is create domains in the views (action.act_window.domain) to facilitate finding the products according to this priority. As the field is a function field, I can not use it directly in the domain. So I'm trying to update a field every time the function field is updated. I dont know if there is another way I can do this...

Martín Guzmán

Jean C

unread,
Sep 2, 2013, 12:29:17 PM9/2/13
to tryto...@googlegroups.com
I created a field function that calculates the priority of buying a product according to the needs of my company. What I'm trying to do is create domains in the views (action.act_window.domain) to facilitate finding the products according to this priority. As the field is a function field, I can not use it directly in the domain. So I'm trying to update a field every time the function field is updated. I dont know if there is another way I can do this...

You can use the searcher attribute of the function field to build a domain on the field.

If you are confident that the number of element that will be fetched is not too much, you also can override the search method of your model and manually filter the result.

Jean CAVALLO
Coopengo

Cédric Krier

unread,
Sep 2, 2013, 12:33:33 PM9/2/13
to tryto...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages