Skip to content

Commit

Permalink
[IMP] quality_control_oca: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mymage authored and peluko00 committed May 14, 2024
1 parent 9a2914e commit d6354de
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 96 deletions.
40 changes: 17 additions & 23 deletions quality_control_oca/data/quality_control_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@
Copyright 2017 Simone Rubino - Agile Business Group
Copyright 2021 Tecnativa - Carlos Roca
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="1">
<record id="qc_test_template_category_generic" model="qc.test.category">
<field name="name">Generic</field>
</record>
<record id="qc_test_template_category_referenced" model="qc.test.category">
<field name="name">Referenced</field>
</record>
<record
forcecreate="True"
id="decimal_quality_control"
model="decimal.precision"
>
<field name="name">Quality Control</field>
<field name="digits">5</field>
</record>
<record id="seq_qc_inspection" model="ir.sequence">
<field name="name">Quality inspection</field>
<field name="code">qc.inspection</field>
<field name="prefix">QC-</field>
<field name="padding">6</field>
</record>
</data>
<odoo noupdate="1">
<record id="qc_test_template_category_generic" model="qc.test.category">
<field name="name">Generic</field>
</record>
<record id="qc_test_template_category_referenced" model="qc.test.category">
<field name="name">Referenced</field>
</record>
<record forcecreate="True" id="decimal_quality_control" model="decimal.precision">
<field name="name">Quality Control</field>
<field name="digits">5</field>
</record>
<record id="seq_qc_inspection" model="ir.sequence">
<field name="name">Quality inspection</field>
<field name="code">qc.inspection</field>
<field name="prefix">QC-</field>
<field name="padding">6</field>
</record>
</odoo>
62 changes: 30 additions & 32 deletions quality_control_oca/demo/quality_control_demo.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<record model="qc.test" id="qc_test_1">
<field name="name">Generic Test (demo)</field>
<field name="type">generic</field>
<field name="active" eval="True" />
<field name="category" ref="qc_test_template_category_generic" />
</record>
<record model="qc.test.question" id="qc_test_question_1">
<field name="name">Overall quality</field>
<field name="test" ref="qc_test_1" />
<field name="type">qualitative</field>
</record>
<record model="qc.test.question.value" id="qc_test_question_value_1">
<field name="name">Good</field>
<field name="ok" eval="True" />
<field name="test_line" ref="qc_test_question_1" />
</record>
<record model="qc.test.question.value" id="qc_test_question_value_2">
<field name="name">Bad</field>
<field name="ok" eval="False" />
<field name="test_line" ref="qc_test_question_1" />
</record>
<record model="qc.test.question" id="qc_test_question_2">
<field name="name">Size</field>
<field name="test" ref="qc_test_1" />
<field name="type">quantitative</field>
<field name="min_value" eval="1.0" />
<field name="max_value" eval="10.0" />
<field name="uom_id" ref="uom.product_uom_unit" />
</record>
</data>
<odoo noupdate="1">
<record model="qc.test" id="qc_test_1">
<field name="name">Generic Test (demo)</field>
<field name="type">generic</field>
<field name="active" eval="True" />
<field name="category" ref="qc_test_template_category_generic" />
</record>
<record model="qc.test.question" id="qc_test_question_1">
<field name="name">Overall quality</field>
<field name="test" ref="qc_test_1" />
<field name="type">qualitative</field>
</record>
<record model="qc.test.question.value" id="qc_test_question_value_1">
<field name="name">Good</field>
<field name="ok" eval="True" />
<field name="test_line" ref="qc_test_question_1" />
</record>
<record model="qc.test.question.value" id="qc_test_question_value_2">
<field name="name">Bad</field>
<field name="ok" eval="False" />
<field name="test_line" ref="qc_test_question_1" />
</record>
<record model="qc.test.question" id="qc_test_question_2">
<field name="name">Size</field>
<field name="test" ref="qc_test_1" />
<field name="type">quantitative</field>
<field name="min_value" eval="1.0" />
<field name="max_value" eval="10.0" />
<field name="uom_id" ref="uom.product_uom_unit" />
</record>
</odoo>
10 changes: 2 additions & 8 deletions quality_control_oca/models/qc_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def _compute_product_id(self):
copy=False,
)
date = fields.Datetime(
string="Date",
required=True,
readonly=True,
copy=False,
Expand All @@ -64,17 +63,15 @@ def _compute_product_id(self):
help="Product associated with the inspection",
)
qty = fields.Float(string="Quantity", default=1.0)
test = fields.Many2one(comodel_name="qc.test", string="Test", readonly=True)
test = fields.Many2one(comodel_name="qc.test", readonly=True)
inspection_lines = fields.One2many(
comodel_name="qc.inspection.line",
inverse_name="inspection_id",
string="Inspection lines",
readonly=True,
states={"ready": [("readonly", False)]},
)
internal_notes = fields.Text(string="Internal notes")
external_notes = fields.Text(
string="External notes",
states={"success": [("readonly", True)], "failed": [("readonly", True)]},
)
state = fields.Selection(
Expand All @@ -86,14 +83,12 @@ def _compute_product_id(self):
("failed", "Quality failed"),
("canceled", "Canceled"),
],
string="State",
readonly=True,
default="draft",
tracking=True,
)
success = fields.Boolean(
compute="_compute_success",
string="Success",
help="This field will be marked if all tests have succeeded.",
store=True,
)
Expand Down Expand Up @@ -321,7 +316,7 @@ def _compute_valid_values(self):
help="Value of the result for a qualitative question.",
domain="[('id', 'in', possible_ql_values)]",
)
notes = fields.Text(string="Notes")
notes = fields.Text()
min_value = fields.Float(
string="Min",
digits="Quality Control",
Expand Down Expand Up @@ -351,7 +346,6 @@ def _compute_valid_values(self):
)
question_type = fields.Selection(
[("qualitative", "Qualitative"), ("quantitative", "Quantitative")],
string="Question type",
readonly=True,
)
valid_values = fields.Char(
Expand Down
19 changes: 8 additions & 11 deletions quality_control_oca/models/qc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def onchange_type(self):
if self.type == "generic":
self.object_id = False

active = fields.Boolean("Active", default=True)
name = fields.Char(string="Name", required=True, translate=True)
active = fields.Boolean(default=True)
name = fields.Char(required=True, translate=True)
test_lines = fields.One2many(
comodel_name="qc.test.question",
inverse_name="test",
Expand All @@ -40,14 +40,12 @@ def onchange_type(self):
fill_correct_values = fields.Boolean(string="Pre-fill with correct values")
type = fields.Selection(
[("generic", "Generic"), ("related", "Related")],
string="Type",
required=True,
default="generic",
)
category = fields.Many2one(comodel_name="qc.test.category", string="Category")
category = fields.Many2one(comodel_name="qc.test.category")
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env.company,
)

Expand Down Expand Up @@ -87,12 +85,11 @@ def _check_valid_range(self):
% tc.name_get()[0][1]
)

sequence = fields.Integer(string="Sequence", required=True, default="10")
test = fields.Many2one(comodel_name="qc.test", string="Test")
name = fields.Char(string="Name", required=True, translate=True)
sequence = fields.Integer(required=True, default="10")
test = fields.Many2one(comodel_name="qc.test")
name = fields.Char(required=True, translate=True)
type = fields.Selection(
[("qualitative", "Qualitative"), ("quantitative", "Quantitative")],
string="Type",
required=True,
)
ql_values = fields.One2many(
Expand All @@ -101,7 +98,7 @@ def _check_valid_range(self):
string="Qualitative values",
copy=True,
)
notes = fields.Text(string="Notes")
notes = fields.Text()
min_value = fields.Float(string="Min", digits="Quality Control")
max_value = fields.Float(string="Max", digits="Quality Control")
uom_id = fields.Many2one(comodel_name="uom.uom", string="Uom")
Expand All @@ -112,7 +109,7 @@ class QcTestQuestionValue(models.Model):
_description = "Possible values for qualitative questions."

test_line = fields.Many2one(comodel_name="qc.test.question", string="Test question")
name = fields.Char(string="Name", required=True, translate=True)
name = fields.Char(required=True, translate=True)
ok = fields.Boolean(
string="Correct answer?",
help="When this field is marked, the answer is considered correct.",
Expand Down
3 changes: 1 addition & 2 deletions quality_control_oca/models/qc_test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _check_parent_id(self):
_("Error! You can not create recursive categories.")
)

