Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
4106 Переглядів

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.

    

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
серп. 24
8270
0
лип. 23
1817
0
черв. 21
4559
0
серп. 18
4372
0
трав. 16
6188