Skip to Content
Menú
This question has been flagged
1 Respondre
3808 Vistes

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
Descartar
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
Descartar
Related Posts Respostes Vistes Activitat
2
d’ag. 24
8153
0
de jul. 23
1693
0
de juny 21
4441
0
d’ag. 18
4268
0
de maig 16
6093