[tryton-dev] Last email on this mailing list

2018-11-17 Thread 'Cédric Krier' via tryton-dev
As discussed on 
https://discuss.tryton.org/t/replace-mailing-list-by-discuss/599, this is the 
last email on this mailing list which will be read only.
Please consider using https://discuss.tryton.org/

Thanks.

-- 
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/96f80e7b-4e41-4f83-9e30-2c968ac6cbd1%40googlegroups.com.


Re: [tryton-dev] What is the fields_child and context_model

2018-10-01 Thread 'Cédric Krier' via tryton-dev
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

2018-10-01 Thread 'Cédric Krier' via tryton-dev
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

2018-10-01 Thread 'Cédric Krier' via tryton-dev
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] Mobile Apps For tryton?

2018-10-01 Thread 'Cédric Krier' via tryton-dev
On 2018-09-30 20:02, Markus Bala wrote:
> Is it any plan for Tryton in App?

No but sao, the web client, is responsive and so it can be used on
mobile device.

-- 
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/20181001073510.cu467jw3r7umhcjn%40kei.


Re: [tryton-dev] What is the fields_child and context_model

2018-10-01 Thread 'Cédric Krier' via tryton-dev
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.


Re: [tryton-dev] How to get the timezone from client

2018-09-28 Thread 'Cédric Krier' via tryton-dev
Hi,

On 2018-09-27 20:51, Markus Bala wrote:
> I noticed that setting timezone in user preference is missing.
> However, in the documentation still show the setting.

It is a mistake, the field has been removed long time ago:
https://bugs.tryton.org/issue7750

> Back to topic,
> My situation is to print the printer date/time in the report.
> If in the libreoffice, I set the date from the report. It will take the 
> server date but server's date is UTC timezone.
> 
> So, I will custom printed_date but how to get the timezone from client show 
> that can show the correct time?

You can not know the timezone of the client because it is the OS
timezone on which it runs. The best option is to use a timezone stored
on some record, for example you can use the one on company.

-- 
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/20180928072623.pzmurrf55xwlcuvf%40kei.


Re: [tryton-dev] How to get the Report in Byte?

2018-09-21 Thread 'Cédric Krier' via tryton-dev
On 2018-09-21 01:35, Markus Bala wrote:
> > > Question 3: How to get report in byte in trytond so I can print direct to 
> > > printer through network. Like the link below
> > > 
> > > https://www.zebra.com/us/en/support-downloads/knowledge-articles/ait/Network-Printing-Python-Example.html
> > 
> > You can get the Report class from the pool and call execute on it. This
> > will return the bytes as second element of the response.
> 
> Could you give me example on this? Iam litte bit confuse.
> 
> Currently, I am using Relatio. It should be a dirty hack. I hope can use the 
> method directly from Trytond instead.
> 
> Below is my code:
> 
> from relatorio import Report
> 
> class BarcodeLabel(Workflow, ModelSQL, ModelView):
> 
> @classmethod
> def print_lpn(cls, records):
> report = Report(abspath(join(dirname(__file__), 'lpn.odt')),
> ODT_MIME)
> data = report(records=records).render().getvalue()
> file_name = join(dirname(__file__), 'output_basic.odt')
> open(file_name, 'wb').write(data)

It should be something like:

@classmethod
def print_lpn(cls, records):
pool = Pool()
Report = pool.get('module.my_report', type='report')
ext, data, print, name = Report.execute(map(int, records), {})


-- 
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/20180921085311.jzkbjx3askvyu6nd%40kei.


Re: [tryton-dev] How to get the Report in Byte?

2018-09-21 Thread 'Cédric Krier' via tryton-dev
On 2018-09-17 01:21, Markus Bala wrote:
> Actually I have 3 questions, below is my case:
> 
> I will doing barcode label for some warehouse operation.
> 
> Case Study:
> At the receiving area, during receiving & storage, it will need to print 2 
> labels. One label is product label. One label is storage label. The different 
> between 2 labels are in the label's size.
> Product label using 5cm x 10cm. Storage label using 15cm x 10cm.
> 
> Because of this, I will  have 2 labels printer. Printer (A) for product 
> label. Printer (B) for storage Label.
> 
> Question 1: for "Direct Print", how can set when I click on print "Product 
> Label" it choose Printer (A) and vice versa.

On windows, the client use the command 'print' which let the OS decide.
So maybe you can use different file extension and configure the OS to
choose the right printer.
On MacOS, the client uses the 'open' command which just open the file.
Maybe it is possible to configure the "opener" to select the right
printer when requesting to print.
On UNIX, it uses the 'xdg-open' command. In this case, I guess you can
also customize xdg to select the right printer from the mime-type.

> Or alternative solution:
> Making the printer module. Like the link below:
> 
> https://groups.google.com/forum/#!searchin/tryton-dev/printer|sort:date/tryton-dev/1Hu0AE5bjd8/0zCHyxkPq3EJ

Not sure it is the best option because it requires a connection between
the server and the printer. Usually they are not in the same physical
area.

> Question 2: How to get "Tryton Client" IP from "Trytond"? the purpose to 
> fixed the IP/PC for the label printers so other PC do not have label printer

Since 4.8, the Transaction.context has an attribute '_request' which is
the werkzeug request object and contain the IP address of the client.
But there is no guarantee that this attribute will always be set (for
example from proteus request or cron job).

> Question 3: How to get report in byte in trytond so I can print direct to 
> printer through network. Like the link below
> 
> https://www.zebra.com/us/en/support-downloads/knowledge-articles/ait/Network-Printing-Python-Example.html

You can get the Report class from the pool and call execute on it. This
will return the bytes as second element of the response.

-- 
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/20180921081919.jaygesgfwrolmchi%40kei.


[tryton-dev] Translation for 5.0

2018-09-04 Thread 'Cédric Krier' via tryton-dev
Hi,

The translation terms have been updated on http://pootle.tryton.org/ for
the release 5.0. A second update is planned for the 14th. The end of
translation is scheduled for the 28th at 18:00 CEST.

For the record, I have added a script that automates the task:
http://hg.tryton.org/tryton-tools/rev/c6d07120dd7b
It is configured (on tycho) to run every month so the translation task
will be smoothed during all the development period for the future
releases.

Thanks,
-- 
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/20180904205219.ryqk44seylxyklma%40kei.