Search code examples
pythonodooodoo-13

How to update the state of a sales order in Odoo 13 via api (Python)?


I am trying to update the sales order within Odoo 13 via the API

 so_id = models.execute_kw(db, uid, password, 'sales order', 'write'[{
          'name': 'order name"
           #update state 
        }])

This however does not work. Per the documentation https://www.odoo.com/documentation/13.0/webservices/odoo.html we should user the write method to update records, and I have done so but still can't figure out the issue. When I attempt to write to Odoo it just returns a 500 error.


Solution

  • Figured it out. For people looking at how to update sales records, you have to include the ID of the sales record.

         so_id = models.execute_kw(db, uid, password, 'sale.order',
             'write', [id], [{'state': new_state_value}])