I'm executing a function in a cron job and fetch a certain partner from the database.
Suppose I change the partners name in that function.
partner = self.env[...].sudo().search(...) #assumes this works and returns object
partner.name = 'New name'
I notice that after I change the property, the write function is called (I put a breakpoint in the overwritten write() method). My question is: who triggers this write()? And, suppose I do two changes on this object, e.g. also change something in the address, will this then cause two write() calls, and, thus also two DB updates.
We can however also call partner.write({'name': 'New name'}). What is the difference and what is the preferred way of working?