Skip to Content
Menu
This question has been flagged
1 Reply
3308 Views

Hi... ,please help me again..

I have 3 statusbar (Request, To approve, Approved). If manger approve a ot request in "To approve" state, statusbar move to "Approved" state.In that state, I want to do readonly for all users and managers.I dont want to see Edit and Create Button in that  state.

Here My Python and Xml.file and Record rules for manager.

state = fields.Selection ([
('new', 'Request'), ('to_approve', 'To Approve'), ('done', 'Approved')],
default = 'new')

@ api.one
def con_request (self):
self.write ({'state': 'to_approve'})

@ api.one
def mng_approve (self):
self.write ({'state': 'done'})

Xml............................................

<record id = "hr_ot_request_view_form" model = "ir.ui.view">
<field name = "name"> hr.otrequest.view.form </field>
<field name = "model"> hr.employee.otrequest < / field>
<field name = "arch" type = "xml">
<form>
<header>
<button string = "Confirm Request" type = "object" name = "con_request" class = "oe_highlight" attrs = "{' invisible ': [(' state ',' not in ',' new ')} "/>
<button string =" Approve "type =" object "name =" mng_approve "class =" oe_highlight "groups =" base. group_hr_manager "attrs =" {'invisible': [(' state ',' not in ',' to_approve ')]} "/>

<field name =" state "widget =" statusbar "statusbar_colors =' {" new ":" red "," to_approve ":" blue "," done ":" green "} '/>
</header>

Rcord Rules For manager.........

<record id = "ot_request_rule_manager" model = "ir.rule">
<field name = "name"> Ot request only for manager </field>
<field name = "model_id" ref = "model_hr_employee_otrequest" />
<field name = "domain_force"> [('department_user_id', '=', user.id), ('state', 'in', ['to_approve', 'done'])]
</field>
<field name = "groups" eval = "[(4, ref ('base.group_hr_manager'))]" />
</record>

Thank you..

Avatar
Discard
Best Answer

Hi @Hannay ,

Use the below attributes in your <form> tag

<form string="XYZ Form" create="false"  edit="false">

</form>

Avatar
Discard