Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
4080 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
août 24
8267
0
juil. 23
1814
0
juin 21
4556
0
août 18
4365
0
mai 16
6178