From fded19fd84c6d9b669277f7b8b9773445e1b64d1 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 1 Sep 2010 16:08:47 +0530 Subject: [PATCH] [IMP] Account payment: Change the behavior on bank statemt => import payment lines now it will search only paymentlines where bank statemenline id = false on same payment line (note: added new field on bank statement line field on payment line to synchronize) bzr revid: mra@mra-laptop-20100901103847-2fqmda2lcfluaksh --- addons/account_payment/account_payment.py | 3 ++- .../account_payment_populate_statement.py | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index 2ebf0ea430b..b36dc0be306 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -325,7 +325,8 @@ class payment_line(osv.osv): 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'), '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) + 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True), + 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line') } _defaults = { 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence' diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index 381f0d0f8f7..0d736dba7d2 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + from lxml import etree from osv import osv, fields @@ -38,7 +39,8 @@ class account_payment_populate_statement(osv.osv_memory): statement = statement_obj.browse(cr, uid, context['active_id'], context=context) line_ids = line_obj.search(cr, uid, [ ('move_line_id.reconcile_id', '=', False), - ('order_id.mode.journal.id', '=', statement.journal_id.id)]) + ('bank_statement_line_id', '=', False),]) +# ('order_id.mode.journal.id', '=', statement.journal_id.id)]) line_ids.extend(line_obj.search(cr, uid, [ ('move_line_id.reconcile_id', '=', False), ('order_id.mode', '=', False)])) @@ -47,15 +49,15 @@ class account_payment_populate_statement(osv.osv_memory): model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','account_payment_populate_statement_view')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { - 'name': ('Entrie Lines'), - 'context': context, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'account.payment.populate.statement', - 'views': [(resource_id,'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - } + 'name': ('Entrie Lines'), + 'context': context, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'account.payment.populate.statement', + 'views': [(resource_id,'form')], + 'type': 'ir.actions.act_window', + 'target': 'new', + } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(account_payment_populate_statement, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) @@ -93,7 +95,7 @@ class account_payment_populate_statement(osv.osv_memory): reconcile_id = statement_reconcile_obj.create(cr, uid, { 'line_ids': [(6, 0, [line.move_line_id.id])] }, context=context) - statement_line_obj.create(cr, uid, { + st_line_id = statement_line_obj.create(cr, uid, { 'name': line.order_id.reference or '?', 'amount': - amount, 'type': 'supplier', @@ -103,6 +105,7 @@ class account_payment_populate_statement(osv.osv_memory): 'ref': line.communication, 'reconcile_id': reconcile_id, }, context=context) - return {'type' : 'ir.actions.act_window_close'} + 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()