Hi, Please can you help me to correct this error
class account_voucher_populate_statement(models.TransientModel):
_name = "account.voucher.populate.statement"
_description = "Account Voucher Populate Statement"
journal_id = fields.Many2one(
'account.journal',
'Journal',
required=True
)
line_ids = fields.Many2many(
'account.payment',
'account_payment_line_rel',
'payment_id', 'line_id',
'Payment',
domain="[('journal_id', '=', journal_id), ('state', '=', 'posted'), ('bank_statement_line_ids', '=', False)]"
)
def get_statement_line_new(self, cr, uid, payment, statement, context=None):
# Override thi method to modifiy the new statement line to create
ctx = context.copy()
ctx['date'] = payment.date
amount = self.pool.get('res.currency').compute(cr, uid, payment.currency_id.id,
statement.currency.id, payment.amount, context=ctx)
sign = payment.type == 'payment' and -1.0 or 1.0
type = payment.type == 'payment' and 'supplier' or 'customer'
account_id = payment.type == 'payment' and payment.partner_id.property_account_payable.id or payment.partner_id.property_account_receivable.id
return {
'name': payment.reference or payment.number or '?',
'amount': sign * amount,
'type': type,
'partner_id': payment.partner_id.id,
'account_id': account_id,
'statement_id': statement.id,
'ref': payment.name,
'payment_id': payment.id,
'journal_entry_id': payment.move_id.id,
}
def populate_statement(self, cr, uid, ids, context=None):
statement_obj = self.env['account.bank.statement']
statement_line_obj = self.env['account.bank.statement.line']
payment_obj = self.env['account.payment']
if context is None:
context = {}
data = self.read(cr, uid, ids, [], context=context)[0]
payments_ids = data['line_ids']
if not payments_ids:
return {'type': 'ir.actions.act_window_close'}
statement = statement_obj.browse(
cr, uid, context['active_id'], context=context)
for payment in payment_obj.browse(cr, uid, payment_ids, context=context):
statement_line_obj.create(cr, uid,
self.get_statement_line_new(cr, uid, payment, statement, context=context), context=context)
payment_obj.write(
cr, uid, payment_ids, {'is_bank_voucher': True}, context=context)
return {'type': 'ir.actions.act_window_close'}