|
@@ -69,23 +69,8 @@ class AccountVoucher(models.Model):
|
|
|
|
|
|
# Fecha del servidor
|
|
|
today = fields.Date.context_today(self)
|
|
|
-
|
|
|
- # Consultar Caja Abierta, Método de Pagos, Fecha de Hoy
|
|
|
- bank_statement = self.env['account.bank.statement'].search([('state', '=', 'open'), ('journal_id', '=', [journal.id]), ('date', '=', today)])
|
|
|
-
|
|
|
- # Crea caja si no tiene caja con el método de pago y la fecha de hoy
|
|
|
- if not bank_statement:
|
|
|
- bank = {
|
|
|
- 'journal_id': journal.id,
|
|
|
- 'period_id': int(period.id),
|
|
|
- 'date': today,
|
|
|
- 'user_id': user.id
|
|
|
- }
|
|
|
- bank_statement = bank_statement.create(bank)
|
|
|
-
|
|
|
# Crea la linea en la caja del pago realizado
|
|
|
- line = {
|
|
|
- 'statement_id': bank_statement.id,
|
|
|
+ bank_statement_line = [[0, False, {
|
|
|
'name': account_voucher.reference,
|
|
|
'partner_id': account_voucher.partner_id.id,
|
|
|
'amount': account_voucher.amount,
|
|
@@ -95,11 +80,27 @@ class AccountVoucher(models.Model):
|
|
|
'journal_entry_id': account_voucher.move_id.id,
|
|
|
'currency_id': account_voucher.currency_id.id,
|
|
|
'ref': 'NP'
|
|
|
+ }]]
|
|
|
+
|
|
|
+ # Consultar Caja Abierta, Método de Pagos, Fecha de Hoy
|
|
|
+ bank_statement = self.env['account.bank.statement'].search([('journal_id', '=', [journal.id]), ('date', '=', today)])
|
|
|
+
|
|
|
+ bank = {
|
|
|
+ 'journal_id': account_voucher.journal_id.id,
|
|
|
+ 'period_id': account_voucher.period_id.id,
|
|
|
+ 'date': today,
|
|
|
+ 'user_id': user.id,
|
|
|
+ 'state': 'open' if account_voucher.journal_id.type == 'cash' else 'draft',
|
|
|
+ 'line_ids':bank_statement_line
|
|
|
}
|
|
|
- statement_line = self.env['account.bank.statement.line'].create(line)
|
|
|
|
|
|
- # Actualizar La caja en Estado Abierto
|
|
|
- bank_statement.write({'state': 'open'})
|
|
|
+ if bank_statement:
|
|
|
+ if len(bank_statement) == 1:
|
|
|
+ bank_statement.write(bank)
|
|
|
+ else:
|
|
|
+ bank_statement[len(bank_statement) -1].write(bank)
|
|
|
+ else:
|
|
|
+ bank_statement = bank_statement.create(bank)
|
|
|
|
|
|
# Retorna el ticket de pagos
|
|
|
return {
|