How to build and use plugins in the client

124 views
Skip to first unread message

edbo....@gmail.com

unread,
Dec 13, 2017, 4:20:06 AM12/13/17
to tryton-dev
Hello,

We have an Altek TTP-343 labelprinter and want to print labels which are created by Tryton. We have created an odt-report with the dimensions of the label, print it to a PDF and then to the labelprinter. Unfortunally printing didn't work and even printing from other programs failed. Except ofcourse the labelprinter software itself.

The nice thing about the printing software is that we can use Python to start the programm in the background, open labels, change variables and print the label. For us this is the way to go.

So there are two ways to print the labels:
1. create a Python-application with gui which login to Tryton, get the data and userinput and print the label
2. create a plugin in the Tryton-client to print the label

Our preferred way it to use 2. because less work needs to be done on the gui-side and there is one application which does all the work.

But the question remains: Is it possible? and if so, how can we execute a plugin-command from the client? So a user clicks on the (new?) print button and in the background the labelsoftware is started, a predefined label with variables is opened (just like a odt-report) and filled in with the data the plugin got from the Tryton-client.




Cédric Krier

unread,
Dec 13, 2017, 4:40:06 AM12/13/17
to tryton-dev
On 2017-12-13 01:13, edbo....@gmail.com wrote:
> But the question remains: Is it possible?

Yes probably. Plugins are kind of wizard that run on client side.

> and if so, how can we execute a plugin-command from the client?

The plugins appears in the action menu of the form.
The plugin can decide on which model to appear thanks to the
'get_plugins(model)' method.

> So a user clicks on the (new?) print button and in the background the
> labelsoftware is started, a predefined label with variables is opened
> (just like a odt-report) and filled in with the data the plugin got
> from the Tryton-client.

I guess you will have to retrieve the report using RPC calls and send it
to the printer.

But indeed you may be interested by https://bugs.tryton.org/issue6999, I
think we will allow to customize the command to do direct printing. In
this case, you could write a script that will recognize the label and
send it to the right printer.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

edbo....@gmail.com

unread,
Dec 13, 2017, 7:27:39 AM12/13/17
to tryton-dev
On Wednesday, 13 December 2017 10:40:06 UTC+1, Cédric Krier wrote:
> On 2017-12-13 01:13, edbo wrote:
> > But the question remains: Is it possible?
>
> Yes probably. Plugins are kind of wizard that run on client side.

This is very interesting, it basically means that you can read data from a COM-port and put that data into the database through the Tryton-client?.


> > and if so, how can we execute a plugin-command from the client?
>
> The plugins appears in the action menu of the form.
> The plugin can decide on which model to appear thanks to the
> 'get_plugins(model)' method.

I looked into the translation-plugin and think I get an idea on how to get it working.


> > So a user clicks on the (new?) print button and in the background the
> > labelsoftware is started, a predefined label with variables is opened
> > (just like a odt-report) and filled in with the data the plugin got
> > from the Tryton-client.
>
> I guess you will have to retrieve the report using RPC calls and send it
> to the printer.

We are using a programm called NiceLabel to create a label with several variables and store it somewhere. Then we start the Tryton-client and select a set of products (first or in the "wizard") en click on "print". Then in the background (using Python) we start NiceLabel, open the created label en replace the variables with the data we get from Tryton-database. Next we print the label. It means that Tryton doesn't do anything with the label other then give the data for the label.


> But indeed you may be interested by https://bugs.tryton.org/issue6999, I
> think we will allow to customize the command to do direct printing. In
> this case, you could write a script that will recognize the label and
> send it to the right printer.

The label-format is binary and you need the labelsoftware to read that. So Tryton-report-engine cannot do anything with it.

Cédric Krier

unread,
Dec 13, 2017, 7:50:08 AM12/13/17
to tryton-dev
On 2017-12-13 04:11, edbo....@gmail.com wrote:
> > But indeed you may be interested by https://bugs.tryton.org/issue6999, I
> > think we will allow to customize the command to do direct printing. In
> > this case, you could write a script that will recognize the label and
> > send it to the right printer.
>
> The label-format is binary and you need the labelsoftware to read
> that. So Tryton-report-engine cannot do anything with it.

The report engine is capable of generating binary data.

edbo....@gmail.com

unread,
Dec 13, 2017, 3:54:57 PM12/13/17
to tryton-dev
On Wednesday, 13 December 2017 10:40:06 UTC+1, Cédric Krier wrote:
> On 2017-12-13 01:13, wrote:
> > But the question remains: Is it possible?
>
> Yes probably. Plugins are kind of wizard that run on client side.

