Skip to content

Commit

Permalink
[MIG] quality_control_oca: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peluko00 committed May 14, 2024
1 parent 989080c commit 11f31e9
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 66 deletions.
4 changes: 4 additions & 0 deletions quality_control_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ Contributors

- Vicent Cubells

- `APSL-Nagarro <https://www.apsl.tech>`__:

- Antoni Marroig <[email protected]>

Other credits
-------------

Expand Down
2 changes: 1 addition & 1 deletion quality_control_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{
"name": "Quality Control OCA",
"version": "16.0.1.2.0",
"version": "17.0.1.0.0",
"category": "Quality Control",
"license": "AGPL-3",
"summary": "Generic infrastructure for quality tests.",
Expand Down
28 changes: 4 additions & 24 deletions quality_control_oca/models/qc_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ def _compute_product_id(self):
string="Inspection number",
required=True,
default="/",
readonly=True,
states={"draft": [("readonly", False)]},
copy=False,
)
date = fields.Datetime(
required=True,
readonly=True,
copy=False,
default=fields.Datetime.now,
states={"draft": [("readonly", False)]},
)
object_id = fields.Reference(
string="Reference",
selection="object_selection_values",
readonly=True,
states={"draft": [("readonly", False)]},
ondelete="set null",
)
product_id = fields.Many2one(
Expand All @@ -63,17 +57,13 @@ 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", readonly=True)
test = fields.Many2one(comodel_name="qc.test")
inspection_lines = fields.One2many(
comodel_name="qc.inspection.line",
inverse_name="inspection_id",
readonly=True,
states={"ready": [("readonly", False)]},
)
internal_notes = fields.Text(string="Internal notes")
external_notes = fields.Text(
states={"success": [("readonly", True)], "failed": [("readonly", True)]},
)
external_notes = fields.Text()
state = fields.Selection(
[
("draft", "Draft"),
Expand All @@ -83,7 +73,6 @@ def _compute_product_id(self):
("failed", "Quality failed"),
("canceled", "Canceled"),
],
readonly=True,
default="draft",
tracking=True,
)
Expand All @@ -94,15 +83,12 @@ def _compute_product_id(self):
)
auto_generated = fields.Boolean(
string="Auto-generated",
readonly=True,
copy=False,
help="If an inspection is auto-generated, it can be canceled but not removed.",
)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self.env.company,
)
user = fields.Many2one(
Expand Down Expand Up @@ -291,15 +277,13 @@ def _compute_valid_values(self):
inspection_id = fields.Many2one(
comodel_name="qc.inspection", string="Inspection", ondelete="cascade"
)
name = fields.Char(string="Question", readonly=True)
name = fields.Char(string="Question")
product_id = fields.Many2one(
comodel_name="product.product",
related="inspection_id.product_id",
store=True,
)
test_line = fields.Many2one(
comodel_name="qc.test.question", string="Test question", readonly=True
)
test_line = fields.Many2one(comodel_name="qc.test.question", string="Test question")
possible_ql_values = fields.Many2many(
comodel_name="qc.test.question.value", string="Answers"
)
Expand All @@ -318,19 +302,16 @@ def _compute_valid_values(self):
min_value = fields.Float(
string="Min",
digits="Quality Control",
readonly=True,
help="Minimum valid value for a quantitative question.",
)
max_value = fields.Float(
string="Max",
digits="Quality Control",
readonly=True,
help="Maximum valid value for a quantitative question.",
)
test_uom_id = fields.Many2one(
comodel_name="uom.uom",
string="Test UoM",
readonly=True,
help="UoM for minimum and maximum values for a quantitative " "question.",
)
test_uom_category = fields.Many2one(
Expand All @@ -344,7 +325,6 @@ def _compute_valid_values(self):
)
question_type = fields.Selection(
[("qualitative", "Qualitative"), ("quantitative", "Quantitative")],
readonly=True,
)
valid_values = fields.Char(
string="Valid values", store=True, compute="_compute_valid_values"
Expand Down
4 changes: 2 additions & 2 deletions quality_control_oca/models/qc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _check_valid_answers(self):
"Question '%s' is not valid: "
"you have to mark at least one value as OK."
)
% tc.name_get()[0][1]
% tc.display_name
)

@api.constrains("min_value", "max_value")
Expand All @@ -82,7 +82,7 @@ def _check_valid_range(self):
"Question '%s' is not valid: "
"minimum value can't be higher than maximum value."
)
% tc.name_get()[0][1]
% tc.display_name
)

