account_bank_statement.py 1012 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, tools, api
  3. class AccountBankStatement(models.Model):
  4. _inherit = 'account.bank.statement'
  5. @api.model
  6. def _default_type_statement(self):
  7. typeStatement = self.env['account.bank.statement.type'].search([('is_default', '=', True)],limit=1)
  8. return typeStatement.id if (typeStatement) else ''
  9. type_statement = fields.Many2one('account.bank.statement.type', string='Tipo de Caja', ondelete='restrict')
  10. _defaults = {
  11. 'type_statement': _default_type_statement,
  12. }
  13. @api.model
  14. def update_statement_type_defualt(self):
  15. type = self.env['account.bank.statement.type'].search([('is_default', '=', True)],limit=1)
  16. statement = self.env['account.bank.statement'].search([('type_statement', '=', False)])
  17. if (not statement):
  18. return False
  19. for statementUpdate in statement:
  20. statementUpdate.write({
  21. 'type_statement': type.id
  22. })