I got the first part working, I got the data from the database. Now I want to put that data into a label. For that part I need the win32com.client library from Python. But importing failed (I'm working on Windows 10). So, do I need to rebuild the whole client to get this working?

Cédric Krier

unread,
Dec 13, 2017, 6:10:06 PM12/13/17
to tryton-dev
On 2017-12-13 12:54, edbo....@gmail.com wrote:
> On Wednesday, 13 December 2017 10:40:06 UTC+1, Cédric Krier wrote:
> > On 2017-12-13 01:13, wrote:
> > > But the question remains: Is it possible?
> >
> > Yes probably. Plugins are kind of wizard that run on client side.
>
> I got the first part working, I got the data from the database. Now I
> want to put that data into a label. For that part I need the
> win32com.client library from Python. But importing failed (I'm working
> on Windows 10). So, do I need to rebuild the whole client to get this
> working?

You can not add new dependencies except if you bundle them.

edbo....@gmail.com

unread,
Dec 14, 2017, 2:48:39 AM12/14/17
to tryton-dev
On Thursday, 14 December 2017 00:10:06 UTC+1, Cédric Krier wrote:
> On 2017-12-13 12:54, edbo wrote:
> > On Wednesday, 13 December 2017 10:40:06 UTC+1, Cédric Krier wrote:
> > > On 2017-12-13 01:13, wrote:
> > > > But the question remains: Is it possible?
> > >
> > > Yes probably. Plugins are kind of wizard that run on client side.
> >
> > I got the first part working, I got the data from the database. Now I
> > want to put that data into a label. For that part I need the
> > win32com.client library from Python. But importing failed (I'm working
> > on Windows 10). So, do I need to rebuild the whole client to get this
> > working?
>
> You can not add new dependencies except if you bundle them.

Does this mean that I have to rebuild the client? It's not a problem, just want to know if this is the case. So I can ask my IT-department to install the needed build tools.

Cédric Krier

unread,
Dec 14, 2017, 8:35:06 AM12/14/17
to tryton-dev
Not necessary but your plugin may contains all the needed libraries.

Oscar Andres Alvarez Montero

unread,
Dec 14, 2017, 8:49:48 AM12/14/17
to tryto...@googlegroups.com, tryton-dev
Hi
Here a plug in for create csv file opened with Glabels (Linux and works in TTP247)


You need this dependence

 
Cheers
--
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/20171214133118.GF10740%40kei.

edbo....@gmail.com

unread,
Dec 15, 2017, 9:39:08 AM12/15/17
to tryton-dev
On Thursday, 14 December 2017 14:49:48 UTC+1, oscar_alvarez wrote:
> HiHere a plug in for create csv file opened with Glabels (Linux and works in TTP247)
>
>
> https://bitbucket.org/presik/plugin_stock_glabels

Thanks! I've used your idea to get everything working. Because I'm on windows and our labels are created with the NiceLabel software, I had to use that. It is a real pain in the back to get GTK and it modules installed on windows and get a build system running, so I dropped that and moved to execute an external Python-script.
So what I did was:
1. Create a new label-report with plain text as layout. The content of that report is JSON-like, so when the report is created I get a JSON-string.
2. Create the plugin which prints the report, based on the selected products
3. Store the returned report-data into a temporary file
4. Execute an external Python-script

The external script then:
1. Import the win32com.client
2. Reads the report-data which is a JSON-string from the stored file
3. Starts NiceLabel in the background (win32com.client is needed here)
4. Asks NiceLabel to open a certain label
5. Asks NiceLabel to fill in the different variables and print the label
6. Closes NiceLabel and quit

For the external script I used http://www.primozic.net/nl/how-can-i-automate-nicelabel-from-a-scripting-language-like-vbscript-or-python/



Eduardo Ruiz Rodriguez

unread,
Feb 23, 2018, 3:50:06 AM2/23/18
to tryton-dev
El viernes, 15 de diciembre de 2017, 15:39:08 (UTC+1), edbo....@gmail.com escribió:
> So what I did was:
> 1. Create a new label-report with plain text as layout. The content of that report is JSON-like, so when the report is created I get a JSON-string.

Hello, I'm stucked in that point. How did you get that report (text/json-like..)?. The only report type I can generate is odt/ods. What is the template format you applied for it?

Eduardo

Sergi Almacellas Abellana

unread,
Feb 23, 2018, 4:06:07 AM2/23/18
to tryto...@googlegroups.com
El 22/02/18 a les 20:10, Eduardo Ruiz Rodriguez ha escrit:
Hi Eduardo,

You can use the 'txt' template extension to generate a report from txt
format. Then you should upload the template file and declare using the
relatorio sintax as usual. It's the same as we use for email
notification templates [1], but using the txt template extension.

Hope it helps.


[1]
http://hg.tryton.org/modules/web_user/file/4153faf25a3e/email_validation.html

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Eduardo Ruiz Rodriguez

unread,
Feb 23, 2018, 4:40:06 AM2/23/18
to tryton-dev
El viernes, 23 de febrero de 2018, 10:06:07 (UTC+1), Sergi Almacellas Abellana escribió:
> El 22/02/18 a les 20:10, Eduardo Ruiz Rodriguez ha escrit:
> > El viernes, 15 de diciembre de 2017, 15:39:08 (UTC+1), edbo....@gmail.com escribió:
> >> So what I did was:
> >> 1. Create a new label-report with plain text as layout. The content of that report is JSON-like, so when the report is created I get a JSON-string.
> > Hello, I'm stucked in that point. How did you get that report (text/json-like..)?. The only report type I can generate is odt/ods. What is the template format you applied for it?
> Hi Eduardo,
>
> You can use the 'txt' template extension to generate a report from txt
> format. Then you should upload the template file and declare using the
> relatorio sintax as usual. It's the same as we use for email
> notification templates [1], but using the txt template extension.

Yes, it works, thank you very much. I was dealing with the extension field (instead of template extension).

Regards,

Eduardo
Reply all
Reply to author
Forward
0 new messages