12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- # -*- coding: utf-8 -*-
- from openerp import models, fields, tools, api
- class AccountBankStatement(models.Model):
- _inherit = 'account.bank.statement'
- type_statement = fields.Selection([('normal', 'Normal'),('general', 'General')],'Tipo de Caja ', default="normal", help="Tipo de caja")
- @api.model
- def get_statement_point_of_sale(self, id):
- accountStatement = self.env['account.bank.statement'].browse(id)
- decimal_precision = self.env['decimal.precision'].precision_get('Account')
- if (not accountStatement):
- return False
- statementPointOfSale = self._get_statement_point_of_sale(accountStatement)
- if (not statementPointOfSale):
- return False
- statementLine = []
- for line in statementPointOfSale:
- lineStatement = self.env['account.bank.statement.line'].search([('name', '=', line['name'])])
- if (not lineStatement):
- amount = line['amount']
- statementLine.append([0, False, {
- 'name': line['name'],
- 'ref' : 'Responsable/'+line['userName'],
- 'amount': round(float(amount), decimal_precision),
- 'journal_id': accountStatement.journal_id.id,
- 'account_id': accountStatement.journal_id.internal_account_id.id,
- 'statement_id': accountStatement.id,
- 'date': line['date'],
- }])
- line = []
- if (not statementLine):
- return False
- line = accountStatement.write({'line_ids': statementLine})
- if (not line):
- return False
- return len(statementLine)
- '''
- Get Account Bank Statement Point of Sale
- '''
- def _get_statement_point_of_sale(self, statement):
- statementPoint = self.env['account.bank.statement'].search([
- ('date','=',statement.date),
- ('journal_id.id', '=',statement.journal_id.id),
- ('period_id.id', '=', statement.period_id.id),
- ('type_statement', '=', 'normal'),
- ('state', '=', 'confirm')], order='id')
- pointSatatement = []
- for statementP in statementPoint:
- amount = 0.0
- for line in statementP.line_ids:
- amount += line.amount
- if (amount > 0):
- pointSatatement.append({
- 'name': statementP.name,
- 'date': statementP.date,
- 'journalId': statementP.journal_id.id,
- 'periodId': statementP.period_id.id,
- 'userId': statementP.user_id.id,
- 'userName': statementP.user_id.name,
- 'posSessionId': statementP.pos_session_id.id,
- 'posSessionName': statementP.pos_session_id.name,
- 'amount': amount
- })
- return pointSatatement
|