Source code for odoo_xmlrpc_twisted.functions.update_user_address_values
"""Module updates the user address values."""# call the function "get_settings_odoo" to get the parameters# for the logging of the model on the "odoo Webservice API"try:from.get_settings_odooimportget_settings_odooexceptImportError:fromget_settings_odooimportget_settings_odooresult=get_settings_odoo()db=result[0]uid=result[1]password=result[3]models=result[4]
[docs]defupdate_user_address_values(partner_id,address_type,street,street_2,zip_code,city,state,country):""" Function updates the user address values by using the model 'res.partner'. Depending on the type, either a delivery addresse or invoice address will be updated or created if not already existing. """result=Falseifpartner_id!=''andaddress_type!='':# the parent_id is the partner_id so that the reference to the original partner record is givenparent_id=partner_id# set the values for the addressnew_address_values={'type':address_type,'street':street,'street2':street_2,'zip':zip_code,'city':city,'state_id':state,'country_id':country,}# Search for existing addresses of the partner of that typeexisting_address=models.execute_kw(db,uid,password,'res.partner','search',[[['parent_id','=',parent_id],['type','=',address_type]]],)# Update addressifexisting_addressandexisting_address[0]:# Assuming there is only one addressexisting_address_id=existing_address[0]models.execute_kw(db,uid,password,'res.partner','write',[[existing_address_id],new_address_values])else:# If there's no existing address, create a new onenew_address_values['parent_id']=parent_idnew_address_id=models.execute_kw(db,uid,password,'res.partner','create',[new_address_values])result=Truereturn(result)