From 8ecb170ce0c7e0de67e212885b70f4ae2cf35208 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Mon, 29 Dec 2008 12:31:21 +0530 Subject: [PATCH] Bugfixed and correction on account_payment lp bug: https://launchpad.net/bugs/311727 fixed bzr revid: jvo@tinyerp.com-20081229070121-5wozed2ko26a3dwf --- addons/account_payment/payment.py | 16 +++++----- addons/account_payment/payment_view.xml | 4 +-- .../wizard/wizard_populate_statement.py | 30 ++++++++++--------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py index 9d5b3682f74..b0bc71568f9 100644 --- a/addons/account_payment/payment.py +++ b/addons/account_payment/payment.py @@ -19,7 +19,6 @@ # along with this program. If not, see . # ############################################################################## - from osv import fields from osv import osv import time @@ -110,7 +109,7 @@ class payment_order(osv.osv): ('now', 'Directly'), ('due', 'Due date'), ('fixed', 'Fixed date') - ], "Prefered date", change_default=True, required=True,help="Choose an option for the Payment Order:'Fixed' stands for a date specified by you.'Directly' stands for the direct execution.'Due date' stands for the scheduled date of execution."), + ], "Preferred date", change_default=True, required=True,help="Choose an option for the Payment Order:'Fixed' stands for a date specified by you.'Directly' stands for the direct execution.'Due date' stands for the scheduled date of execution."), 'date_created': fields.date('Creation date', readonly=True), 'date_done': fields.date('Execution date', readonly=True), } @@ -401,13 +400,13 @@ class payment_line(osv.osv): # 'reference': fields.function(select_by_name, string="Ref", method=True, # type='char'), 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Maturity Date'), - 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref'), + 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'), 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text",help='Address of the Main Partner'), 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text",help='Address of the Ordering Customer.'), # 'partner_payable': fields.function(partner_payable, string="Partner payable", method=True, type='float'), # 'value_date': fields.function(_value_date, string='Value Date', # method=True, type='date'), - 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line direclty"), + 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line directly"), 'create_date': fields.datetime('Created' ,readonly=True), 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True) } @@ -430,6 +429,7 @@ class payment_line(osv.osv): if move_line_id: line = self.pool.get('account.move.line').browse(cr,uid,move_line_id) data['amount_currency']=line.amount_to_pay + res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, company_currency, context) if res: @@ -460,12 +460,12 @@ class payment_line(osv.osv): return {'value': data} - def onchange_amount(self,cr,uid,ids,amount,currency,cmpny_currency,context=None): - if not amount: - return {} + def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None): + if (not amount) or (not cmpny_currency): + return {'value': {'amount':False}} res = {} currency_obj = self.pool.get('res.currency') - company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency,amount) + company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency, amount) res['amount'] = company_amount return {'value': res} diff --git a/addons/account_payment/payment_view.xml b/addons/account_payment/payment_view.xml index 5de9f36a074..4202ca94b6c 100644 --- a/addons/account_payment/payment_view.xml +++ b/addons/account_payment/payment_view.xml @@ -220,14 +220,14 @@ - + - + diff --git a/addons/account_payment/wizard/wizard_populate_statement.py b/addons/account_payment/wizard/wizard_populate_statement.py index 5646ae71ae6..c9c37c2094f 100644 --- a/addons/account_payment/wizard/wizard_populate_statement.py +++ b/addons/account_payment/wizard/wizard_populate_statement.py @@ -67,22 +67,24 @@ def _populate_statement(obj, cursor, user, data, context): for line in line_obj.browse(cursor, user, line_ids, context=context): ctx = context.copy() - ctx['date'] = line.value_date + ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now amount = currency_obj.compute(cursor, user, line.currency.id, statement.currency.id, line.amount_currency, context=ctx) - reconcile_id = statement_reconcile_obj.create(cursor, user, { - 'line_ids': [(6, 0, [line.move_line_id.id])] - }, context=context) - statement_line_obj.create(cursor, user, { - '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.reference, - 'reconcile_id': reconcile_id, - }, context=context) + + if line.move_line_id: + reconcile_id = statement_reconcile_obj.create(cursor, user, { + 'line_ids': [(6, 0, [line.move_line_id.id])] + }, context=context) + statement_line_obj.create(cursor, user, { + '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, + 'reconcile_id': reconcile_id, + }, context=context) return {}