Skip to Content
Menu
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
Related Posts Replies Views Activity
3
Sep 24
9984
2
Feb 24
598
1
Jul 23
1003
2
Jun 23
1394
1
May 23
11452