[tryton-dev] Add party name to a list of orderlines

2018-05-16 Thread edbo . design
Last weekend we finally migrated from OpenERP v5 to Tryton and are already 
happy with the system. However during working with Tryton colleagues discovered 
some issues which are not available in Tryton (yet). So we decided to implement 
them.

One of the issues is that they searched a lot in order-lines (sale, invoice, 
purchase) and filter them on party or on product or on both. In OpenERP this 
was already there and they got used to it to get easy an overview what a client 
has both in the past and for which price.

Creating a new list in Tryton isn't hard, but we couldn't find an example on 
how to get the party name also in the list of orderlines. We already created a 
very simple orderline tree:









But we want also a field

in the tree with the party name. The part name isn't available on the 
orderline, but in the parent order. Adding sale.party or something didn't work. 
Is this possible without adding an extra function-field? and how can this be 
solved?


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/c72dacab-a047-4b58-840a-d8def202668c%40googlegroups.com.


Re: [tryton-dev] account_statement import modules

2018-04-11 Thread edbo . design
On Wednesday, 11 April 2018 12:37:53 UTC+2, Sergi Almacellas Abellana  wrote:
> 
> Maybe you can propose another discussion explaining why you use the
> extra fuctionality to see if we can find a generic solution that works
> for most people.

Should I use discuss for that? I think it's better reading then email.


> If you have not contributed any patch to tryton probably it's better to
> pick an easy issue first to get familiar with the process. Here is the
> list of easy issues:
> 
> https://bugs.tryton.org/issue?status=-1,1,2,3,4,5,6,7&@sort=-activity&@search_text=&@columns=id,activity,component,title,assignedto,status&@dispname=Show%20Easy=27&@group=priority&@filter=status,keyword&@pagesize=50&@startwith=0

Ah, ok there are some very easy issues. I will try some to get familiar with 
the process.


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

-- 
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/6899a520-51b4-4576-baf2-791a27246736%40googlegroups.com.


[tryton-dev] account_statement import modules

2018-04-10 Thread edbo . design
I'm just wondering. We took the account_statement_coda module to build the 
account_statement_mt940 module. The module just import the statement and 
creates the origins, but there are no lines created. So we still have to 
manually add the statement lines?

We have now an almost working module for importing mt940 statements (except 
creating / filling a dict with the information). Because we want minimal work, 
we have also extended the import wizard with a default payable and receivable 
account and the statement lines are also created and linked to the origin.

So we can do two things: 
- Keep this module as it works perfectly for us
- Split the module into a basic version as the other ones and create our own to 
add the extra functionality. The basic version can then be added to the set of 
default modules if wanted. But as not being a full-time developer, but it's 
rather a hobby, I have no experience with testing, or creating installable new 
python-packages etc. If anybody can help me out here with some extra 
explanation of http://www.tryton.org/how-to-contribute.html would be very 
welcome.

-- 
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/69b47eb8-d8b4-4538-aa2b-646c436cd099%40googlegroups.com.


Re: [tryton-dev] How to build and use plugins in the client

2017-12-15 Thread edbo . design
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/



-- 
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/7d4dc08c-2b94-4df7-937f-73cb19871be9%40googlegroups.com.


Re: [tryton-dev] How to build and use plugins in the client

2017-12-13 Thread edbo . design
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.

-- 
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/4af3f542-0e75-4d33-af30-03d6d80b6c6b%40googlegroups.com.


Re: [tryton-dev] How to build and use plugins in the client

2017-12-13 Thread edbo . design
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?


> 
> > 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.
> 

-- 
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/23b7268b-7acf-450b-a588-1bc9467f9b56%40googlegroups.com.


Re: [tryton-dev] How to build and use plugins in the client

2017-12-13 Thread edbo . design
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.

-- 
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/b7adc972-cc00-4467-9907-5797c5cfd2e7%40googlegroups.com.


[tryton-dev] How to build and use plugins in the client

2017-12-13 Thread edbo . design
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.




-- 
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/91fa3953-f46c-4594-b53b-266b1fe679a6%40googlegroups.com.


Re: [tryton-dev] Adding images in reports

