You can make your record in two states :-1.)State="OPEN",2.)State="Submitted".
Once you submitted the record then the creator of the record cannot edit it , then only Project Manager or the Admin can edit the record.
Make a new Group "Can_Edit_Group" in the settings-->Users-->Groups.And add the project manager into it.
You need to add state and edit_group field in your _columns in your .py file.
_columns={
'state':fields.selection([('open', 'Open'), ('submitted','Submitted'),],'Status', readonly=True),
'edit_group':fields.many2one('res.groups', string='HR Manager Group'),
}
def _get_edit_group(self, cr, uid, context=None):
all_groups=self.pool.get('res.groups')
edit_group = all_groups.browse(cr, uid, all_groups.search(cr,uid,[('name','=','Can_Edit_Group')])[0]).id
return edit_group
_defaults = {
'edit_group':lambda self, cr, uid, context:self._get_edit_group( cr, uid, context=None)
}
def change_state(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'state' : 'submitted' })
return True
In XML add a button to change the record state on click.
Put the button inside the header tag. If you are inheriting the View then do it using the Xpath else,
put the header tag after you open the form tag.
<header>
<group attrs="{'invisible':[('state','=','submitted' )]}">
<button name="change_state" string="Submit" type="object" states="open" class="oe_highlight"/>
</group>
<field name="state" widget="statusbar" statusbar_visible="open,submitted"/>
<header>
In the record rule you can enter this rule:
This will check if the state="submitted" and edit_group i.e the id of the group of whom users can edit the record are "in" the logged in user group.If this condition satisfy then the logged in user can edit the record else not.
['&',('state','=','submitted'),('edit_group','in',[g.id for g in user.groups_id])]
Give them all the access i.e check the boolean field read,write,create,delete and add the group into it i.e. add the Can_Edit_Group
And don forget to add the your object and give record a name. And check the Active field.
I hope this is what you were looking for.