I am creating a syncing function where when a Sales order is created/edited it will sync it to our other CRM. I'm inheriting the Sales order module as follows :
@api.model
def create(self, values):
# Override the original create function for the sale_order model
record = super(sale_order, self).create(values)
return record
def write(self, values):
record = super(sale_order, self).write(values)
for record in self:
if record.company_id.x_studio_is_zoho_sales_order_sync == True:
company_id = record.company_id
partner = record.partner_id
partner_id = partner.id
partner_obj = self.env['res.partner'].search([('id','=',partner_id)])
...
However i noticed that when creating/editing a Sales order , the write function is executed several times (almost 20 or more). is there a way i can stop it from executing multiple times ?