|
@@ -4,77 +4,100 @@ 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']
|
|
|
+ def _default_type_statement(self):
|
|
|
+ typeStatement = self.env['account.bank.statement.type'].search([('is_default', '=', True)],limit=1)
|
|
|
+ return typeStatement.id if (typeStatement) else ''
|
|
|
|
|
|
- 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'],
|
|
|
- }])
|
|
|
+ type_statement = fields.Many2one('account.bank.statement.type', string='Tipo de Caja', ondelete='restrict')
|
|
|
|
|
|
- line = []
|
|
|
+ _defaults = {
|
|
|
+ 'type_statement': _default_type_statement,
|
|
|
+ }
|
|
|
|
|
|
- if (not statementLine):
|
|
|
- return False
|
|
|
-
|
|
|
- line = accountStatement.write({'line_ids': statementLine})
|
|
|
- if (not line):
|
|
|
+ @api.model
|
|
|
+ def update_statement_type_defualt(self):
|
|
|
+ type = self.env['account.bank.statement.type'].search([('is_default', '=', True)],limit=1)
|
|
|
+ statement = self.env['account.bank.statement'].search([('type_statement', '=', False)])
|
|
|
+ if (not statement):
|
|
|
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 (statementP.balance_start > 0):
|
|
|
- amount += statementP.balance_start
|
|
|
+ for statementUpdate in statement:
|
|
|
+ statementUpdate.write({
|
|
|
+ 'type_statement': type.id
|
|
|
+ })
|
|
|
|
|
|
- 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
|
|
|
+ # @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 (statementP.balance_start > 0):
|
|
|
+ # amount += statementP.balance_start
|
|
|
+ #
|
|
|
+ # 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
|