adding page visibility based on stages
This commit is contained in:
parent
7b6d108ace
commit
92543295d6
|
|
@ -17,3 +17,4 @@ from . import project_task
|
|||
from . import timesheets
|
||||
# from . import project_task_gantt
|
||||
from . import user_availability
|
||||
from . import stage_visibility
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProjectProject(models.Model):
|
||||
_inherit = 'project.project'
|
||||
|
||||
is_initiation_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_planning_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_development_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_testing_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_deployment_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_maintenance_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_closure_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_architecture_user = fields.Boolean(compute='_compute_stage_access')
|
||||
is_project_editor = fields.Boolean(compute='_compute_stage_access')
|
||||
|
||||
def _compute_stage_access(self):
|
||||
user = self.env.user
|
||||
|
||||
for project in self:
|
||||
flows = self.env['project.stages.approval.flow'].search([
|
||||
('project_id', '=', project.id)
|
||||
])
|
||||
|
||||
stages = flows.filtered(
|
||||
lambda f:
|
||||
f.assigned_to == user
|
||||
or f.approval_by == user
|
||||
or user in f.involved_users
|
||||
or user.has_group('project.group_project_manager')
|
||||
).mapped('stage_id.name')
|
||||
project_editor = False
|
||||
if (project.user_id and user == project.user_id) or (project.project_sponsor and user == project.project_sponsor):
|
||||
project_editor = True
|
||||
|
||||
|
||||
project.is_initiation_user = 'Initiation' in stages
|
||||
project.is_planning_user = 'Planning' in stages
|
||||
project.is_development_user = 'Development' in stages
|
||||
project.is_testing_user = 'Testing' in stages
|
||||
project.is_deployment_user = 'Deployment' in stages
|
||||
project.is_maintenance_user = 'Maintenance & Support' in stages
|
||||
project.is_closure_user = 'Closer' in stages
|
||||
project.is_architecture_user = 'Architecture & Design' in stages
|
||||
project.is_project_editor = project_editor
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Normal users: see only stages where they are involved -->
|
||||
<record id="project_stage_visibility_user_rule" model="ir.rule">
|
||||
<field name="name">Project Stage Visibility - User</field>
|
||||
<field name="model_id" ref="model_project_stages_approval_flow"/>
|
||||
<field name="domain_force">
|
||||
[
|
||||
'|',
|
||||
('assigned_to', '=', user.id),
|
||||
'|',
|
||||
('approval_by', '=', user.id),
|
||||
'|',
|
||||
('involved_users', 'in', user.id),
|
||||
'|',
|
||||
('project_id.user_id', '=', user.id),
|
||||
('project_id.project_lead', '=', user.id)
|
||||
]
|
||||
</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
|
||||
</record>
|
||||
|
||||
<!-- Project managers see everything -->
|
||||
<record id="project_stage_visibility_manager_rule" model="ir.rule">
|
||||
<field name="name">Project Stage Visibility - Manager</field>
|
||||
<field name="model_id" ref="model_project_stages_approval_flow"/>
|
||||
<field name="domain_force">[(1,'=',1)]</field>
|
||||
<field name="groups" eval="[(4, ref('project.group_project_manager'))]"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
@ -69,14 +69,17 @@
|
|||
<field name="show_approval_button" invisible="1"/>
|
||||
<field name="show_refuse_button" invisible="1"/>
|
||||
<field name="show_back_button" invisible="1"/>
|
||||
<field name="is_project_editor" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='stage_id']" position="attributes">
|
||||
<attribute name="domain">[('id', 'in', showable_stage_ids)]</attribute>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="//page[@name='settings']" position="attributes">
|
||||
<attribute name="invisible">not is_project_editor</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='settings']" position="before">
|
||||
<page name="project_stages" string="Project Stages" invisible="not assign_approval_flow">
|
||||
<page name="project_stages" string="Project Stages" invisible="not assign_approval_flow or not is_project_editor">
|
||||
<field name="project_stages" options="{'no_create': True, 'no_open': True, 'no_delete': True}">
|
||||
<list editable="bottom" delete="0" create="0">
|
||||
<field name="stage_id" readonly="1"/>
|
||||
|
|
@ -94,7 +97,7 @@
|
|||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page name="task_stages" string="Task Stages">
|
||||
<page name="task_stages" string="Task Stages" invisible="not is_project_editor">
|
||||
<field name="type_ids" context="{'project_id': id}" options="{'no_open': True}">
|
||||
<list edit="0" no_open="True">
|
||||
<field name="sequence"/>
|
||||
|
|
@ -110,7 +113,7 @@
|
|||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Team">
|
||||
<page string="Team" name="team" invisible="not is_project_editor">
|
||||
<group>
|
||||
<button name="fetch_project_task_stage_users" type="object" string="Fetch Users from Related Stages" class="btn-primary"/>
|
||||
<button name="add_users" type="object" string="Add/Update" class="btn-secondary"/>
|
||||
|
|
@ -138,6 +141,9 @@
|
|||
<xpath expr="//field[@name='description']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='description']" position="attributes">
|
||||
<attribute name="invisible">not is_initiation_user</attribute>
|
||||
</xpath>
|
||||
<page name="description" position="inside">
|
||||
<group>
|
||||
<field name="project_vision"
|
||||
|
|
@ -249,7 +255,7 @@
|
|||
</xpath>
|
||||
|
||||
<xpath expr="//sheet/notebook/page[@name='settings']" position="after">
|
||||
<page name="planning" string="Planning (Budget & Deadlines)">
|
||||
<page name="planning" string="Planning (Budget & Deadlines)" invisible="not is_planning_user">
|
||||
<group>
|
||||
|
||||
<group string="project Scope">
|
||||
|
|
@ -363,7 +369,7 @@
|
|||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//sheet/notebook" position="inside">
|
||||
<page name="architecture_design" string="Architecture & Design">
|
||||
<page name="architecture_design" string="Architecture & Design" invisible="not is_architecture_user">
|
||||
|
||||
<field name="architecture_design_ids">
|
||||
<list>
|
||||
|
|
@ -417,7 +423,7 @@
|
|||
</list>
|
||||
</field>
|
||||
</page>
|
||||
<page name="development" string="Development Details">
|
||||
<page name="development" string="Development Details" invisible="not is_development_user">
|
||||
<group string="Documents">
|
||||
<field name="development_document_ids">
|
||||
<list editable="bottom">
|
||||
|
|
@ -460,7 +466,7 @@
|
|||
<field name="development_notes" nolabel="1" placeholder="click hear to write comments"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Testing Documents">
|
||||
<page name="testing" string="Testing Documents" invisible="not is_testing_user">
|
||||
<group string="Documents">
|
||||
<field name="testing_document_ids">
|
||||
<list editable="bottom">
|
||||
|
|
@ -485,7 +491,7 @@
|
|||
<field name="testing_notes" nolabel="1" placeholder="click hear to write comments"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Deployment" name="deployment">
|
||||
<page string="Deployment" name="deployment" invisible="not is_deployment_user">
|
||||
<field name="deployment_log_ids" mode="kanban" colspan="4" nolabel="1">
|
||||
<kanban class="o_kanban_small_column o_deployment_kanban">
|
||||
<field name="deployment_date"/>
|
||||
|
|
@ -602,10 +608,10 @@
|
|||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Maintenance & Support">
|
||||
<page name="maintenance_support" string="Maintenance & Support" invisible="not is_maintenance_user">
|
||||
<field name="maintenance_support_ids" mode="kanban"/>
|
||||
</page>
|
||||
<page string="Closure">
|
||||
<page name="closure" string="Closure" invisible="not is_closure_user">
|
||||
|
||||
<!-- A. Closure Checklist -->
|
||||
<group string="Closure Checklist">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="project_project_form_tab_visibility" model="ir.ui.view">
|
||||
<field name="name">project.project.form.tab.visibility</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="inherit_id" ref="project_task_timesheet_extended.project_project_inherit_form_view2"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<!-- Initiation -->
|
||||
<xpath expr="//page[@name='description']" position="attributes">
|
||||
<attribute name="invisible">not is_initiation_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Planning -->
|
||||
<xpath expr="//page[@name='planning']" position="attributes">
|
||||
<attribute name="invisible">not is_planning_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Architecture -->
|
||||
<xpath expr="//page[@name='architecture_design']" position="attributes">
|
||||
<attribute name="invisible">not is_architecture_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Development -->
|
||||
<xpath expr="//page[@name='development']" position="attributes">
|
||||
<attribute name="invisible">not is_development_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Testing -->
|
||||
<xpath expr="//page[@name='testing']" position="attributes">
|
||||
<attribute name="invisible">not is_testing_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Deployment -->
|
||||
<xpath expr="//page[@name='deployment']" position="attributes">
|
||||
<attribute name="invisible">not is_deployment_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Maintenance -->
|
||||
<xpath expr="//page[@name='maintenance_support']" position="attributes">
|
||||
<attribute name="invisible">not is_maintenance_user</attribute>
|
||||
</xpath>
|
||||
|
||||
<!-- Closure -->
|
||||
<xpath expr="//page[@name='closure']" position="attributes">
|
||||
<attribute name="invisible">not is_closure_user</attribute>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue