Skip to Content
Menu
This question has been flagged
1 Reply
6735 Views

I need to compute a filed after pos_session.state is 'closed' in a  (working) function:

class pos_session2(models.Model):
_inherit = 'pos.session'
chk = fields.Char(string = 'chk', compute = '_session_costs_control', store = True)

@api.depends('sequence_number')
def _session_costs_control(self):
_logger.info('Status = %s', self.state)
    if self.state == 'closed':
        self.chk = self.state #for tests purpose
    else:
        self.chk = self.sequence_number

The if statement is never reached, the else statement works fine and correctly update for every order added.

I've tried with:

self.state == str('closed')
(self.state == 'closed')

But nothing so far. When I close a session the field pos_session.chk is not updated. For now I'm checking the field with a cr.execute but I would like to understand why a simple string is not captured in Odoo.

Edit: Solved adding  'state' and 'stop_at' on api.depends(). When I close the session the index of 'sequence_number' is not updated.  Just a stupid mistake.

Avatar
Discard
Author Best Answer

Solved adding 'state' and 'stop_at' on api.depends(). When a session is closed the index of 'sequence_number' is not updated.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 21
5199
3
Jul 20
18536
2
Jan 19
5101
1
Dec 18
1842
1
Jul 18
6093