Skip to content

Commit

Permalink
[16.0] adds res.team model
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadrien Huvelle committed Oct 30, 2024
1 parent 52f198a commit b884e54
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 0 deletions.
1 change: 1 addition & 0 deletions partner_team/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions partner_team/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 camptocamp (<http://www.camptocamp.ch)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Partner Team",
"version": "16.0.1.0.0",
"category": "Contacts",
"author": "Camptocamp, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"license": "AGPL-3",
"depends": ["base", "contacts", "partner_contact_role"],
"data": [
"security/ir.model.access.csv",
"views/res_partner_views.xml",
"views/res_team_views.xml",
"views/rel_team_partner_views.xml",
],
"installable": True,
"application": True,
}
3 changes: 3 additions & 0 deletions partner_team/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import rel_team_partner
from . import res_partner
from . import res_team
10 changes: 10 additions & 0 deletions partner_team/models/rel_team_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class RelTeamPartner(models.Model):

_name = "rel.team.partner"
_mailing_enabled = True
partner_id = fields.Many2one("res.partner")
team_id = fields.Many2one("res.team")
role_ids = fields.Many2many("res.partner.role", string="Roles", required=True)
8 changes: 8 additions & 0 deletions partner_team/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

rel_team_ids = fields.One2many("rel.team.partner", "partner_id", string="Teams")
# team_ids = fields.Many2many(related="rel_team_ids.team_id", string="Teams")
16 changes: 16 additions & 0 deletions partner_team/models/res_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import fields, models


class Team(models.Model):
_name = "res.team"
_inherit = ["image.mixin"]

def _mailing_get_default_domain(self, mailing):
return [("list_ids", "in", mailing.partner_ids.ids)]

active = fields.Boolean(default=True)
name = fields.Char(
string="Name of your team",
required=True,
)
rel_team_ids = fields.One2many("rel.team.partner", "team_id", string="Partners")
5 changes: 5 additions & 0 deletions partner_team/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_team_group_user,ir.filters.group,model_res_team,base.group_user,1,0,0,0
access_res_team_group_system,ir.filters.group,model_res_team,base.group_system,1,1,1,1
access_rel_team_partner_group_user,ir.filters.group,model_rel_team_partner,base.group_user,1,0,0,0
access_rel_team_partner_group_system,ir.filters.group,model_rel_team_partner,base.group_system,1,1,1,1
22 changes: 22 additions & 0 deletions partner_team/views/rel_team_partner_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<odoo>
<record id="base_view_rel_team_partner_form" model="ir.ui.view">
<field name="name">rel.team.partner.view.form</field>
<field name="model">rel.team.partner</field>
<field name="arch" type="xml">
<form>
<sheet>
<notebook>
<page string="Members">
<field name="partner_id" />
<field name="role_ids">
<tree editable="bottom">
<field name="name" string="Roles" />
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</odoo>
101 changes: 101 additions & 0 deletions partner_team/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field
name="name"
>res.config.settings.view.form.inherit.sportclub.base</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="70" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div
class="app_settings_block o_sportclub_base_block"
data-string="SportClub_Base"
string="Sport Club"
data-key="sportclub_base"
groups="base.group_user"
invisible="1"
>
<h2>Sport Club</h2>
</div>
</xpath>
<xpath
expr="//div[hasclass('o_sportclub_base_block')]"
position="attributes"
>
<attribute name="invisible">0</attribute>
</xpath>
<xpath
expr="//div[hasclass('o_sportclub_base_block')]"
position="inside"
>
<div class="row mt16 o_settings_container">
<div class="o_setting_box col-12 col-lg-6">

<div
class="o_setting_right_pane o_sportclub_base_right_pane"
>
<h2>Club informations</h2>
<div class="content-group">
<div class="row ">
<label
class="o_form_label col-lg-12"
for="sportclub_name"
/>
<field name="sportclub_name" />
</div>
<div class="row">
<label
class="o_form_label col-lg-12"
for="sportclub_matr"
/>
<field name="sportclub_matr" />
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>

</record>

<record id="settings_action" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="res_model">res.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field
name="context"
eval="{'module': 'general_settings', 'bin_size': False}"
/>
</record>

