internal team model update

This commit is contained in:
karuna 2025-11-10 10:14:09 +05:30
parent 5f267e96da
commit 2dbdb58127
3 changed files with 74 additions and 34 deletions

View File

@ -11,6 +11,24 @@ class InternalTeams(models.Model):
active = fields.Boolean(default=True, help="Set active to false to hide the Teams without removing it.") active = fields.Boolean(default=True, help="Set active to false to hide the Teams without removing it.")
parent_id = fields.Many2one('internal.teams', string="Parent Team",
domain="[('id', '!=', id)]")
child_ids = fields.One2many('internal.teams', 'parent_id', string="Child Teams")
active = fields.Boolean(default=True)
# Computed field to include members + child team members and leads
all_members_ids = fields.Many2many(
'res.users', compute='_compute_all_members', string="All Members", store=False
)
@api.depends('members_ids', 'child_ids.members_ids', 'child_ids.team_lead')
def _compute_all_members(self):
for rec in self:
all_members = rec.members_ids
for child in rec.child_ids:
all_members |= child.members_ids | child.team_lead
rec.all_members_ids = all_members
def _compute_display_name(self): def _compute_display_name(self):
""" Custom display_name in case a registration is nott linked to an attendee """ Custom display_name in case a registration is nott linked to an attendee

View File

@ -66,5 +66,8 @@
</record> </record>
</data> </data>
<data>
</data>
</odoo> </odoo>

View File

@ -11,6 +11,7 @@
</list> </list>
</field> </field>
</record> </record>
<record id="internal_teams_form_view" model="ir.ui.view"> <record id="internal_teams_form_view" model="ir.ui.view">
<field name="name">internal.teams.form.view</field> <field name="name">internal.teams.form.view</field>
<field name="model">internal.teams</field> <field name="model">internal.teams</field>
@ -20,6 +21,10 @@
<group> <group>
<field name="team_name"/> <field name="team_name"/>
<field name="team_lead"/> <field name="team_lead"/>
<!-- ✅ added -->
<field name="parent_id"/>
</group>
<notebook> <notebook>
<page name="team_members" string="Team"> <page name="team_members" string="Team">
<field name="members_ids" widget="many2many"> <field name="members_ids" widget="many2many">
@ -48,9 +53,24 @@
</templates> </templates>
</kanban> </kanban>
</field> </field>
<!-- ✅ added: show combined team members including child team leads and members -->
<field name="all_members_ids" widget="many2many_tags" readonly="1"
string="Including Child Teams"/>
</page> </page>
<!-- ✅ added: Child Teams tab -->
<page name="child_teams" string="Child Teams">
<field name="child_ids">
<list editable="bottom">
<field name="team_name"/>
<field name="team_lead"/>
<field name="members_ids" widget="many2many_tags"/>
</list>
</field>
</page>
</notebook> </notebook>
</group>
</sheet> </sheet>
</form> </form>
</field> </field>
@ -63,8 +83,7 @@
<field name="view_mode">list,form</field> <field name="view_mode">list,form</field>
</record> </record>
<menuitem id="internal_teams_menu" name="Internal Teams"
<menuitem id="internal_teams_menu" name="Internal Teams" action="internal_teams_action_tree" action="internal_teams_action_tree"
parent="project.menu_project_config"/> parent="project.menu_project_config"/>
</odoo> </odoo>