# -*- coding: utf-8 -*- from openerp.http import request as r def create_bank_statement_lines(account_voucher_id, reference=None): account_voucher = r.env['account.voucher'].browse(account_voucher_id) amount = account_voucher.amount if account_voucher.type == 'payment': amount = amount * -1 return [[0, False, { 'name': account_voucher.reference, 'amount': amount, 'partner_id': account_voucher.partner_id.id, 'voucher_id': account_voucher.id, 'journal_id': account_voucher.journal_id.id, 'account_id': account_voucher.account_id.id, 'journal_entry_id': account_voucher.move_id.id, 'currency_id': account_voucher.currency_id.id, 'ref': 'POS/' + (reference or '') }]] def create_bank_statement(account_voucher_id, account_bank_statement_lines, date_today): account_voucher = r.env['account.voucher'].browse(account_voucher_id) account_bank_statement = r.env['account.bank.statement'].search([('journal_id', '=', account_voucher.journal_id.id), ('date', '=', date_today)]) values = { 'date': date_today, 'user_id': r.env.user.id, 'journal_id': account_voucher.journal_id.id, 'period_id': account_voucher.period_id.id, 'line_ids': account_bank_statement_lines, 'state': 'open' if account_voucher.journal_id.type == 'cash' else 'draft' } if account_bank_statement: size = len(account_bank_statement) if size == 1: account_bank_statement.write(values) else: account_bank_statement[size - 1].write(values) else: account_bank_statement.create(values) return account_bank_statement