<record id="configuration_action" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field
name="context"
>{'module': 'sportclub_base', 'bin_size': False}</field>
</record>



<menuitem
name="Sport Club"
id="menu_sportclub"
sequence="95"
groups="base.group_user"
web_icon="sportclub_base,static/description/icon.png"
/>



</data>
</odoo>
20 changes: 20 additions & 0 deletions partner_team/views/res_partner_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="base_view_partner_form" model="ir.ui.view">
<field name="name">partner_team.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page string="Teams">
<field name="rel_team_ids">
<tree>
<field name="team_id" />
<field name="role_ids" widget="many2many_tags" />
</tree>
</field>
</page>
</notebook>
</field>
</record>
</odoo>
149 changes: 149 additions & 0 deletions partner_team/views/res_team_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="base_view_team_form" model="ir.ui.view">
<field name="name">partner_teamres.team.form</field>
<field name="model">res.team</field>
<field name="priority" eval="20" />
<field name="arch" type="xml">
<form string="Teams">
<sheet>
<div class="oe_button_box" name="button_box" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<field name="image_128" invisible="1" />
<field
name="image_1920"
widget='image'
class="oe_avatar"
options='{"preview_image": "avatar_128"}'
/>
<div class="oe_title mb24">
<h1>
<field
id="name"
class="text-break"
name="name"
default_focus="1"
placeholder="e.g. Lumber Inc"
/>
</h1>

</div>
<notebook>
<page string="Members">
<field name="rel_team_ids">
<tree editable="bottom">
<field name="partner_id" />
<field name="role_ids" widget="many2many_tags" />
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="base_view_team_kanban" model="ir.ui.view">
<field name="name">partner_teamres.team.kanban</field>
<field name="model">res.team</field>
<field name="arch" type="xml">
<kanban>
<field name="name" />
<field name="rel_team_ids" />
<field name="active" />
<templates>
<t t-name="kanban-box">
<div
class="oe_kanban_global_click o_kanban_record_has_image_fill"
>

<div
class="o_kanban_image_fill_left o_kanban_image_full"
t-attf-style="background-image: url(#{kanban_image('res.team', 'image_128', record.id)})"
role="img"
/>

<div
class="ribbon ribbon-top-right"
attrs="{'invisible': [('active', '=', True)]}"
>
<span class="bg-danger">Archived</span>
</div>
<div
class="oe_kanban_details d-flex flex-column justify-content-between"
>
<div>
<strong class="o_kanban_record_title ">
<field name="name" />
</strong>
<div class="o_kanban_tags_section" />
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left" />
<div class="oe_kanban_bottom_right" />
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="base_view_team_tree" model="ir.ui.view">
<field name="name">partner_teamres.team.tree</field>
<field name="model">res.team</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="rel_team_ids" />
</tree>
</field>
</record>

<record id="action_teams_menu" model="ir.actions.act_window">
<field name="name">Teams</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.team</field>
<field name="view_mode">tree,form,kanban</field>
<field name="context">{'default_is_company': True}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a Team to organize your partners
</p>
<p>
Odoo helps you track all activities related to your teams.
</p>
</field>
</record>
<record id="action_teams_menu_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">tree</field>
<field name="view_id" ref="base_view_team_tree" />
<field name="act_window_id" ref="action_teams_menu" />
</record>
<record id="action_teams_menu_form" model="ir.actions.act_window.view">
<field name="sequence" eval="1" />
<field name="view_mode">form</field>
<field name="view_id" ref="base_view_team_form" />
<field name="act_window_id" ref="action_teams_menu" />
</record>
<record id="action_teams_menu_kanban" model="ir.actions.act_window.view">
<field name="sequence" eval="2" />
<field name="view_mode">kanban</field>
<field name="view_id" ref="base_view_team_kanban" />
<field name="act_window_id" ref="action_teams_menu" />
</record>

<menuitem
id="res_team_menu_contacts"
name="Teams"
action="action_teams_menu"
parent="contacts.menu_contacts"
sequence="2"
/>
</odoo>
1 change: 1 addition & 0 deletions setup/partner_team/odoo/addons/partner_team
6 changes: 6 additions & 0 deletions setup/partner_team/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit b884e54

Please sign in to comment.