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.

Reply via email to