2

Im using Python 3.6 and xmlrpc to unlink all canceled Sale orders in odoo 11 CE but im still getting this error:

odoo11/odoo/api.py", line 690, in call_kw_multi\n    result = method(recs, args, *kwargs)\nTypeError: unlink() missing 1 required positional argument: \'values\'\n'>

ive also tried somehting like:

            , [[sale_id]])

instead of:

            , [sale_id])

heres my code:

import xmlrpc.client

class Odoo():
    def __init__(self):
        self.DATA = "DB"
        self.USER = "USER"
        self.PASS = "PASS"
        self.PORT = "8069"
        self.URL = "http://localhost"
        self.URL_COMMON = "{}:{}/xmlrpc/2/common".format(
            self.URL, self.PORT)
        self.URL_OBJECT = "{}:{}/xmlrpc/2/object".format(
            self.URL, self.PORT)
    def authenticateOdoo(self):
        self.ODOO_COMMON = xmlrpc.client.ServerProxy(self.URL_COMMON)
        self.ODOO_OBJECT = xmlrpc.client.ServerProxy(self.URL_OBJECT)
        self.UID = self.ODOO_COMMON.authenticate(
            self.DATA
            , self.USER
            , self.PASS
            , {})
def main():
    od = Odoo()
    od.authenticateOdoo()
    sale_ids = od.ODOO_OBJECT.execute_kw(od.DATA, od.UID, od.PASS, 'sale.order', 'search', [[("state", "=", "cancel")]])
    od.ODOO_OBJECT.execute_kw(od.DATA, od.UID, od.PASS, 'sale.order', 'unlink', [sale_ids])
    print(od.UID)

if __name__ == '__main__':
    main()
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
Toprocker
  • 38
  • 5
  • Please extract a [mcve] and provide the full error (backtrace) in a readable way. Please also take the [tour] and read [ask]. – Ulrich Eckhardt Oct 31 '19 at 09:37
  • 1
    The Odoo you're trying to call is your Odoo ? And if is it true, have you override the method unlink of sale.order? – jo541 Oct 31 '19 at 10:28
  • im trying to unlink all sale.order by executing python script above for my local running odoo server. what youre meaning with "override"? – Toprocker Oct 31 '19 at 10:33

1 Answers1

1

This error is python error, you called a method that is defined with positional argument values without argument. The problem here the unlink method of a Model don't accept any arguement.

So check your costum addons where did you inherit the sale.order model and you override the unlink method and remove values argument.

Look for this method in your odoo instance and remove values arguement restart the server and everything will be fine.

   _inherit = 'sale.order'

  ......
  ......

   @api.multi
   def unlink(values):
Charif DZ
  • 14,415
  • 3
  • 21
  • 40