diff options
| author | Jay Vora (OpenERP) <jvo@tinyerp.com> | 2011-05-16 19:48:07 +0530 |
|---|---|---|
| committer | Jay Vora (OpenERP) <jvo@tinyerp.com> | 2011-05-16 19:48:07 +0530 |
| commit | 7dd9ff14e00e1c1ca28fbffaeea4b4e4299e954b (patch) | |
| tree | 36fc0f0f1ef5c349a81283ef508c44fb3cc8179c | |
| parent | b3c167b3aa94ef6859e5595c5f366c2b8e3edea2 (diff) | |
| parent | 208c6e0b55cab729426a6555f533734b69542bd8 (diff) | |
[MERGE] Merged Rifakat's branch for the fix of onchange call
bzr revid: jvo@tinyerp.com-20110516141807-5ktqh53nk8z8n3pu
| -rw-r--r-- | addons/account_payment/wizard/account_payment_populate_statement.py | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index 340ab4bcb03..e7436d3beb3 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -75,45 +75,46 @@ class account_payment_populate_statement(osv.osv_memory): amount = currency_obj.compute(cr, uid, line.currency.id, statement.currency.id, line.amount_currency, context=ctx) + if not line.move_line_id.id: + continue context.update({'move_line_ids': [line.move_line_id.id]}) - result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment', context=context) + result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id=statement.currency.id, ttype='payment', date=line.date, context=context) - if line.move_line_id: - voucher_res = { - 'type': 'payment', - 'name': line.name, - 'partner_id': line.partner_id.id, - 'journal_id': statement.journal_id.id, - 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), - 'company_id': statement.company_id.id, - 'currency_id': statement.currency.id, - 'date': line.date or time.strftime('%Y-%m-%d'), - 'amount': abs(amount), - 'period_id': statement.period_id.id - } - voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context) - voucher_line_dict = False - if result['value']['line_ids']: - for line_dict in result['value']['line_ids']: - move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context) - if line.move_line_id.move_id.id == move_line.move_id.id: - voucher_line_dict = line_dict - if voucher_line_dict: - voucher_line_dict.update({'voucher_id': voucher_id}) - voucher_line_obj.create(cr, uid, voucher_line_dict, context=context) - - st_line_id = statement_line_obj.create(cr, uid, { - 'name': line.order_id.reference or '?', - 'amount': - amount, - 'type': 'supplier', + voucher_res = { + 'type': 'payment', + 'name': line.name, 'partner_id': line.partner_id.id, - 'account_id': line.move_line_id.account_id.id, - 'statement_id': statement.id, - 'ref': line.communication, - 'voucher_id': voucher_id, - }, context=context) + 'journal_id': statement.journal_id.id, + 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), + 'company_id': statement.company_id.id, + 'currency_id': statement.currency.id, + 'date': line.date or time.strftime('%Y-%m-%d'), + 'amount': abs(amount), + 'period_id': statement.period_id.id + } + voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context) + voucher_line_dict = {} + if result['value']['line_ids']: + for line_dict in result['value']['line_ids']: + move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context) + if line.move_line_id.move_id.id == move_line.move_id.id: + voucher_line_dict = line_dict + if voucher_line_dict: + voucher_line_dict.update({'voucher_id': voucher_id}) + voucher_line_obj.create(cr, uid, voucher_line_dict, context=context) + + st_line_id = statement_line_obj.create(cr, uid, { + 'name': line.order_id.reference or '?', + 'amount': - amount, + 'type': 'supplier', + 'partner_id': line.partner_id.id, + 'account_id': line.move_line_id.account_id.id, + 'statement_id': statement.id, + 'ref': line.communication, + 'voucher_id': voucher_id, + }, context=context) - line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id}) + line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id}) return {'type': 'ir.actions.act_window_close'} account_payment_populate_statement() |