2017-12-08 Thread edbo . design
On Friday, 8 December 2017 02:18:32 UTC+1, edbo@gmail.com  wrote:
> On Thursday, 7 December 2017 14:02:49 UTC+1, Sergi Almacellas Abellana  wrote:
> > El 07/12/17 a les 13:35, ha escrit:
> > > Hello All,
> > > 
> > > We want to add dynamically created images to a report, but we can't get 
> > > it working :-( . It's a generated 2D-barcode based on a product code. We 
> > > added a frame an added on tab Options as name image: (record.barcode, 
> > > 'image/png'), but we only get a strange line and not a 2D-barcode.
> > > We also added a binary-field to the product to see if that was going to 
> > > work, but we get the same result.
> > > 
> > > Does anybody got this working and can you provide an example?
> > 
> > Which library are you using to generate the barcode?
> 
> Because we want 2D-barcode (QR-code or Datamatrix) we cannot use pyBarcode. 
> We use treepoem [1] which is a wrapper around and postscript barcode generator
> 
> [1] https://github.com/YPlan/treepoem
> 
> > 
> > We are using pyBarcode without problems. Here is the relevant code:
> > 
> > import barcode 
> > 
> > from barcode.writer import ImageWriter> 
> > class Product:
> >  barcode = fields.Function(fields.Binary("Barcode",  
> >  'get_barcode')
> >  def get_barcode(self, name): 
> >  fd = BytesIO() 
> >  barcode.generate( 
> >  'ean13', self.code[:12].zfill(12), 
> >  writer=ImageWriter(), output=fd) 
> >  fd.seek(0) 
> >  return fields.Binary.cast(fd.read())
> > This should show without problems on the report.
> 
> I've tried something similar with treepoem:
> 
> def get_2dbarcode(self, name):
> fd = io.BytesIO()
> # generate 2D-barcode
> image = treepoem.generate_barcode(
> 'datamatrix',
> "THA7",  # normally this will be dynamic
> {},
> )
> image.save(fd, format="png")
> fd.seek(0)
> return fields.Binary.cast(fd.read())
> 
> But no luck.

Got, it. It seems that you have to anchor the frame to a paragraph and not to 
the page or character. So, to sum up:
 
 # import the libraries
 import io
 import treepoem

 # add a field to your model which generates the barcode
 barcode = fields.Function(fields.Binary("Barcode", 'get_2dbarcode')

 # define your function which creates the barcode
 def get_2dbarcode(self, name):
 fd = io.BytesIO()
 # generate 2D-barcode
 image = treepoem.generate_barcode(
 'datamatrix',
 self.code,
 {},
 )
 image.save(fd, format="png")
 fd.seek(0)
 return fields.Binary.cast(fd.read())

And in your report:
Add a frame and make sure:
1. Anchor is on paragraph (tab "Type")
2. Name is (, "image/png") (tab "Options")

I'm going to remove the field, because the code is auto-generated on first save 
action and never changes.

-- 
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/f7d52ca2-981c-403f-bd4f-6a2a1f101a2f%40googlegroups.com.


Re: [tryton-dev] Adding images in reports

2017-12-07 Thread edbo . design
On Thursday, 7 December 2017 14:02:49 UTC+1, Sergi Almacellas Abellana  wrote:
> El 07/12/17 a les 13:35, ha escrit:
> > Hello All,
> > 
> > We want to add dynamically created images to a report, but we can't get it 
> > working :-( . It's a generated 2D-barcode based on a product code. We added 
> > a frame an added on tab Options as name image: (record.barcode, 
> > 'image/png'), but we only get a strange line and not a 2D-barcode.
> > We also added a binary-field to the product to see if that was going to 
> > work, but we get the same result.
> > 
> > Does anybody got this working and can you provide an example?
> 
> Which library are you using to generate the barcode?

Because we want 2D-barcode (QR-code or Datamatrix) we cannot use pyBarcode. We 
use treepoem [1] which is a wrapper around and postscript barcode generator

[1] https://github.com/YPlan/treepoem

> 
> We are using pyBarcode without problems. Here is the relevant code:
> 
> import barcode 
> 
> from barcode.writer import ImageWriter> 
> class Product:
>  barcode = fields.Function(fields.Binary("Barcode",  
>  'get_barcode')
>  def get_barcode(self, name): 
>  fd = BytesIO() 
>  barcode.generate( 
>  'ean13', self.code[:12].zfill(12), 
>  writer=ImageWriter(), output=fd) 
>  fd.seek(0) 
>  return fields.Binary.cast(fd.read())
> This should show without problems on the report.

I've tried something similar with treepoem:

def get_2dbarcode(self, name):
fd = io.BytesIO()
# generate 2D-barcode
image = treepoem.generate_barcode(
'datamatrix',
"THA7",  # normally this will be dynamic
{},
)
image.save(fd, format="png")
fd.seek(0)
return fields.Binary.cast(fd.read())

But no luck.

-- 
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/3a516ac9-5c9f-4dec-8722-dd6f837c59c7%40googlegroups.com.


[tryton-dev] Adding images in reports

2017-12-07 Thread edbo . design
Hello All,

We want to add dynamically created images to a report, but we can't get it 
working :-( . It's a generated 2D-barcode based on a product code. We added a 
frame an added on tab Options as name image: (record.barcode, 'image/png'), but 
we only get a strange line and not a 2D-barcode.
We also added a binary-field to the product to see if that was going to work, 
but we get the same result.

Does anybody got this working and can you provide an example?

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/3f0f450a-086b-45f8-8d63-59446cd71a17%40googlegroups.com.


[tryton-dev] Historize only on certain workflow transaction

2017-03-15 Thread edbo . design
I'm working on a review and revise module. This module have a workflow with 
the states "draft" -> "review" -> "released" . The data can only be edited 
when in state "draft". When in state "released" and a user wants to change 
it, the state goes back to "draft". But in that transaction (from 
"released" to "draft") I want to store a copy of the data. 

Instead of writing my own history table and functionality I want to use the 
standard _history = true . But then I get on all write-actions a new copy 
in the history-table.

What are the (other) possibilities? 


Regards,

Ed

-- 
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/4f6e1c6d-b5c9-4fb2-b9be-c8a4e0935114%40googlegroups.com.


Re: [tryton-dev] Re: Testing new windows build

2016-09-22 Thread edbo . design


On Wednesday, 21 September 2016 15:30:03 UTC+2, Cédric Krier wrote:
>
> On 2016-09-21 05:51, edbo@gmail.com  wrote: 
> > Ah, ok. I tried it on version 4.0. Is it possible to build a version for 
> > 4.0? 
>
> No this is development feature. 
>
> > Or have a demo4.1.tryton.org up just for testing? 
>
> It will be too much work to keep up to date a server on the development 
> branch because it changes almost every day. 
>
> I didn't mean to keep it up and running, but just for testing the client. 
But nevertheless, I setted up my own testserver, created a new database and 
installed some modules. After that I added some products and added some 
production-orders.

> - installation is working 

Installation on Windows 7 x86_64 works OK. When installed on one system, 
you can grab the whole directory and copy it to another machine and it will 
still work.

> - client start 

Client starts without any glitch

> - can open form, list, graph and calendar views 

No problems here

> - uninstallation is working

The whole directory is removed including the shortcuts.

-- 
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/e596f861-c911-4302-b758-e3875603cf63%40googlegroups.com.


Re: [tryton-dev] Re: Testing new windows build

2016-09-21 Thread edbo . design


On Wednesday, 21 September 2016 13:37:15 UTC+2, Sergi Almacellas Abellana 
wrote:
>
> El 21/09/16 a les 12:14, edbo@gmail.com  ha escrit: 
> > 
> > 
> > - client start 
> > 
> > 
> > Client starts correctly, but I can't login into any database. The client 
> > keeps saying "Incompatible server" 
> Which trytond version are you using? 
>
> The compiled version is 4.1 so you must use a 4.1 trytond version which 
> is the latest development version (not yet released). 
>

Ah, ok. I tried it on version 4.0. Is it possible to build a version for 
4.0? Or have a demo4.1.tryton.org up just for testing?

 

-- 
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/480c9db3-077c-4bef-8eca-f4a684feb1a8%40googlegroups.com.


[tryton-dev] Re: Testing new windows build

2016-09-21 Thread edbo . design
On Tuesday, 20 September 2016 18:35:03 UTC+2, Cédric Krier wrote:
>
> Hi, 
>
> Working on issue5085, I would like to have feedback from the new setup 
> posted there: https://bugs.tryton.org/msg28864 
> What is important to test is: 
>
> - installation is working 
>

Installation on windows 7 X86_64 works ok

 

> - client start 
>

Client starts correctly, but I can't login into any database. The client 
keeps saying "Incompatible server"
 

- can open form, list, graph and calendar views 
> - uninstallation is working 
>
> It will be great to have report for the different Windows available. 
>
> Thanks, 
> -- 
> Cédric Krier - B2CK SPRL 
> Email/Jabber: cedric...@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/e9e82117-399a-489d-b6b4-09645be17481%40googlegroups.com.


[tryton-dev] Re: RFC: User Application

2016-09-05 Thread edbo . design


On Thursday, 1 September 2016 10:10:03 UTC+2, Cédric Krier wrote:
>
> Hi, 
>
> I would like to have feedbacks on this topic and implementation: 
> https://discuss.tryton.org/t/support-user-application/183 
>
> I think it could be a major improvement for Tryton and allow to create 
> "killer features". 
>

I'm also liking this. But instead putting it in __init__.py is it possible 
to put it in a separate file? e.g. webextension.py

 

> I would like also to have feedback on Chronos especially the design 
> because the goal is to be very fast at timesheet encoding. 
>
>
I think it's out of scope, but for javascript I'm using EmberJS as my 
framework, it's a bit like Tryton :-) : framework and modules (in EmberJS 
called components). In EmberJS an adapter which is keen enough to connect 
to Tryton and talks http://jsonapi.org/ is already their.

 

> Thanks, 
> -- 
> Cédric Krier - B2CK SPRL 
> Email/Jabber: cedric...@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/6334c148-fe15-4893-a424-18906d65537a%40googlegroups.com.


Re: [tryton-dev] Using of Model. __post_setup__

2016-05-06 Thread edbo . design


On Friday, May 6, 2016 at 3:55:03 PM UTC+2, Cédric Krier wrote:
>
> On 2016-05-06 05:41, edbo@gmail.com  wrote: 
> > Hello, 
> > 
> > I think I'm using the Model. __post_setup__ class not correctly, but how 
> > I'm using it is working in Tryton-3.6.5 but not in Tryton-4.0.0 and 
> maybe 
> > there are other ways to do it. 
> > 
> > What I'm trying to do, is to build an IOT-platform into Tryton where 
> agents 
> > can connect to and update several values they allowed to change. To 
> > minimize database-queries and updating database-records or inserting new 
> > ones, I build a dict which lives in memory. The agents send the new 
> values 
> > in and Tryton will update the values in the dict, and a cron-job will 
> > archive those values into the database at certain moments. The new 
> values 
> > are also used to trigger events like sending mail, executing scripts 
> etc. 
> > 
> > To create the dict in memory I'm using the __post_setup__ class to 
> populate 
> > the dict with the several values. 
> > 
> > @classmethod 
> > def __post_setup__(cls): 
> > super(Trigger, cls).__post_setup__() 
> > 
> > # get the triggers 
> > triggers = cls.search( [('id', '>', 0 )] ) 
> > 
> > if triggers: 
> > # Build the datastructure in memory 
> > for trigger in cls.browse( triggers ): 
> > 
> > sensors = [] 
> > on_activate = [] 
> > on_deactivate = [] 
> > 
> > # get the sensors and conditions 
> > for sensor in trigger.sensor: 
> > if len(sensor.condition) > 2: 
> > sensors.append({ 
> > "id": sensor.id, 
> > "sensor": sensor.sensor.id, 
> > "condition" : sensor.condition, 
> > }) 
> > 
> > # only add the trigger to the list when there are 
> > # sensors and conditions 
> > if len(sensors): 
> > MEM_TRIGGERS.append({ 
> > "id" : trigger.id, 
> > "name"   : trigger.name, 
> > "sequence"   : trigger.sequence, 
> > "min_delay"  : trigger.minimum_time_delay, 
> > "min_active" : trigger.minimum_time_active, 
> > "when"   : datetime.datetime.utcnow(), 
> > "activated"  : trigger.activated, 
> > "enabled": trigger.enabled, 
> > "sensors": sensors 
> > }) 
> > 
> > I have extended the ir.trigger with 
> > sensor = fields.One2Many('iot.triggersensors', 'trigger', 'Sensor') 
> > 
> > And the iot.triggersensors 
> > 
> > class TriggerSensor(ModelSQL, ModelView): 
> > "TriggerSensor" 
> > __name__ = 'iot.triggersensors' 
> > 
> > name = fields.Char('Name') 
> > trigger = fields.Many2One('ir.trigger', 'Trigger', 
> > domain=[('on_sensor','=',True)], ondelete='CASCADE') 
> > condition = fields.Char('Condition') 
> > 
> > 
> > This is working in Tryton version 3.65, but in 4.0.0 I get 
> > 
> >   File "/home/ed/ERP/iot/trytond-4.0.0/trytond/pool.py", line 229, in 
> setup 
> > cls.__post_setup__() 
> >   File "/home/ed/ERP/iot/trytond-4.0.0/trytond/modules/iot/iot.py", line 
> > 1173, in __post_setup__ 
> > for sensor in trigger.sensor: 
> >   File "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/modelstorage.py", 
> line 
> > 1352, in __getattr__ 
> > read_data = self.read(list(ids), ffields.keys()) 
> >   File "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/modelsql.py", line 
> > 744, in read 
> > getter_result = field.get(ids, cls, fname, values=result) 
> >   File 
> "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/fields/one2many.py", 
> > line 86, in get 
> > field = Relation._fields[self.field] 
> > AttributeError: type object 'iot.triggersensors' has no attribute 
> '_fields' 
> > 
> > So my question is, are there other methods to accomplish this (after the 
> > Tryton-server is started create a dict into memory)? or is this a bug in 
> > Tryton-4.0.0? 
>
> It is definitely not a bug in 4.0. Your code was working before by 
> chance. The ORM should never be used during the initialization of the 
> Pool. Your code doesn't work any more probably because of the 
> optimization of the pool initialization. 
>
> Hmm, ok, but the documentation says "Setup the class AFTER added into the 
trytond.pool.Pool". So IMO this means that the class is added into the pool 
and then __post_setup__ will be called.

 

> Also you should be careful with global variable, your structure is 
> probably not thread-safe. 
>

I don't use global. In my iot.py I have
MEM_SENSORS = {}  # store sensor values in memory

just 

[tryton-dev] Using of Model. __post_setup__

2016-05-06 Thread edbo . design
Hello,

I think I'm using the Model. __post_setup__ class not correctly, but how 
I'm using it is working in Tryton-3.6.5 but not in Tryton-4.0.0 and maybe 
there are other ways to do it.

What I'm trying to do, is to build an IOT-platform into Tryton where agents 
can connect to and update several values they allowed to change. To 
minimize database-queries and updating database-records or inserting new 
ones, I build a dict which lives in memory. The agents send the new values 
in and Tryton will update the values in the dict, and a cron-job will 
archive those values into the database at certain moments. The new values 
are also used to trigger events like sending mail, executing scripts etc.

To create the dict in memory I'm using the __post_setup__ class to populate 
the dict with the several values.

@classmethod
def __post_setup__(cls):
super(Trigger, cls).__post_setup__()

# get the triggers
triggers = cls.search( [('id', '>', 0 )] )

if triggers:
# Build the datastructure in memory
for trigger in cls.browse( triggers ):

sensors = []
on_activate = []
on_deactivate = []

# get the sensors and conditions
for sensor in trigger.sensor:
if len(sensor.condition) > 2:
sensors.append({
"id": sensor.id,
"sensor": sensor.sensor.id,
"condition" : sensor.condition,
})

# only add the trigger to the list when there are 
# sensors and conditions
if len(sensors):
MEM_TRIGGERS.append({
"id" : trigger.id,
"name"   : trigger.name,
"sequence"   : trigger.sequence,
"min_delay"  : trigger.minimum_time_delay,
"min_active" : trigger.minimum_time_active,
"when"   : datetime.datetime.utcnow(),
"activated"  : trigger.activated,
"enabled": trigger.enabled,
"sensors": sensors
})

I have extended the ir.trigger with 
sensor = fields.One2Many('iot.triggersensors', 'trigger', 'Sensor') 

And the iot.triggersensors

class TriggerSensor(ModelSQL, ModelView):
"TriggerSensor"
__name__ = 'iot.triggersensors'

name = fields.Char('Name')
trigger = fields.Many2One('ir.trigger', 'Trigger', 
domain=[('on_sensor','=',True)], ondelete='CASCADE')
condition = fields.Char('Condition')


This is working in Tryton version 3.65, but in 4.0.0 I get

  File "/home/ed/ERP/iot/trytond-4.0.0/trytond/pool.py", line 229, in setup
cls.__post_setup__()
  File "/home/ed/ERP/iot/trytond-4.0.0/trytond/modules/iot/iot.py", line 
1173, in __post_setup__
for sensor in trigger.sensor:
  File "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/modelstorage.py", line 
1352, in __getattr__
read_data = self.read(list(ids), ffields.keys())
  File "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/modelsql.py", line 
744, in read
getter_result = field.get(ids, cls, fname, values=result)
  File "/home/ed/ERP/iot/trytond-4.0.0/trytond/model/fields/one2many.py", 
line 86, in get
field = Relation._fields[self.field]
AttributeError: type object 'iot.triggersensors' has no attribute '_fields'

So my question is, are there other methods to accomplish this (after the 
Tryton-server is started create a dict into memory)? or is this a bug in 
Tryton-4.0.0?



Regards,

Ed

-- 
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/fa7af54a-45a9-46d9-aad8-c0a9b3792e4c%40googlegroups.com.


Re: [tryton-dev] Stuck with a button

2013-08-16 Thread edbo . design
On Thursday, August 15, 2013 9:11:05 PM UTC+2, Giovanni wrote:


 'requested': {
'invisible': And(Bool(~Eval('requesting'))
  , (Eval('state') == 'free')  
   ),
 },

 'invisible' means just that. From what is written here, the button  will 
 be invisible when
 'state' is 'free' and 'requesting' is checked.

 What you want should be something like :
 'invisible': Not(And(~~Eval('requesting), Eval('state') == 'free'))


Thanks! That's working like I wanted. The button is now only shown when the 
state is free and the checkbox requesting is checked.

Ed



[tryton-dev] Stuck with a button

2013-08-15 Thread edbo . design
Hello,

In my module I have created some fields and some buttons. It all works ok, 
but I want to make a button visible based on two fields. One field is the 
state, which is a selection, the second is a boolean. The button should 
only be shown when the state is free AND the boolean is true.

So I created the button:

'requested': {
   'invisible': And(Bool(~Eval('requesting'))
 , (Eval('state') == 'free')  
  ),
},

Unfortunately the button shows up in all other states. Checking and 
unchecking works only when the state is free. I tried other things as 
well with Equal, Not and Or, but with the same result or worse.

Can anybody shine a light on this?, I'm stuck.

Thanks,

Ed




Re: [tryton-dev] Add units to product attributes

2013-05-10 Thread edbo . design


On Wednesday, May 8, 2013 11:42:26 PM UTC+2, Cédric Krier wrote:

 On 08/05/13 11:42 -0700, edbo@gmail.com javascript: wrote: 
  We are very happy with the product_attribute module. It work quite well. 
  The only thing we actually miss is the possibility to add a unit to the 
  attribute, to make it clear to the user what we mean. Otherwise it is 
  possible that the person reads the value in meters, while we meant 
  millimetre.  Now we can add it to the string, but it would be nice 
 to 
  have it separated. 
  
  Is it possible to add a unit-field to the attributes? 

 We choosen to not implement any foreign field in the Dict fields because 
 we can not ensure the integrity. 
 So it is not possible to add a Many2One to unit as we generaly do in 
 Tryton. 


It would be nice to have, but an extra field in which you can type the unit 
should be possible?


 The new prefix/suffix could be implemented to the Dict schema definition 
 as solution. 

 Can you explain this a little more?




-- 
 Cédric Krier 

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



[tryton-dev] Re: Statement Import

2013-03-29 Thread edbo . design
Hi all,

We are running OpenERP v5 and are investigating if we are going to move to 
Tryton or stay with OpenERP. Because we are a reseller we have always a lot 
of statements which we want to import automatically, so we build an 
import-framework our self for OpenERP and released it to the community. 
Edusense, a Dutch company has completely changed the import-framework, and 
it works much better now. IMHO Tryton needs such a module for importing 
statements. See http://www.edusense.nl/index.php/en/downloads for the 
source-code

Regards,

Ed