i write a python code. i want when hubspot_update_response is 200 the
hubspot id is store into odoo. how can i get this..?
i was try but i am getting following error.. "ERROR: could not serialize
access due to concurrent update"
here is my code..
if hubspot_search_data["total"] > 0:
# Contact already exists, update instead of creating a new one
hubspot_contact = {
"id": hubspot_search_data["results"][0]["id"],
"properties": {
"firstname": odoo_contact["name"],
"phone": odoo_contact["phone"],
"hubspot_hash": odoo_hash,
}
}
update_data = {
"inputs": [hubspot_contact]
}
hubspot_update_url = f"{hubspot_headers['base_url']}/crm/v3/objects/{hubspot_headers['model_name']}/batch/update"
hubspot_update_response = requests.post(hubspot_update_url, headers=hubspot_headers,
json=update_data)
if hubspot_update_response.status_code == 200:
hubspot_id = hubspot_update_response.json()["results"][0]["id"]
partner = self.env['res.partner'].search([('id', '=', odoo_contact["id"])], limit=1)
if partner:
partner.write({'hubspot_id': hubspot_id})
print(
f"Hubspot ID {hubspot_id} has been stored in the Odoo database for contact {odoo_contact['email']}")
else:
print(f"Error: Cannot find contact with ID {odoo_contact['id']} in Odoo database.")
here is my update data :
---- update_data------ {'inputs': [{'id': '17151', 'properties': {'firstname': 'hubspot6', 'phone': '123456781111', 'hubspot_hash': '3e2e37f16d4999807b6b16ac818a07788ff9f1b8d9fdf69e2331e2fb91d16282'}}]}
but it can't update hubspot_id value in odoo database.
and i am getting following error..
2023-03-31 05:43:26,273 15919 INFO integrationextra odoo.addons.base.models.ir_cron: Job `Contacts Scheduler` done.
2023-03-31 05:43:26,274 15919 ERROR integrationextra odoo.sql_db: bad query: UPDATE "res_partner" SET "hubspot_id" = '17351', "write_date" = '2023-03-31 05:43:03.555219', "write_uid" = 1 WHERE id IN (415)
ERROR: could not serialize access due to concurrent update