|
@@ -7,22 +7,34 @@ _MODEL = 'res.bank.payments'
|
|
|
|
|
|
'''
|
|
|
'''
|
|
|
-def create_bank_payment_statement(data, currency_id, date, journal_id=None, partner_id=None, supplier_id=None):
|
|
|
- bank_payments_type_id = request.env['res.bank.payments.type'].get_bank_payments_type_id(journal_id)
|
|
|
+def create_bank_payment_statement(data, invoice_id, account_voucher_id):
|
|
|
+ invoice = request.env['account.invoice'].browse(invoice_id)
|
|
|
+ account_voucher = request.env['account.voucher'].browse(account_voucher_id)
|
|
|
+ bank_statement_line = request.env['account.bank.statement.line'].search([('voucher_id', '=', account_voucher_id)])
|
|
|
+
|
|
|
+ bank_payments_type_id = request.env['res.bank.payments.type'].get_bank_payments_type_id(account_voucher.journal_id.id)
|
|
|
|
|
|
values = {
|
|
|
'bank_payments_type_id': bank_payments_type_id,
|
|
|
'bank_id': data.get('bank_id', None),
|
|
|
- 'currency_id': currency_id,
|
|
|
- 'date': date,
|
|
|
- 'customer_id': partner_id,
|
|
|
+ 'currency_id': invoice.currency_id.id,
|
|
|
+ 'date': invoice.date_invoice,
|
|
|
+ 'customer_id': invoice.partner_id.id,
|
|
|
'number_cta': data.get('number_cta', None),
|
|
|
'number_cta_origin': data.get('number_cta_origin', None),
|
|
|
'name_holder': data.get('name_holder', None),
|
|
|
'number': data.get('number'),
|
|
|
'date_maturity': data.get('date_maturity', '') or get_date(),
|
|
|
- 'supplier_id': supplier_id,
|
|
|
- 'amount_total': data.get('amount', None)
|
|
|
+ 'amount_total': data.get('amount', None),
|
|
|
+ 'payments_line': [[0, False, {
|
|
|
+ 'amount': abs(account_voucher.amount),
|
|
|
+ 'amount_currency': 0.0,
|
|
|
+ 'date': invoice.date_invoice,
|
|
|
+ 'statement_line_id': bank_statement_line.id,
|
|
|
+ 'statement_id': bank_statement_line.statement_id.id,
|
|
|
+ 'type_operation': ('payment', 'receipt')[invoice.type == 'out_invoice'],
|
|
|
+ 'currency_id': invoice.currency_id.id
|
|
|
+ }]]
|
|
|
}
|
|
|
|
|
|
request.env['res.bank.payments'].create(values)
|