~openbig/bigconsulting/addons

« back to all changes in this revision

Viewing changes to account_payment_discount_extension/wizard/wizard_discount_pay.py

  • Committer: thomas-dreiling
  • Date: 2010-10-08 10:09:57 UTC
  • Revision ID: thomas-dreiling-20101008100957-vm4abrqpfdsxqtdq
- clean-ups in account_payment_discount_extension
- translations for account_payment_discount_extension

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
def _launch_wizard(self, cr, uid, data, context):
31
31
    """
32
32
    Search for a wizard to launch according to the type.
33
 
    If type is manual. just confirm the order.
 
33
    If type is manual, just confirm the order.
34
34
    """
35
35
    pool = pooler.get_pool(cr.dbname)
 
36
    invoice_obj = pool.get('account.invoice')
 
37
    order_line = pool.get('payment.line')
36
38
    order_ref = pool.get('payment.order')
37
 
    order_line = pool.get('payment.line')
38
 
    order = order_ref.browse(cr,uid,data['id'],context)
39
 
    invoice_obj = pool.get('account.invoice')
 
39
    order = order_ref.browse(cr, uid, data['id'], context)
40
40
    
41
 
    t= order.mode and order.mode.type.code or 'manual'
42
 
    if t == 'manual' :
 
41
    t = order.mode and order.mode.type.code or 'manual'
 
42
    if t == 'manual':
43
43
        order_ref.set_done(cr,uid,data['id'],context)
44
44
        return {}
45
45
   
48
48
    for pay_line in order.line_ids:
49
49
        invoice_data = invoice_obj.browse(cr, uid, pay_line.move_line_id.invoice.id, context=context)
50
50
        if pay_line.cash_discount:
51
 
            context.update({'pay_cash_discount':pay_line.cash_discount, 'pay_cash_dis_acc':pay_line.partner_id.property_supplier_cash_discount_account.id})
 
51
            context.update({'pay_cash_discount': pay_line.cash_discount, 'pay_cash_dis_acc': pay_line.partner_id.property_supplier_cash_discount_account.id})
52
52
        account_id = order.inter_bank_journal.default_credit_account_id and order.inter_bank_journal.default_credit_account_id.id
53
53
        invoice_obj.pay_and_reconcile(cr, uid, [invoice_data.id],
54
 
                   pay_line.amount_currency, account_id, period_ids[0], journal_id, False,
55
 
                    period_ids[0], journal_id, context, pay_line.name)
 
54
            pay_line.amount_currency, account_id, period_ids[0], journal_id, False,
 
55
            period_ids[0], journal_id, context, pay_line.name)
56
56
 
57
57
    gw = order_ref.get_wizard(t)
58
58
    if not gw:
59
 
        order_ref.set_done(cr,uid,data['id'],context)
 
59
        order_ref.set_done(cr, uid, data['id'], context)
60
60
        return {}       
61
61
 
62
62
    mod_obj = pool.get('ir.model.data')
63
63
    act_obj = pool.get('ir.actions.wizard')
64
 
    module, wizard= gw
 
64
    module, wizard = gw
65
65
    result = mod_obj._get_id(cr, uid, module, wizard)
66
66
    id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
67
67
    result = act_obj.read(cr, uid, [id])[0]
68
 
    #result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
69
68
    return result
70
69
 
71
70
class wizard_pay(wizard.interface):
72
71
 
73
 
    states= {'init' : {'actions': [],       
74
 
                       'result':{'type':'action',
75
 
                                 'action':_launch_wizard,
76
 
                                 'state':'end'}
77
 
                       }
78
 
             }
 
72
    states= {
 
73
        'init' : {
 
74
            'actions': [],
 
75
            'result': {
 
76
                'type': 'action',
 
77
                'action': _launch_wizard,
 
78
                'state': 'end'
 
79
            }
 
80
        }
 
81
    }
79
82
wizard_pay('pay_discount_payment')
80
83
 
81
84
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: