[IMP] quality_control_team_oca: black, isort, prettier

This commit is contained in:
Kaynnan Lemes
2024-02-22 12:25:09 -03:00
parent 22e343c5c6
commit 742fe85df8
30 changed files with 401 additions and 297 deletions

View File

@@ -1,60 +0,0 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class QualityControlTeam(models.Model):
_name = "qc.team"
_inherit = ['mail.thread']
_description = "Quality Control Team"
_order = "name"
@api.model
def _get_default_qc_team_id(self, user_id=None):
if not user_id:
user_id = self.env.uid
qc_team_id = None
if 'default_qc_team_id' in self.env.context:
qc_team_id = self.env['qc.team'].browse(
self.env.context.get('default_qc_team_id'))
if not qc_team_id or not qc_team_id.exists():
company_id = self.sudo(user_id).company_id.id
qc_team_id = self.env['qc.team'].sudo().search([
'|',
('user_id', '=', user_id),
('member_ids', '=', user_id),
'|',
('company_id', '=', False),
('company_id', 'child_of', [company_id])
], limit=1)
if not qc_team_id:
default_team_id = self.env.ref(
'quality_control_team.qc_team_main', raise_if_not_found=False)
if default_team_id:
qc_team_id = default_team_id
return qc_team_id
name = fields.Char(
string='Quality Control Team', required=True)
active = fields.Boolean(default=True)
company_id = fields.Many2one(
comodel_name='res.company', string='Company',
default=lambda self: self.env['res.company']._company_default_get(
'qc.team'))
user_id = fields.Many2one(
comodel_name='res.users', string='Team Leader')
member_ids = fields.One2many(
comodel_name='res.users', inverse_name='qc_team_id',
string='Team Members')
reply_to = fields.Char(
string='Reply-To',
help="The email address put in the 'Reply-To' of all emails sent by "
"Odoo about cases in this QC team")
color = fields.Integer(string='Color Index', help="The color of the team")
@api.model
def create(self, values):
return super(
QualityControlTeam,
self.with_context(mail_create_nosubscribe=True)).create(values)

View File

@@ -1,35 +0,0 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestQualityControlTeam(TransactionCase):
def setUp(self):
super(TestQualityControlTeam, self).setUp()
self.qc_team_obj = self.env['qc.team']
self.main_qc_team = self.env.ref('quality_control_team.qc_team_main')
self.other_company = self.env['res.company'].create({
'name': 'other company',
})
self.user_test = self.env['res.users'].create({
'name': 'Test User',
'login': 'testuser',
'company_id': self.other_company.id,
'company_ids': [(4, self.other_company.id)],
})
def test_default_qc_team(self):
"""Test that the QC team is defaulted correctly."""
team = self.qc_team_obj._get_default_qc_team_id(
user_id=self.user_test.id)
self.assertEqual(team, self.main_qc_team)
test_team = self.qc_team_obj.create({
'name': 'Test Team',
'user_id': self.user_test.id,
'company_id': self.other_company.id,
})
team = self.qc_team_obj._get_default_qc_team_id(
user_id=self.user_test.id)
self.assertEqual(team, test_team)

View File

@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<record id="qc_team_view_kanban" model="ir.ui.view" >
<field name="name">qc.team.dashboard</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<kanban class="o_kanban_dashboard oe_background_grey" create="0">
<field name="name"/>
<field name="user_id"/>
<field name="member_ids"/>
<field name="color"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)}">
<div class="o_kanban_card_header">
<div class="o_kanban_card_header_title">
<div class="o_primary"><field name="name"/></div>
</div>
<div class="o_kanban_manage_button_section">
<a class="o_kanban_manage_toggle_button" href="#"><i class="fa fa-ellipsis-v" role="img" aria-label="Manage" title="Manage"/></a>
</div>
</div>
<div class="container o_kanban_card_content">
<div class="row o_kanban_card_upper_content">
<div class="col-6 o_kanban_primary_left" name="card_left"/>
<div class="col-6 o_kanban_primary_right" name="card_right"/>
</div>
</div>
<div class="container o_kanban_card_manage_pane dropdown-menu" role="menu">
<div t-if="widget.editable" class="o_kanban_card_manage_settings row" groups="quality_control.group_quality_control_manager">
<div role="menuitem" aria-haspopup="true" class="col-8">
<ul class="oe_kanban_colorpicker" data-field="color" role="menu"/>
</div>
<div role="menuitem" class="col-4 text-right">
<a type="edit">Settings</a>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="qc_team_search" model="ir.ui.view">
<field name="name">Case Teams - Search</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<search string="QC teams Search">
<field name="name"/>
<field name="user_id"/>
<filter name="personal" string="My Teams"
domain="['|', ('member_ids', '=', uid), ('user_id', '=', uid)]"/>
<group expand="0" string="Group By...">
<filter name="group_user_id" string="Team Leader" domain="[]" context="{'group_by':'user_id'}"/>
</group>
</search>
</field>
</record>
<record id="qc_team_dashboard_act" model="ir.actions.act_window">
<field name="name">Dashboard</field>
<field name="res_model">qc.team</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,form</field>
<field name="context">{'search_default_personal':1}</field>
<field name="help" type="html">
<p>Define a new quality control teams going to <b><i>Configuration >
Quality Control Teams</i></b>.
</p>
</field>
</record>
<menuitem id="menu_qc_team_act" action="qc_team_dashboard_act"
sequence="1" parent="quality_control.qc_menu" name="Dashboard"/>
</odoo>

View File

@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<record id="qc_team_view_form" model="ir.ui.view">
<field name="name">qc.team.form</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<form string="Quality Control Team">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only" string="Quality Control team"/>
<h1>
<field name="name" placeholder="Quality Control Team name..."/>
</h1>
<div name="options_active"/>
</div>
<group>
<group name="left">
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager']}"/>
</group>
<group name="right">
</group>
</group>
<notebook>
<page name="members" string="Team Members">
<field name="member_ids" widget="many2many" options="{'not_delete': True}">
<kanban quick_create="false" create="true" delete="true">
<field name="id"/>
<field name="name"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click" style="max-width: 200px">
<div class="o_kanban_record_top">
<img t-att-src="kanban_image('res.users', 'image_small', record.id.raw_value)" height="40" width="40" class="oe_avatar oe_kanban_avatar_smallbox mb0"/>
<div class="o_kanban_record_headings ml8">
<strong class="o_kanban_record_title"><field name="name"/></strong>
</div>
<a t-if="! read_only_mode" type="delete" class="text-danger">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</page>
<page string="More Info" name="more_info" groups="base.group_no_one">
<group string="Company" groups="base.group_multi_company">
<field name="company_id" options="{'no_create': True}"/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"
help="Follow this QC team to automatically track the events associated to users of this team."/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record id="qc_team_view_tree" model="ir.ui.view">
<field name="name">qc.team.tree</field>
<field name="model">qc.team</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Quality Control Team">
<field name="name"/>
<field name="active" invisible="1"/>
<field name="user_id"/>
</tree>
</field>
</record>
<record id="qc_team_config_action" model="ir.actions.act_window">
<field name="name">Quality Control Teams</field>
<field name="res_model">qc.team</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to define a new quality control team.
</p><p>
Use quality control team to organize your different
departments into separate teams. Each team will work in
its own list of processes, stages...
</p>
</field>
</record>
<menuitem name="Quality Control Teams"
id="qc_team_config_menu"
groups="base.group_system"
parent="quality_control.menu_qc_config"
action="qc_team_config_action"
sequence="10"/>
</odoo>

View File

@@ -3,7 +3,7 @@
{
"name": "Quality Control Team",
"summary": "Adds quality control teams to handle different quality "
"control workflows",
"control workflows",
"version": "12.0.1.1.1",
"development_status": "Mature",
"category": "Quality Control",
@@ -13,9 +13,7 @@
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"quality_control",
],
"depends": ["quality_control",],
"data": [
"security/ir.model.access.csv",
"views/qc_team_view.xml",

View File

@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="0">
<record model="qc.team" id="qc_team_main">
<field name="name">Main QC Team</field>
<field name="member_ids" eval="[(4, ref('base.user_admin'))]"/>
<field name="member_ids" eval="[(4, ref('base.user_admin'))]" />
</record>
</data>

View File

@@ -0,0 +1,69 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class QualityControlTeam(models.Model):
_name = "qc.team"
_inherit = ["mail.thread"]
_description = "Quality Control Team"
_order = "name"
@api.model
def _get_default_qc_team_id(self, user_id=None):
if not user_id:
user_id = self.env.uid
qc_team_id = None
if "default_qc_team_id" in self.env.context:
qc_team_id = self.env["qc.team"].browse(
self.env.context.get("default_qc_team_id")
)
if not qc_team_id or not qc_team_id.exists():
company_id = self.sudo(user_id).company_id.id
qc_team_id = (
self.env["qc.team"]
.sudo()
.search(
[
"|",
("user_id", "=", user_id),
("member_ids", "=", user_id),
"|",
("company_id", "=", False),
("company_id", "child_of", [company_id]),
],
limit=1,
)
)
if not qc_team_id:
default_team_id = self.env.ref(
"quality_control_team.qc_team_main", raise_if_not_found=False
)
if default_team_id:
qc_team_id = default_team_id
return qc_team_id
name = fields.Char(string="Quality Control Team", required=True)
active = fields.Boolean(default=True)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env["res.company"]._company_default_get("qc.team"),
)
user_id = fields.Many2one(comodel_name="res.users", string="Team Leader")
member_ids = fields.One2many(
comodel_name="res.users", inverse_name="qc_team_id", string="Team Members"
)
reply_to = fields.Char(
string="Reply-To",
help="The email address put in the 'Reply-To' of all emails sent by "
"Odoo about cases in this QC team",
)
color = fields.Integer(string="Color Index", help="The color of the team")
@api.model
def create(self, values):
return super(
QualityControlTeam, self.with_context(mail_create_nosubscribe=True)
).create(values)

View File

@@ -5,7 +5,6 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
qc_team_id = fields.Many2one(
comodel_name='qc.team', string='Quality Control Team')
qc_team_id = fields.Many2one(comodel_name="qc.team", string="Quality Control Team")

View File

@@ -5,7 +5,6 @@ from odoo import fields, models
class ResUsers(models.Model):
_inherit = 'res.users'
_inherit = "res.users"
qc_team_id = fields.Many2one(
comodel_name='qc.team', string='Quality Control Team')
qc_team_id = fields.Many2one(comodel_name="qc.team", string="Quality Control Team")

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@@ -0,0 +1,34 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestQualityControlTeam(TransactionCase):
def setUp(self):
super(TestQualityControlTeam, self).setUp()
self.qc_team_obj = self.env["qc.team"]
self.main_qc_team = self.env.ref("quality_control_team.qc_team_main")
self.other_company = self.env["res.company"].create({"name": "other company",})
self.user_test = self.env["res.users"].create(
{
"name": "Test User",
"login": "testuser",
"company_id": self.other_company.id,
"company_ids": [(4, self.other_company.id)],
}
)
def test_default_qc_team(self):
"""Test that the QC team is defaulted correctly."""
team = self.qc_team_obj._get_default_qc_team_id(user_id=self.user_test.id)
self.assertEqual(team, self.main_qc_team)
test_team = self.qc_team_obj.create(
{
"name": "Test Team",
"user_id": self.user_test.id,
"company_id": self.other_company.id,
}
)
team = self.qc_team_obj._get_default_qc_team_id(user_id=self.user_test.id)
self.assertEqual(team, test_team)

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Copyright 2017-19 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<record id="qc_team_view_kanban" model="ir.ui.view">
<field name="name">qc.team.dashboard</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<kanban class="o_kanban_dashboard oe_background_grey" create="0">
<field name="name" />
<field name="user_id" />
<field name="member_ids" />
<field name="color" />
<templates>
<t t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)}">
<div class="o_kanban_card_header">
<div class="o_kanban_card_header_title">
<div class="o_primary"><field name="name" /></div>
</div>
<div class="o_kanban_manage_button_section">
<a class="o_kanban_manage_toggle_button" href="#"><i
class="fa fa-ellipsis-v"
role="img"
aria-label="Manage"
title="Manage"
/></a>
</div>
</div>
<div class="container o_kanban_card_content">
<div class="row o_kanban_card_upper_content">
<div
class="col-6 o_kanban_primary_left"
name="card_left"
/>
<div
class="col-6 o_kanban_primary_right"
name="card_right"
/>
</div>
</div>
<div
class="container o_kanban_card_manage_pane dropdown-menu"
role="menu"
>
<div
t-if="widget.editable"
class="o_kanban_card_manage_settings row"
groups="quality_control.group_quality_control_manager"
>
<div
role="menuitem"
aria-haspopup="true"
class="col-8"
>
<ul
class="oe_kanban_colorpicker"
data-field="color"
role="menu"
/>
</div>
<div role="menuitem" class="col-4 text-right">
<a type="edit">Settings</a>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="qc_team_search" model="ir.ui.view">
<field name="name">Case Teams - Search</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<search string="QC teams Search">
<field name="name" />
<field name="user_id" />
<filter
name="personal"
string="My Teams"
domain="['|', ('member_ids', '=', uid), ('user_id', '=', uid)]"
/>
<group expand="0" string="Group By...">
<filter
name="group_user_id"
string="Team Leader"
domain="[]"
context="{'group_by':'user_id'}"
/>
</group>
</search>
</field>
</record>
<record id="qc_team_dashboard_act" model="ir.actions.act_window">
<field name="name">Dashboard</field>
<field name="res_model">qc.team</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,form</field>
<field name="context">{'search_default_personal':1}</field>
<field name="help" type="html">
<p>Define a new quality control teams going to <b><i>Configuration >
Quality Control Teams</i></b>.
</p>
</field>
</record>
<menuitem
id="menu_qc_team_act"
action="qc_team_dashboard_act"
sequence="1"
parent="quality_control.qc_menu"
name="Dashboard"
/>
</odoo>

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<record id="qc_team_view_form" model="ir.ui.view">
<field name="name">qc.team.form</field>
<field name="model">qc.team</field>
<field name="arch" type="xml">
<form string="Quality Control Team">
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options='{"terminology": "archive"}'
/>
</button>
</div>
<div class="oe_title">
<label
for="name"
class="oe_edit_only"
string="Quality Control team"
/>
<h1>
<field
name="name"
placeholder="Quality Control Team name..."
/>
</h1>
<div name="options_active" />
</div>
<group>
<group name="left">
<field
name="user_id"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager']}"
/>
</group>
<group name="right">
</group>
</group>
<notebook>
<page name="members" string="Team Members">
<field
name="member_ids"
widget="many2many"
options="{'not_delete': True}"
>
<kanban
quick_create="false"
create="true"
delete="true"
>
<field name="id" />
<field name="name" />
<templates>
<t t-name="kanban-box">
<div
class="oe_kanban_global_click"
style="max-width: 200px"
>
<div class="o_kanban_record_top">
<img
t-att-src="kanban_image('res.users', 'image_small', record.id.raw_value)"
height="40"
width="40"
class="oe_avatar oe_kanban_avatar_smallbox mb0"
/>
<div
class="o_kanban_record_headings ml8"
>
<strong
class="o_kanban_record_title"
><field name="name" /></strong>
</div>
<a
t-if="! read_only_mode"
type="delete"
class="text-danger"
>
<i class="fa fa-times" />
</a>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</page>
<page
string="More Info"
name="more_info"
groups="base.group_no_one"
>
<group string="Company" groups="base.group_multi_company">
<field
name="company_id"
options="{'no_create': True}"
/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field
name="message_follower_ids"
widget="mail_followers"
help="Follow this QC team to automatically track the events associated to users of this team."
/>
<field name="message_ids" widget="mail_thread" />
</div>
</form>
</field>
</record>
<record id="qc_team_view_tree" model="ir.ui.view">
<field name="name">qc.team.tree</field>
<field name="model">qc.team</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Quality Control Team">
<field name="name" />
<field name="active" invisible="1" />
<field name="user_id" />
</tree>
</field>
</record>
<record id="qc_team_config_action" model="ir.actions.act_window">
<field name="name">Quality Control Teams</field>
<field name="res_model">qc.team</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to define a new quality control team.
</p><p>
Use quality control team to organize your different
departments into separate teams. Each team will work in
its own list of processes, stages...
</p>
</field>
</record>
<menuitem
name="Quality Control Teams"
id="qc_team_config_menu"
groups="base.group_system"
parent="quality_control.menu_qc_config"
action="qc_team_config_action"
sequence="10"
/>
</odoo>

View File

@@ -0,0 +1 @@
../../../../quality_control_team_oca

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)