Skip to Content
Menu
This question has been flagged
1 Reply
3817 Views

I have a method that has parameters as recordset like this

    def some_method(self, picking_id):

        print(picking_id.name)


is there any way to call this method with XML-RPC and add a parameter as recordset? because if I do this.

    

rpc_object.execute(
dbname, uid, user_pw, "delivery.carrier", "some_method", [], [2394]
)

when my method is called picking_id is [2394] and not recordset.

    

Avatar
Discard
Best Answer

Hi Grf,

You can achieve the recordset from the picking id passed to the functions using the orm search/ browse function.

def some_method(self, picking_id):
if picking_id:
picking_id = self.env['stock.picking'].browse(picking_id)
print(picking_id.name)

If you can't directly accept the picking_id and recordset itself, add a try catch statement so that if the recordset is passed as the arguement it'll be accessed as such and of its the picking id itself the orm method will be called.

Eg:

def some_method(self, picking_id):
if picking_id:
try:
print(picking_id.name)
# will return error if the picking_id is not a recordset and the exception case will be run in which the recordset will be fetched from the picking_id
except:
picking_id = self.env['stock.picking'].browse(picking_id)

Regards

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 24
8160
0
Jul 23
1698
0
Jun 21
4451
0
Aug 18
4273
0
May 16
6093