account_bank_statement.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, tools, api
  3. class AccountBankStatement(models.Model):
  4. _inherit = 'account.bank.statement'
  5. type_statement = fields.Selection([('normal', 'Normal'),('general', 'General')],'Tipo de Caja ', default="normal", help="Tipo de caja")
  6. @api.model
  7. def get_statement_point_of_sale(self, id):
  8. accountStatement = self.env['account.bank.statement'].browse(id)
  9. decimal_precision = self.env['decimal.precision'].precision_get('Account')
  10. if (not accountStatement):
  11. return False
  12. statementPointOfSale = self._get_statement_point_of_sale(accountStatement)
  13. if (not statementPointOfSale):
  14. return False
  15. statementLine = []
  16. for line in statementPointOfSale:
  17. lineStatement = self.env['account.bank.statement.line'].search([('name', '=', line['name'])])
  18. if (not lineStatement):
  19. amount = line['amount']
  20. statementLine.append([0, False, {
  21. 'name': line['name'],
  22. 'ref' : 'Responsable/'+line['userName'],
  23. 'amount': round(float(amount), decimal_precision),
  24. 'journal_id': accountStatement.journal_id.id,
  25. 'account_id': accountStatement.journal_id.internal_account_id.id,
  26. 'statement_id': accountStatement.id,
  27. 'date': line['date'],
  28. }])
  29. line = []
  30. if (not statementLine):
  31. return False
  32. line = accountStatement.write({'line_ids': statementLine})
  33. if (not line):
  34. return False
  35. return len(statementLine)
  36. '''
  37. Get Account Bank Statement Point of Sale
  38. '''
  39. def _get_statement_point_of_sale(self, statement):
  40. statementPoint = self.env['account.bank.statement'].search([
  41. ('date','=',statement.date),
  42. ('journal_id.id', '=',statement.journal_id.id),
  43. ('period_id.id', '=', statement.period_id.id),
  44. ('type_statement', '=', 'normal'),
  45. ('state', '=', 'confirm')], order='id')
  46. pointSatatement = []
  47. for statementP in statementPoint:
  48. amount = 0.0
  49. for line in statementP.line_ids:
  50. amount += line.amount
  51. if (statementP.balance_start > 0):
  52. amount += statementP.balance_start
  53. if (amount > 0):
  54. pointSatatement.append({
  55. 'name': statementP.name,
  56. 'date': statementP.date,
  57. 'journalId': statementP.journal_id.id,
  58. 'periodId': statementP.period_id.id,
  59. 'userId': statementP.user_id.id,
  60. 'userName': statementP.user_id.name,
  61. 'posSessionId': statementP.pos_session_id.id,
  62. 'posSessionName': statementP.pos_session_id.name,
  63. 'amount': amount
  64. })
  65. return pointSatatement