Hi.
I want to make a little change to the def write() function in res.partner.
My first problem is, that I don't find the function "write" in official Odoo10 module "account" in the partner.py file.
The second problem is, that I don't know how I can check if any field is changed. I need to check that and then when something changed I need to set the "state to draft".
So for example:
@api.model
def write(self):
self.write({'state': 'draft'})
return True
Thank you
update:
I have this 2 functions:
@api.multi
def confirm_customer(self):
self.state = 'confirmed'
return True
@api.multi
def write(self, data):
res = super(Partner, self).write(data)
if self.state == 'confirmed':
self.state = 'draft'
return res
After I click my button "confirm_customer" it should go to state=confirmed. It works fine without the "def write" function.
But with the write function it doesn't work.
Now it didn't change the "confirm_customer" state to confirm. It stays all the time on draft.
When you use self.a_field = 'some_value' write function is called. So when you call self.state = 'confirm' it will go to write. Write your functions accordingly
also in your write function don't use self.field = 'a_value' pass values by dictionary
so I need to write something like this : vals (dict) vals{'foo': 1, 'bar': "Qux"}
I mean, I have no idea how I can change a value without using the .write() method...
any solution on that problem ?