~vauxoo/addons-vauxoo/7.0-project_issue_conf-dev_luis

« back to all changes in this revision

Viewing changes to invoice_cancel_iva/model/invoice.py

 
[MERGE] Merge to add all changes in trunk series

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        if invo_brw.cancel_true:
58
58
            if invo_brw.wh_iva_id:
59
59
                iva_line_obj.load_taxes(cr, uid, [
60
 
                                        i.id for i in invo_brw.wh_iva_id.wh_lines], context=context)
 
60
                    i.id for i in invo_brw.wh_iva_id.wh_lines],
 
61
                    context=context)
61
62
                for d in state:
62
63
                    if invo_brw.wh_iva_id.prev_state == 'cancel':
63
64
                        break
64
65
 
65
 
                    if not all([False for line in invo_brw.wh_iva_id.wh_lines if not line.invoice_id.move_id]):
66
 
                        raise osv.except_osv(_('Error'), _(
67
 
                            'One of the bills involved in the vat retention has not been validated, because it does not have an associated retention'))
 
66
                    if not all([False for line in invo_brw.wh_iva_id.wh_lines
 
67
                                if not line.invoice_id.move_id]):
 
68
                            raise osv.except_osv(_('Error'), _(
 
69
                                'One of the bills involved in the vat retention\
 
70
                                has not been validated, because it does not\
 
71
                                have an associated retention'))
68
72
                    wf_service.trg_validate(
69
73
                        uid, 'account.wh.iva', invo_brw.wh_iva_id.id, d[1], cr)
70
74
 
82
86
        invo_brw = self.browse(cr, uid, ids, context=context)[0]
83
87
        if invo_brw.wh_iva_id:
84
88
            iva_obj.write(cr, uid, [invo_brw.wh_iva_id.id], {
85
 
                          'prev_state': invo_brw.wh_iva_id.state}, context=context)
 
89
                'prev_state': invo_brw.wh_iva_id.state},
 
90
                context=context)
86
91
 
87
92
        res = super(account_invoice, self).invoice_cancel(
88
93
            cr, uid, ids, context=context)
96
101
        if invo_brw.wh_iva_id:
97
102
            return False
98
103
        return True
99