assign_roll_no.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
  6. # Copyright (C) 2011-Today Serpent Consulting Services PVT. LTD.
  7. # (<http://www.serpentcs.com>)
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ##############################################################################
  22. from openerp import models, fields, api
  23. # This wizard is designed for assigning the roll number to a student.
  24. class AssignRollNo(models.TransientModel):
  25. _name = 'assign.roll.no'
  26. _description = 'Assign Roll Number'
  27. standard_id = fields.Many2one('standard.standard', 'Class', required=True)
  28. medium_id = fields.Many2one('standard.medium', 'Medium', required=True)
  29. division_id = fields.Many2one('standard.division', 'Division',
  30. required=True)
  31. @api.multi
  32. def assign_rollno(self):
  33. res = {}
  34. student_obj = self.env['student.student']
  35. for stud_data in self:
  36. student_ids = student_obj.search([('standard_id', '=',
  37. stud_data.standard_id.id),
  38. ('medium_id', '=',
  39. stud_data.medium_id.id),
  40. ('division_id', '=',
  41. stud_data.division_id.id)])
  42. number = 1
  43. for student in student_ids:
  44. student.write({'roll_no': number})
  45. number = number + 1
  46. return res