state Workflow
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from odoo import fields, models, api
|
from odoo import fields, models, api, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
class StudentStudent(models.Model):
|
class StudentStudent(models.Model):
|
||||||
_name = 'student.student'
|
_name = 'student.student'
|
||||||
@@ -15,6 +16,20 @@ class StudentStudent(models.Model):
|
|||||||
phone = fields.Char(string='Số điện thoại')
|
phone = fields.Char(string='Số điện thoại')
|
||||||
course_ids = fields.Many2many('student.course', string='Môn học')
|
course_ids = fields.Many2many('student.course', string='Môn học')
|
||||||
|
|
||||||
|
state = fields.Selection([
|
||||||
|
('draft', 'Draft'),
|
||||||
|
('confirmed', 'Confirmed'),
|
||||||
|
('graduated', 'Graduated')
|
||||||
|
], string='Status', default='draft')
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
self.write({'state': 'confirmed'})
|
||||||
|
|
||||||
|
def action_graduate(self):
|
||||||
|
if not self.env.user.has_group('base.group_sysem'):
|
||||||
|
raise UserError(_("Only administrators can graduate students!"))
|
||||||
|
self.write({'state': 'graduated'})
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _generate_student_id(self):
|
def _generate_student_id(self):
|
||||||
last_student = self.search([], order='id desc', limit=1)
|
last_student = self.search([], order='id desc', limit=1)
|
||||||
|
|||||||
@@ -21,6 +21,14 @@
|
|||||||
<field name="model">student.student</field>
|
<field name="model">student.student</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Form học sinh">
|
<form string="Form học sinh">
|
||||||
|
<header>
|
||||||
|
<button name="action_confirm" type="object"
|
||||||
|
string="Confirm" class="btn-primary"
|
||||||
|
invisible="state != 'draft'" />
|
||||||
|
<button name="action_graduate" type="object"
|
||||||
|
string="Graduate" class="btn-success"
|
||||||
|
invisible="state != 'confirmed'" />
|
||||||
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
Reference in New Issue
Block a user