name = fields.Char("Name", required=True, translate=True)
name = fields.Char(required=True, translate=True)
parent_id = fields.Many2one(
comodel_name="qc.test.category", string="Parent category"
)
Expand All @@ -42,7 +42,6 @@ def _check_parent_id(self):
string="Child categories",
)
active = fields.Boolean(
string="Active",
default=True,
help="This field allows you to hide the category without removing it.",
)
4 changes: 2 additions & 2 deletions quality_control_oca/models/qc_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class QcTrigger(models.Model):
_name = "qc.trigger"
_description = "Quality control trigger"

name = fields.Char(string="Name", required=True, translate=True)
active = fields.Boolean(string="Active", default=True)
name = fields.Char(required=True, translate=True)
active = fields.Boolean(default=True)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/qc_trigger_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class QcTriggerLine(models.AbstractModel):
)
partners = fields.Many2many(
comodel_name="res.partner",
string="Partners",
help="If filled, the test will only be created when the action is done"
" for one of the specified partners. If empty, the test will always be"
" created.",
Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/views/product_category_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<group name="first" position="after">
<group name="qc" string="Quality control">
<field name="qc_triggers" nolabel="1">
<tree string="Quality control triggers" editable="bottom">
<tree editable="bottom">
<field
name="trigger"
options="{'no_create': True, 'no_edit': True, 'no_open': True}"
Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/views/product_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<page name="inventory" position="inside">
<group name="qc" string="Quality control">
<field name="qc_triggers" nolabel="1">
<tree string="Quality control triggers" editable="bottom">
<tree editable="bottom">
<field
name="trigger"
options="{'no_create': True, 'no_edit': True, 'no_open': True}"
Expand Down
12 changes: 3 additions & 9 deletions quality_control_oca/views/qc_inspection_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="name">qc.inspection.form</field>
<field name="model">qc.inspection</field>
<field name="arch" type="xml">
<form string="Inspection">
<form>
<header>
<button
name="action_draft"
Expand Down Expand Up @@ -86,12 +86,7 @@
<notebook>
<page string="Questions">
<field name="inspection_lines" nolabel="1">
<tree
string="Inspection lines"
editable="top"
delete="false"
create="false"
>
<tree editable="top" delete="false" create="false">
<field name="name" />
<field name="question_type" />
<field name="possible_ql_values" invisible="1" />
Expand Down Expand Up @@ -141,7 +136,7 @@
<field name="name">qc.inspection.tree</field>
<field name="model">qc.inspection</field>
<field name="arch" type="xml">
<tree string="Inspections">
<tree>
<field name="name" />
<field name="user" />
<field name="test" />
Expand Down Expand Up @@ -241,7 +236,6 @@
<tree
decoration-danger="success==False"
decoration-info="success==True"
string="Inspection lines"
delete="false"
create="false"
>
Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/views/qc_test_category_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="name">qc.test.category.tree</field>
<field name="model">qc.test.category</field>
<field name="arch" type="xml">
<tree string="Test categories" editable="bottom">
<tree editable="bottom">
<field name="complete_name" />
<field name="name" />
<field name="parent_id" />
Expand Down
6 changes: 3 additions & 3 deletions quality_control_oca/views/qc_test_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</group>
</group>
<field name="test_lines" nolabel="1">
<tree string="Questions">
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="type" />
Expand All @@ -57,7 +57,7 @@
<field name="name">qc.test.tree</field>
<field name="model">qc.test</field>
<field name="arch" type="xml">
<tree string="Tests">
<tree>
<field name="name" />
<field name="category" />
<field name="type" />
Expand Down Expand Up @@ -95,7 +95,7 @@
nolabel="1"
attrs="{'required': [('type','=','qualitative')]}"
>
<tree string="Question value" editable="bottom">
<tree editable="bottom">
<field name="name" />
<field name="ok" />
</tree>
Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/views/qc_trigger_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<field name="name">qc.trigger.tree</field>
<field name="model">qc.trigger</field>
<field name="arch" type="xml">
<tree string="Quality control triggers" editable="bottom">
<tree editable="bottom">
<field name="name" />
<field name="company_id" groups="base.group_multi_company" />
<field name="partner_selectable" />
Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/wizard/qc_test_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class QcInspectionSetTest(models.TransientModel):
_name = "qc.inspection.set.test"
_description = "Set test for inspection"

test = fields.Many2one(comodel_name="qc.test", string="Test")
test = fields.Many2one(comodel_name="qc.test")

def action_create_test(self):
inspection = self.env["qc.inspection"].browse(self.env.context["active_id"])
Expand Down

0 comments on commit d6354de

Please sign in to comment.