Re: [tryton] Re: Get Tryton Stock from Database

2016-03-29 Thread TPH


Am Mittwoch, 23. März 2016 11:55:04 UTC+1 schrieb Cédric Krier:
>
> On 2016-03-23 01:28, TPH wrote: 
> > The reason is very simple. I never have used RPC and don't know how to 
> > start. 
> > 
> > Do I have to install local client package e.g. with pip so I can make 
> > "import tryton.rpc as rpc"? 
> > We do talk about JSON-RPC, doesn't we? Or XML-RPC? 
> > 
> > May you have links? 
> > I found only old ones: 
> > 
> https://code.google.com/archive/p/tryton/wikis/RemoteCalls.wiki#XML-RPC_in_Python
>  
> > 
> > Here are also not many informations: 
> > http://doc.tryton.org/3.2/trytond/doc/ref/rpc.html 
> > 
> > I have interests in doing it a better way. 
>
> Indeed when I said RPC call, I mean to skip the ActiveRecord pattern of 
> proteus and call the method directly from proteus like the method _read 
> does: 
>
> product_proxy = config.get_proxy('product.product') 
> product_proxy.read(ids, fields, context) 
>
> with proper ids, fields and context 
>
> PS: Please don't top-post on this mailing list, see 
> http://groups.tryton.org/netiquette 
> -- 
> Cédric Krier - B2CK SPRL 
> Email/Jabber: cedric...@b2ck.com  
> Tel: +32 472 54 46 59 
> Website: http://www.b2ck.com/


Thank you for the help. This is working fast enought !
Is there any disadvantage in this method?


locations = Location.find([('type', '=', 'storage'), ('parent.name', '=' 
> ,'Main Storage Name')])
> location_ids = [l.id for l in locations]
> config._context['locations'] = location_ids
>
> products = Product.find([('type', '=', 'goods')])
> product_ids = [p.id for p in products]
>
> product_proxy = config.get_proxy('product.product') 
> product_informations = product_proxy.read(product_ids, ["code", 
> "quantity"], config.context) 
>

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/4e93aaa6-508b-4896-ba50-8bf9bd0c13a9%40googlegroups.com.


Re: [tryton] Re: Get Tryton Stock from Database

2016-03-23 Thread Cédric Krier
On 2016-03-23 01:28, TPH wrote:
> The reason is very simple. I never have used RPC and don't know how to 
> start.
> 
> Do I have to install local client package e.g. with pip so I can make 
> "import tryton.rpc as rpc"?
> We do talk about JSON-RPC, doesn't we? Or XML-RPC?
> 
> May you have links?
> I found only old ones:
> https://code.google.com/archive/p/tryton/wikis/RemoteCalls.wiki#XML-RPC_in_Python
> 
> Here are also not many informations:
> http://doc.tryton.org/3.2/trytond/doc/ref/rpc.html
> 
> I have interests in doing it a better way.

Indeed when I said RPC call, I mean to skip the ActiveRecord pattern of
proteus and call the method directly from proteus like the method _read
does:

product_proxy = config.get_proxy('product.product')
product_proxy.read(ids, fields, context)

with proper ids, fields and context

PS: Please don't top-post on this mailing list, see
http://groups.tryton.org/netiquette
-- 
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" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20160323105125.GN28248%40tetsuo.


Re: [tryton] Re: Get Tryton Stock from Database

2016-03-23 Thread TPH
The reason is very simple. I never have used RPC and don't know how to 
start.

Do I have to install local client package e.g. with pip so I can make 
"import tryton.rpc as rpc"?
We do talk about JSON-RPC, doesn't we? Or XML-RPC?

May you have links?
I found only old ones:
https://code.google.com/archive/p/tryton/wikis/RemoteCalls.wiki#XML-RPC_in_Python

Here are also not many informations:
http://doc.tryton.org/3.2/trytond/doc/ref/rpc.html

I have interests in doing it a better way.

thanks and regards




Am Dienstag, 22. März 2016 19:10:05 UTC+1 schrieb Cédric Krier:
>
> On 2016-03-22 09:57, TPH wrote: 
> > 
> > 
> > Am Dienstag, 22. März 2016 13:05:04 UTC+1 schrieb TPH: 
> > > 
> > > Hello, 
> > > 
> > > I just wrote this question in the German group, but I think here are 
> much 
> > > more people. Ill will keep both articles updated. 
> > > 
> > > What is the best way to get product stock directly from database? 
> > > 
> > > For a webshop / ebay sync I need the stock for every product of the 
> > > warehouse. I have tried this with proteus, but this is not fast 
> enough. 
> > > 
> > > So I am searching for an way, to get the actually stock of product on 
> the 
> > > warehouse. 
> > > 
> > > I think I have to use  "stock_location" and "stock_move". Maybe 
> someone 
> > > have already a snipped or can give me some hints. 
> > > 
> > > Thank you very much. 
> > > 
> > > 
> > This is now my first draft to get the stock directly from database, 
> first 
> > only for an specific product. Optimization tips are welcome. I don't 
> have 
> > sub-locations so I don't have to search for other locations then parent 
> = 
> > warehouse. 
>
> I still don't understand why you don't use the quantity on Product. 
> The Tryton code to compute the quantity is quite complex because it has 
> a lot of improvements that you will probably miss by reimplementing it 
> like: using SQL SUM (right order), reuse stock period cache, take care 
> of assignation, take care of the effective date etc. 
>
> If proteus is not fast enough when computing product per product, you 
> can make yourself the RPC call for the list of products. 
>
> -- 
> 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" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/f8f147ff-7f0d-4603-9ae7-5b8ce457b2b0%40googlegroups.com.


Re: [tryton] Re: Get Tryton Stock from Database

2016-03-22 Thread Cédric Krier
On 2016-03-22 09:57, TPH wrote:
> 
> 
> Am Dienstag, 22. März 2016 13:05:04 UTC+1 schrieb TPH:
> >
> > Hello,
> >
> > I just wrote this question in the German group, but I think here are much 
> > more people. Ill will keep both articles updated.
> >
> > What is the best way to get product stock directly from database?
> >
> > For a webshop / ebay sync I need the stock for every product of the 
> > warehouse. I have tried this with proteus, but this is not fast enough.
> >
> > So I am searching for an way, to get the actually stock of product on the 
> > warehouse.
> >
> > I think I have to use  "stock_location" and "stock_move". Maybe someone 
> > have already a snipped or can give me some hints.
> >
> > Thank you very much.
> >
> >
> This is now my first draft to get the stock directly from database, first 
> only for an specific product. Optimization tips are welcome. I don't have 
> sub-locations so I don't have to search for other locations then parent = 
> warehouse.

I still don't understand why you don't use the quantity on Product.
The Tryton code to compute the quantity is quite complex because it has
a lot of improvements that you will probably miss by reimplementing it
like: using SQL SUM (right order), reuse stock period cache, take care
of assignation, take care of the effective date etc.

If proteus is not fast enough when computing product per product, you
can make yourself the RPC call for the list of products.

-- 
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" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20160322180818.GL28248%40tetsuo.