sequence = fields.Integer(required=True, default="10")
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/qc_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ class QcTrigger(models.Model):
partner_selectable = fields.Boolean(
string="Selectable by partner",
default=False,
readonly=True,
help="This technical field is to allow to filter by partner in triggers",
)
2 changes: 2 additions & 0 deletions quality_control_oca/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
- Carlos Roca
- [Trey Kilobytes de Soluciones SL](https://www.trey.es):
- Vicent Cubells
- [APSL-Nagarro](https://www.apsl.tech):
- Antoni Marroig \<<[email protected]>\>
4 changes: 4 additions & 0 deletions quality_control_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Vicent Cubells</li>
</ul>
</li>
<li><a class="reference external" href="https://www.apsl.tech">APSL-Nagarro</a>:<ul>
<li>Antoni Marroig &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
81 changes: 54 additions & 27 deletions quality_control_oca/views/qc_inspection_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,44 @@
<button
name="action_draft"
type="object"
attrs="{'invisible': [('state', '!=', 'canceled')]}"
invisible="state != 'canceled'"
string="Draft"
/>
<button
name="action_todo"
type="object"
class="oe_highlight"
states="draft"
invisible="state != 'draft'"
string="Mark todo"
/>
<button
name="action_confirm"
type="object"
class="oe_highlight"
states="ready"
invisible="state != 'ready'"
string="Confirm"
icon="fa-check"
/>
<button
name="action_approve"
type="object"
states="waiting"
invisible="state != 'waiting'"
class="oe_highlight"
groups="quality_control_oca.group_quality_control_manager"
string="Approve"
/>
<button
name="action_cancel"
type="object"
attrs="{'invisible': [('state', 'not in', ['waiting', 'ready', 'failed', 'success'])]}"
invisible="state not in ['waiting', 'ready', 'failed', 'success']"
string="Cancel"
icon="fa-ban"
/>
<field
name="state"
widget="statusbar"
statusbar_visible="draft,waiting,success"
readonly="1"
/>
</header>
<sheet>
Expand All @@ -61,51 +62,73 @@
type="action"
name="%(action_qc_inspection_set_test)d"
icon="fa-bookmark-o"
states="draft"
invisible="state != 'draft'"
string="Set test"
/>
</div>
<h1>
<label string="Inspection " for="name" />
<field name="name" class="oe_inline" />
<field
name="name"
class="oe_inline"
readonly="state != 'draft'"
/>
</h1>
<group>
<group>
<field name="test" />
<field name="test" readonly="1" />
<field name="user" />
<field name="object_id" />
<field name="object_id" readonly="state != 'draft'" />
<field name="qty" />
<field name="product_id" />
</group>
<group>
<field name="date" />
<field name="date" readonly="state != 'draft'" />
<field name="success" />
<field name="auto_generated" />
<field name="auto_generated" readonly="1" />
</group>
</group>
<notebook>
<page string="Questions">
<field name="inspection_lines" nolabel="1">
<field
name="inspection_lines"
nolabel="1"
readonly="state != 'ready'"
>
<tree editable="top" delete="false" create="false">
<field name="name" />
<field name="question_type" />
<field name="possible_ql_values" invisible="1" />
<field name="name" readonly="1" />
<field name="question_type" readonly="1" />
<field
name="possible_ql_values"
column_invisible="1"
/>
<field
name="qualitative_value"
attrs="{'readonly': [('question_type', '=', 'quantitative')]}"
readonly="question_type == 'quantitative'"
/>
<field
name="quantitative_value"
attrs="{'readonly': [('question_type', '=', 'qualitative')]}"
readonly="question_type == 'qualitative'"
/>
<field
name="uom_id"
groups="uom.group_uom"
attrs="{'readonly': [('question_type', '=', 'qualitative')]}"
readonly="question_type == 'qualitative'"
/>
<field
name="test_uom_category"
column_invisible="1"
/>
<field
name="min_value"
column_invisible="1"
readonly="1"
/>
<field
name="max_value"
column_invisible="1"
readonly="1"
/>
<field name="test_uom_category" invisible="1" />
<field name="min_value" invisible="1" />
<field name="max_value" invisible="1" />
<field name="valid_values" />
<field name="success" />
</tree>
Expand All @@ -116,7 +139,11 @@
<field name="internal_notes" nolabel="1" />
</group>
<group string="External notes">
<field name="external_notes" nolabel="1" />
<field
name="external_notes"
nolabel="1"
readonly="state in ['success', 'failed']"
/>
</group>
</page>
</notebook>
Expand Down Expand Up @@ -243,21 +270,21 @@
<field name="product_id" />
<field name="name" />
<field name="question_type" />
<field name="possible_ql_values" invisible="1" />
<field name="possible_ql_values" column_invisible="1" />
<field
name="qualitative_value"
attrs="{'readonly': [('question_type', '=', 'quantitative')]}"
readonly="question_type == 'quantitative'"
/>
<field
name="quantitative_value"
attrs="{'readonly': [('question_type', '=', 'qualitative')]}"
readonly="question_type == 'qualitative'"
/>
<field
name="uom_id"
groups="uom.group_uom"
attrs="{'readonly': [('question_type', '=', 'qualitative')]}"
readonly="question_type == 'qualitative'"
/>
<field name="test_uom_category" invisible="1" />
<field name="test_uom_category" column_invisible="1" />
<field name="valid_values" />
<field name="success" />
</tree>
Expand Down
Loading

0 comments on commit 11f31e9

Please sign in to comment.