How to call custom method in proteus

68 views
Skip to first unread message

Markus Bala

unread,
Oct 19, 2016, 6:54:14 AM10/19/16
to tryton-dev
Hi,

As we know proteus able to work as Tryton client, able to do Find, update, delete, call Button, and Wizard.


Below is to call button in proteus:
s = ShipmentIn.find([('reference','=', ref),('state','=','draft')])
s.click('receive')

My question is how to call a method by using proteus?

Example: (how to call method add in proteus?)

Class StockMove:
    def add(self, val1, val2):
        return val1 + val2



Diego Abad

unread,
Oct 19, 2016, 9:38:01 AM10/19/16
to tryton-dev

You can find a example on account module, see get_origin method,
there is a definition inside   cls.__rpc__.update

http://hg.tryton.org/modules/account/file/tip/move.py#l689

Sergi Almacellas Abellana

unread,
Oct 19, 2016, 9:42:56 AM10/19/16
to tryto...@googlegroups.com
El 19/10/16 a les 15:38, Diego Abad ha escrit:
That's right. You have to add the modules in __rpc__ so they can be
called from the client (and proteus also of course).

But normally is not required to do such things, so I'm wondering what
you are trying to achieve? Maybe rpc is not the right tool to solve the
problem you have.



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

Markus Bala

unread,
Oct 19, 2016, 9:09:51 PM10/19/16
to Tryton
On Wed, Oct 19, 2016 at 8:42 PM, Sergi Almacellas Abellana <se...@koolpi.com> wrote:
El 19/10/16 a les 15:38, Diego Abad ha escrit:
El miércoles, 19 de octubre de 2016, 5:54:14 (UTC-5), Markus Bala escribió:

    Hi,

    As we know proteus able to work as Tryton client, able to do Find,
    update, delete, call Button, and Wizard.


    Below is to call button in proteus:
    s = ShipmentIn.find([('reference','=', ref),('state','=','draft')])
    s.click('receive')

    My question is how to call a method by using proteus?

    Example: (how to call method add in proteus?)

    Class StockMove:
        def add(self, val1, val2):
            return val1 + val2


You can find a example on account module, see get_origin method,
there is a definition inside   cls.__rpc__.update

http://hg.tryton.org/modules/account/file/tip/move.py#l689

Hi Diego,

Thank you. 

After we add tje cls__rpc__.update, how to call this newly method in proteus?
 
is it same as call button action? then how to set the parameter?

s.click('add') --> how to set val1, val2?

That's right. You have to add the modules in __rpc__ so they can be called from the client (and proteus also of course).

But normally is not required to do such things, so I'm wondering what you are trying to achieve? Maybe rpc is not the right tool to solve the problem you have.

Hi Sergi,

I am going to make a small application for Handy Terminal. This application has limited function.
Most of the function are scan the barcode and showing the result on the screen. and Maybe just do simple function such as adding Stock inventory or update the stock qty.

Best Regard, 

--
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/094841f5-b50f-98cd-d059-7bb7febd663d%40koolpi.com.

Reply all
Reply to author
Forward
0 new messages