code: def commit(self):
          
          # Iterate on a new set, as we remove record during iteration from the
          # original one
          for record in set(self.dirty):
              values = {}
              for field in record._values_to_write:
                  if record.id in record._values_to_write[field]:
                      value = record._values_to_write[field].pop(record.id)
                      values[field] = value
                      # Store the value in the '_values' dictionary. This
                      # operation is delegated to each field descriptor as some
                      # values can not be stored "as is" (e.g. magic tuples of
                      # 2many fields need to be converted)
                      record.__class__.__dict__[field].store(record, value)
              record.write(values)
              self.dirty.remove(record)
docs: Commit dirty records to the server. This method is automatically
          called when the `auto_commit` option is set to `True` (default).
          It can be useful to set the former option to `False` to get better
          performance by reducing the number of RPC requests generated.
  
          With `auto_commit` set to `True` (default behaviour), each time a value
          is set on a record field a RPC request is sent to the server to update
          the record:
  
          .. doctest::
  
              >>> user = odoo.env.user
              >>> user.name = "Joe"               # write({'name': "Joe"})
              >>> user.email = "joe@odoo.net"     # write({'email': "joe@odoo.net"})
  
          With `auto_commit` set to `False`, changes on a record are sent all at
          once when calling the :func:`commit` method:
  
          .. doctest::
  
              >>> odoo.config['auto_commit'] = False
              >>> user = odoo.env.user
              >>> user.name = "Joe"
              >>> user.email = "joe@odoo.net"
              >>> user in odoo.env.dirty
              True
              >>> odoo.env.commit()   # write({'name': "Joe", 'email': "joe@odoo.net"})
              >>> user in odoo.env.dirty
              False
  
          Only one RPC request is generated in the last case.