Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3964 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Agu 24
8221
0
Jul 23
1791
0
Jun 21
4541
0
Agu 18
4350
0
Mei 16
6155