~unifield-team/unifield-wm/us-948d

« back to all changes in this revision

Viewing changes to register_accounting/account_cash_statement.py

  • Committer: Vincent GREINER
  • Date: 2016-02-29 15:38:12 UTC
  • Revision ID: vg@tempo-consulting.fr-20160229153812-yfu0qao77nu6mb79
US-948 [FIX] when cashbox is open do not use the calculated balance as reference since we warry over the cashbox balance

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
                for line in statement.starting_details_ids:
53
53
                    amount_total+= line.pieces * line.number
54
54
            else:
55
 
                amount_total = statement.prev_reg_id.msf_calculated_balance
 
55
                if context and context.get('from_open'):
 
56
                    # US-948 carry other cashbox balance at open register
 
57
                    amount_total = statement.prev_reg_id.balance_end_cash
 
58
                else:
 
59
                    amount_total = statement.prev_reg_id.msf_calculated_balance
56
60
 
57
61
            res[statement.id] = {
58
62
                'balance_start': amount_total
146
150
        return res
147
151
 
148
152
    def button_open_cash(self, cr, uid, ids, context=None):
149
 
        if not context:
 
153
        if context is None:
150
154
            context = {}
151
155
        if isinstance(ids, (int, long)):
152
156
            ids = [ids] # Calculate the starting balance
153
157
 
154
 
        res = self._get_starting_balance(cr, uid, ids)
 
158
        context['from_open'] = True
 
159
        res = self._get_starting_balance(cr, uid, ids, context=context)
 
160
        del context['from_open']
155
161
        for rs in res:
156
162
            self.write(cr, uid, [rs], res.get(rs)) # Verify that the starting balance is superior to 0 only if this register has prev_reg_id to False
157
163
            register = self.browse(cr, uid, [rs], context=context)[0]