This question has been flagged

Team,

For some project specific need, I need to keep track of all Invoice changes after open state.

I created a new field as below:

version = fields.Integer(string="Invoice version",compute="_handle_version", store=True)

Wrote a simple handler for the same..

    @api.one
@api.depends('state')
def _handle_version(self):

print "changing version----------------"
print self.state, self.version

if self.version:
print "in if"
self.version+=1
else:
self.version=1

print "new verion is ",self.version


This is mainly used to track in case any changes to invoice are made after state is open like cancelling, edit, etc..

Now, everything this handler is triggered  . I am always getting below o/p.. Always it reads self.version as 0.


changing version---------------- 
draft 0
new verion is 1

or..

changing version---------------- 
open 0
new verion is 1

But always, the incremented and saved value does not show in self.version.


Please help, what I am missing ???

Is something else require to update the field ??



Avatar
Discard