From dccd7b932f5afac32acb2fe5df950efde1c16205 Mon Sep 17 00:00:00 2001 From: qdp Date: Tue, 2 Sep 2008 08:52:47 +0200 Subject: [PATCH] *added automatic fill in of the payment date when importing payment line from invoices *added help tooltip *improved and bugfixed bzr revid: qdp@tinyerp.com-20080902065247-wss1tenz1n4fy698 --- addons/account_payment/payment.py | 5 ++--- addons/account_payment/wizard/wizard_payment_order.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py index 78a2e0640f1..ff4bd139019 100644 --- a/addons/account_payment/payment.py +++ b/addons/account_payment/payment.py @@ -418,7 +418,7 @@ class payment_line(osv.osv): # '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'), + 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line direclty"), 'create_date': fields.datetime('Created' ,readonly=True), 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True) } @@ -457,8 +457,7 @@ class payment_line(osv.osv): elif date_prefered == 'due': data['date'] = line.date_maturity elif date_prefered == 'fixed': - if date_planned: - data['date'] = date_planned + data['date'] = date_planned return {'value': data} diff --git a/addons/account_payment/wizard/wizard_payment_order.py b/addons/account_payment/wizard/wizard_payment_order.py index a0ae8cb5bdb..5ec0a2700c0 100644 --- a/addons/account_payment/wizard/wizard_payment_order.py +++ b/addons/account_payment/wizard/wizard_payment_order.py @@ -87,11 +87,19 @@ def create_payment(self, cr, uid, data, context): payment = order_obj.browse(cr, uid, data['id'], context=context) - t = payment.mode and payment.mode.type.code or 'manual' + t = payment.mode and payment.mode.type.code or None line2bank= pool.get('account.move.line').line2bank(cr, uid, line_ids, t, context) + ## Finally populate the current payment with new lines: for line in line_obj.browse(cr, uid, line_ids, context=context): + if payment.date_prefered == "now": + #no payment date => immediate payment + date_to_pay = False + elif payment.date_prefered == 'due': + date_to_pay = line.date_maturity + elif payment.date_prefered == 'fixed': + date_to_pay = payment.date_planned pool.get('payment.line').create(cr,uid,{ 'move_line_id': line.id, 'amount_currency': line.amount_to_pay, @@ -99,6 +107,7 @@ def create_payment(self, cr, uid, data, context): 'order_id': payment.id, 'partner_id': line.partner_id and line.partner_id.id or False, 'communication': line.ref or '/', + 'date': date_to_pay, }, context=context) return {}