diff --git a/addons/account_payment/report/payment_order.py b/addons/account_payment/report/payment_order.py index 3734e4268d1..a9412b832a4 100644 --- a/addons/account_payment/report/payment_order.py +++ b/addons/account_payment/report/payment_order.py @@ -20,13 +20,13 @@ ############################################################################## import time -import datetime + import pooler from report import report_sxw class payment_order(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): + def __init__(self, cr, uid, name, context=None): super(payment_order, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index b1ae0717dd2..8ef89beefb5 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -40,10 +40,10 @@ class payment_order_create(osv.osv_memory): _columns = { 'duedate': fields.date('Due Date', required=True), 'entries': fields.many2many('account.move.line', 'line_pay_rel', 'pay_id', 'line_id', 'Entries') - } + } _defaults = { 'duedate': time.strftime('%Y-%m-%d'), - } + } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(payment_order_create, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) @@ -64,7 +64,8 @@ class payment_order_create(osv.osv_memory): context = {} data = self.read(cr, uid, ids, [])[0] line_ids = data['entries'] - if not line_ids: return {} + if not line_ids: + return {} payment = order_obj.browse(cr, uid, context['active_id'], context=context) t = None @@ -100,16 +101,13 @@ class payment_order_create(osv.osv_memory): data = self.read(cr, uid, ids, [], context=context)[0] search_due_date = data['duedate'] payment = order_obj.browse(cr, uid, context['active_id'], context=context) - ctx = '' - if payment.mode: - ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id # Search for move line to pay: - domain = [('reconcile_id', '=', False),('account_id.type', '=', 'payable'),('amount_to_pay', '>', 0)] - domain = domain + ['|',('date_maturity','<=',search_due_date),('date_maturity','=',False)] + domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)] + domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)] line_ids = line_obj.search(cr, uid, domain, context=context) context.update({'line_ids': line_ids}) - model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_create_payment_order_lines')], context=context) + model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], 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, @@ -119,7 +117,7 @@ class payment_order_create(osv.osv_memory): 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', 'target': 'new', - } + } payment_order_create() diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index 33706e8458f..8e524c78959 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -19,7 +19,7 @@ # ############################################################################## -from osv import fields, osv +from osv import osv class account_payment_make_payment(osv.osv_memory): _name = "account.payment.make.payment" diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index 6119b9ea5d9..bd61d58be3f 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -29,7 +29,7 @@ class account_payment_populate_statement(osv.osv_memory): _description = "Account Payment Populate Statement" _columns = { 'lines': fields.many2many('payment.line', 'payment_line_rel_', 'payment_id', 'line_id', 'Payment Lines') - } + } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): line_obj = self.pool.get('payment.line') @@ -76,24 +76,18 @@ class account_payment_populate_statement(osv.osv_memory): 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) - if line.partner_id: -# line['partner_id'] = mv.partner_id.id - if amount < 0: - account = line.partner_id.property_account_payable.id - else: - account = line.partner_id.property_account_receivable.id - 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_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 @@ -103,7 +97,7 @@ class account_payment_populate_statement(osv.osv_memory): 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_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, {