Re: [tryton-dev] What is the fields_child and context_model
On 2018-10-01 02:52, Markus Bala wrote: > > > I am going to integrate with some WMS system for receiving. When user > > > input the PO number which is "Lodnum" then tryton "on_change" and will > > > display the WMS data to the list (MS SQL Server). > > > > > > Background, after "on_change", I will read data from MSSQL. And insert to > > > Tryton postgres. > > > But when inserted, above error occurred. > > > > on_change calls are always read-only to enforce good design and > > practice. You can not save in the database something that the user did > > not save yet. Instead you must just send modification to the client by > > setting fields (without saving). > > for ModelSQL , we can set by "self.field = value". > But how to setting the fields for context_model? It is set by the context. Otherwise, it is a model like the others, you can define on_change on it etc. -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/20181001102039.pcjhlogazp3dwy4t%40kei.
Re: [tryton-dev] What is the fields_child and context_model
On Monday, October 1, 2018 at 4:16:05 PM UTC+7, Cédric Krier wrote: > On 2018-10-01 01:55, Markus Bala wrote: > > > > It prompt error psycopg2, cannot execute INSERT because is > > > > readonly-transaction > > > > > > On which kind of RPC call are you doing a save? > > > > Traceback (most recent call last): > > File "/trytond/wsgi.py", line 71, in dispatch_request > > return endpoint(request, **request.view_args) > > File "/trytond/protocols/dispatcher.py", line 41, in rpc > > request, database_name, *request.rpc_params) > > File "/trytond/wsgi.py", line 42, in auth_required > > return wrapped(*args, **kwargs) > > File "/trytond/protocols/wrappers.py", line 122, in wrapper > > return func(request, pool, *args, **kwargs) > > File "/trytond/protocols/dispatcher.py", line 172, in _dispatch > > result = rpc.result(meth(inst, *c_args, **c_kwargs)) > > File "/trytond/model/modelview.py", line 677, in on_change > > method() > > File "/trytond/model/modelview.py", line 84, in wrapper > > result = func(self, *args, **kwargs) > > File "/trytond/model/fields/field.py", line 114, in wrapper > > return func(self, *args, **kwargs) > > File "/trytond/modules/tri_jda/jda.py", line 189, in on_change_lodnum > > rec.save(recs) > > File "/trytond/model/descriptors.py", line 33, in newfunc > > return self.func(owner, *args, **kwargs) > > File "/trytond/model/modelstorage.py", line 1532, in save > > news = cls.create([save_values[r] for r in to_create]) > > File "/trytond/model/modelsql.py", line 580, in create > > [insert_values], [table.id])) > > File "/trytond/backend/postgresql/database.py", line 61, in execute > > cursor.execute(self, sql, args) > > psycopg2.InternalError: cannot execute INSERT in a read-only transaction > > > > > > - > > Above is my stacktrace. > > > > I am going to integrate with some WMS system for receiving. When user input > > the PO number which is "Lodnum" then tryton "on_change" and will display > > the WMS data to the list (MS SQL Server). > > > > Background, after "on_change", I will read data from MSSQL. And insert to > > Tryton postgres. > > But when inserted, above error occurred. > > on_change calls are always read-only to enforce good design and > practice. You can not save in the database something that the user did > not save yet. Instead you must just send modification to the client by > setting fields (without saving). for ModelSQL , we can set by "self.field = value". But how to setting the fields for context_model? > > -- > Cédric Krier - B2CK SPRL > Email/Jabber: cedric.kr...@b2ck.com > Tel: +32 472 54 46 59 > Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/cedc16c5-6118-43b9-b96a-b991b464be3d%40googlegroups.com.
Re: [tryton-dev] What is the fields_child and context_model
On 2018-10-01 01:55, Markus Bala wrote: > > > It prompt error psycopg2, cannot execute INSERT because is > > > readonly-transaction > > > > On which kind of RPC call are you doing a save? > > Traceback (most recent call last): > File "/trytond/wsgi.py", line 71, in dispatch_request > return endpoint(request, **request.view_args) > File "/trytond/protocols/dispatcher.py", line 41, in rpc > request, database_name, *request.rpc_params) > File "/trytond/wsgi.py", line 42, in auth_required > return wrapped(*args, **kwargs) > File "/trytond/protocols/wrappers.py", line 122, in wrapper > return func(request, pool, *args, **kwargs) > File "/trytond/protocols/dispatcher.py", line 172, in _dispatch > result = rpc.result(meth(inst, *c_args, **c_kwargs)) > File "/trytond/model/modelview.py", line 677, in on_change > method() > File "/trytond/model/modelview.py", line 84, in wrapper > result = func(self, *args, **kwargs) > File "/trytond/model/fields/field.py", line 114, in wrapper > return func(self, *args, **kwargs) > File "/trytond/modules/tri_jda/jda.py", line 189, in on_change_lodnum > rec.save(recs) > File "/trytond/model/descriptors.py", line 33, in newfunc > return self.func(owner, *args, **kwargs) > File "/trytond/model/modelstorage.py", line 1532, in save > news = cls.create([save_values[r] for r in to_create]) > File "/trytond/model/modelsql.py", line 580, in create > [insert_values], [table.id])) > File "/trytond/backend/postgresql/database.py", line 61, in execute > cursor.execute(self, sql, args) > psycopg2.InternalError: cannot execute INSERT in a read-only transaction > > > - > Above is my stacktrace. > > I am going to integrate with some WMS system for receiving. When user input > the PO number which is "Lodnum" then tryton "on_change" and will display the > WMS data to the list (MS SQL Server). > > Background, after "on_change", I will read data from MSSQL. And insert to > Tryton postgres. > But when inserted, above error occurred. on_change calls are always read-only to enforce good design and practice. You can not save in the database something that the user did not save yet. Instead you must just send modification to the client by setting fields (without saving). -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/20181001091551.rfhe2e2es5h26rwf%40kei.
Re: [tryton-dev] What is the fields_child and context_model
On Monday, October 1, 2018 at 3:30:04 PM UTC+7, Cédric Krier wrote: > On 2018-10-01 01:04, Markus Bala wrote: > > But when I try using context_model, i am going to do some "save" to model. > > I do not understand. the context model is only used by the client. > > > It prompt error psycopg2, cannot execute INSERT because is > > readonly-transaction > > On which kind of RPC call are you doing a save? > > -- > Cédric Krier - B2CK SPRL > Email/Jabber: cedric.kr...@b2ck.com > Tel: +32 472 54 46 59 > Website: http://www.b2ck.com/ Traceback (most recent call last): File "/trytond/wsgi.py", line 71, in dispatch_request return endpoint(request, **request.view_args) File "/trytond/protocols/dispatcher.py", line 41, in rpc request, database_name, *request.rpc_params) File "/trytond/wsgi.py", line 42, in auth_required return wrapped(*args, **kwargs) File "/trytond/protocols/wrappers.py", line 122, in wrapper return func(request, pool, *args, **kwargs) File "/trytond/protocols/dispatcher.py", line 172, in _dispatch result = rpc.result(meth(inst, *c_args, **c_kwargs)) File "/trytond/model/modelview.py", line 677, in on_change method() File "/trytond/model/modelview.py", line 84, in wrapper result = func(self, *args, **kwargs) File "/trytond/model/fields/field.py", line 114, in wrapper return func(self, *args, **kwargs) File "/trytond/modules/tri_jda/jda.py", line 189, in on_change_lodnum rec.save(recs) File "/trytond/model/descriptors.py", line 33, in newfunc return self.func(owner, *args, **kwargs) File "/trytond/model/modelstorage.py", line 1532, in save news = cls.create([save_values[r] for r in to_create]) File "/trytond/model/modelsql.py", line 580, in create [insert_values], [table.id])) File "/trytond/backend/postgresql/database.py", line 61, in execute cursor.execute(self, sql, args) psycopg2.InternalError: cannot execute INSERT in a read-only transaction - Above is my stacktrace. I am going to integrate with some WMS system for receiving. When user input the PO number which is "Lodnum" then tryton "on_change" and will display the WMS data to the list (MS SQL Server). Background, after "on_change", I will read data from MSSQL. And insert to Tryton postgres. But when inserted, above error occurred. -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/a7ef917a-916d-432b-b734-d85ee2ff65d5%40googlegroups.com.
Re: [tryton-dev] What is the fields_child and context_model
On 2018-10-01 01:04, Markus Bala wrote: > But when I try using context_model, i am going to do some "save" to model. I do not understand. the context model is only used by the client. > It prompt error psycopg2, cannot execute INSERT because is > readonly-transaction On which kind of RPC call are you doing a save? -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/20181001082958.whomnyoacfe3lc5z%40kei.
Re: [tryton-dev] What is the fields_child and context_model
On Monday, October 1, 2018 at 2:35:05 PM UTC+7, Cédric Krier wrote: > On 2018-09-30 09:56, Markus Bala wrote: > > I found the balance_sheet reporting. > > But I do not undertstand what is the field_childs at the line 04. > > It is to define a tree: > https://tryton-readthedocs.readthedocs.io/projects/server/en/latest/topics/views/index.html?highlight=field_childs#tree-view > > > And what is the "context_model" at the line 10.? > > It is the model to display on top of the list to alter the context of > the view. > > -- > Cédric Krier - B2CK SPRL > Email/Jabber: cedric.kr...@b2ck.com > Tel: +32 472 54 46 59 > Website: http://www.b2ck.com/ Noted. the context_model --> is almost similar with wizard. But when I try using context_model, i am going to do some "save" to model. It prompt error psycopg2, cannot execute INSERT because is readonly-transaction is it normal? -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/bfac0338-fdf7-4219-ba7b-29d0bd5d1c92%40googlegroups.com.
Re: [tryton-dev] What is the fields_child and context_model
On 2018-09-30 09:56, Markus Bala wrote: > I found the balance_sheet reporting. > But I do not undertstand what is the field_childs at the line 04. It is to define a tree: https://tryton-readthedocs.readthedocs.io/projects/server/en/latest/topics/views/index.html?highlight=field_childs#tree-view > And what is the "context_model" at the line 10.? It is the model to display on top of the list to alter the context of the view. -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/20181001073415.2awuqi2niyiktzo6%40kei.
[tryton-dev] What is the fields_child and context_model
Line 01) Line 02)account.account.type Line 03)tree Line 04)childs Line 05)account_balance_sheet_tree Line 06) Line 07) Line 08)Balance Sheet Line 09)account.account.type Line 10)account.balance_sheet.context Line 11) Line 14) Line 17) Line 18) I found the balance_sheet reporting. But I do not undertstand what is the field_childs at the line 04. And what is the "context_model" at the line 10.? Especially the context_model? because it already has res_model -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/e3abda3f-ad09-46a3-84b2-ee37d838fbd8%40googlegroups.com.