Skip to content

Commit

Permalink
[16.0][IMP] quality_control_oca: Adding images to failed questions, d…
Browse files Browse the repository at this point in the history
…epending on test configuration.
  • Loading branch information
edescalona committed Feb 7, 2025
1 parent 3271ae2 commit bc0ab6e
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 15 deletions.
59 changes: 59 additions & 0 deletions quality_control_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ This module provides a generic infrastructure for quality tests. The idea is
that it can be later reused for doing quality inspections on production lots
or any other area of the company.

Allows you to add images to questions asked during inspections.
Depending on the configuration, adding images is allowed or not and defining whether it is mandatory to add them to questions that are not satisfactory.

**Table of contents**

.. contents::
Expand Down Expand Up @@ -67,6 +70,58 @@ The complete inspection workflow is:
|
| -> Failure (Pending approval) -> Approved
Usage
=====

Setting up images for inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. Go to *Quality Control > Tests > Tests*.
#. Add a new test.
#. Check the *Enable images* box.

.. image:: https://raw.githubusercontent.com/quality_control_oca/static/src/img/enable_image.png
:height: 100
:width: 200
:alt: Enable images

#. Fill in the other fields.
#. Relate the test to the inspection.

Set required images for inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. Go to *Quality Control > Testing > Tests*.
#. Add a new test.
#. Check the *Enable images* box.
#. Check the *Required images* box.

.. image:: https://raw.githubusercontent.com/quality_control_oca/static/src/img/enable_required_image.png
:height: 100
:width: 200
:alt: Requires images

#. Fill in the other fields.
#. Relate the test to the inspection.

Add images to inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#. Go to *Quality Control > Inspections > Inspections*.
#. Add a new inspection.
#. Add a new test, using the smart button *Set test*.

.. image:: https://raw.githubusercontent.com/quality_control_oca/static/src/img/add_test.png
:height: 100
:width: 200
:alt: Add test

#. Once the test is selected, if the field *Enable images* is enabled, a new field will be shown in the questions to upload an image.
# In case the test has the field *Images required* checked, the questions in which your answer is not correct will require an image.

.. image:: https://raw.githubusercontent.com/quality_control_oca/static/src/img/image_required_inspection.png
:height: 100
:width: 200
:alt: Image required for inspection

Known issues / Roadmap
======================

Expand Down Expand Up @@ -110,6 +165,10 @@ Contributors

* Vicent Cubells

* `Binhex Cloud <https://www.binhex.cloud/>`_:

* Edilio Escalona Almira <[email protected]>

Other credits
~~~~~~~~~~~~~

Expand Down
65 changes: 65 additions & 0 deletions quality_control_oca/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -1117,3 +1117,68 @@ msgstr "o"

#~ msgid "Product template"
#~ msgstr "Plantilla de producto"

#. module: quality_control_oca
#: model:ir.model.fields,help:quality_control_oca.field_qc_inspection__is_required_image
#: model:ir.model.fields,help:quality_control_oca.field_qc_test__is_required_image
msgid ""
"\n"
" Allows the obligation to attach an image in\n"
" the questions defined in the inspection.\n"
" "
msgstr ""
"\n"
" Permite la obligación de adjuntar una imagen en las preguntas definidas en la inspección.\n"
" "

#. module: quality_control_oca
#: model:ir.model.fields,help:quality_control_oca.field_qc_inspection__enable_image
#: model:ir.model.fields,help:quality_control_oca.field_qc_test__enable_image
msgid ""
"\n"
" Allows the possibility of attaching an image\n"
" to the questions defined in the inspection.\n"
" "
msgstr ""
"\n"
"Permite la posibilidad de adjuntar una imagen\n"
" a las preguntas definidas en la inspección.\n"
" "

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection__enable_image
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_test__enable_image
msgid "Enable Image"
msgstr "Habilitar imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection_line__image_1920
msgid "Image"
msgstr "Imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection_line__image_1024
msgid "Image 1024"
msgstr "Imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection_line__image_128
msgid "Image 128"
msgstr "Imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection_line__image_256
msgid "Image 256"
msgstr "Imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection_line__image_512
msgid "Image 512"
msgstr "Imagen"

#. module: quality_control_oca
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection__is_required_image
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_test__is_required_image
msgid "Required image"
msgstr "Imagen requerida"

16 changes: 16 additions & 0 deletions quality_control_oca/models/qc_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, exceptions, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import formatLang


Expand Down Expand Up @@ -111,6 +112,8 @@ def _compute_product_id(self):
tracking=True,
default=lambda self: self.env.user,
)
enable_image = fields.Boolean(related="test.enable_image")
is_required_image = fields.Boolean(related="test.is_required_image")

@api.model_create_multi
def create(self, val_list):
Expand Down Expand Up @@ -161,6 +164,17 @@ def action_confirm(self):
inspection.state = "success"
else:
inspection.state = "waiting"
if inspection.enable_image and inspection.is_required_image:
all_questions_invalid = inspection.inspection_lines.filtered(
lambda x: x.success is False and not x.image_1920
)
if all_questions_invalid:
raise ValidationError(
_(
"The following question(s) are not satisfactory, "
"so an image must be attached. \n {}"
).format(", ".join(all_questions_invalid.mapped("name")))
)

def action_approve(self):
for inspection in self:
Expand Down Expand Up @@ -248,6 +262,7 @@ def _prepare_inspection_line(self, test, line, fill=None):

class QcInspectionLine(models.Model):
_name = "qc.inspection.line"
_inherit = "image.mixin"
_description = "Quality control inspection line"

@api.depends(
Expand Down Expand Up @@ -354,3 +369,4 @@ def _compute_valid_values(self):
success = fields.Boolean(
compute="_compute_quality_test_check", string="Success?", store=True
)
enable_image = fields.Boolean(related="inspection_id.enable_image")
15 changes: 15 additions & 0 deletions quality_control_oca/models/qc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def onchange_type(self):
comodel_name="res.company",
default=lambda self: self.env.company,
)
enable_image = fields.Boolean(
default=False,
help="""
Allows the possibility of attaching an image
to the questions defined in the inspection.
""",
)
is_required_image = fields.Boolean(
string="Required image",
default=False,
help="""
Allows the obligation to attach an image in
the questions defined in the inspection.
""",
)


class QcTestQuestion(models.Model):
Expand Down
4 changes: 4 additions & 0 deletions quality_control_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
* `Trey Kilobytes de Soluciones SL <https://www.trey.es>`__:

* Vicent Cubells

* `Binhex Cloud <https://www.binhex.cloud/>`_:

* Edilio Escalona Almira <[email protected]>
3 changes: 3 additions & 0 deletions quality_control_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
This module provides a generic infrastructure for quality tests. The idea is
that it can be later reused for doing quality inspections on production lots
or any other area of the company.

Allows you to add images to questions asked during inspections.
Depending on the configuration, adding images is allowed or not and defining whether it is mandatory to add them to questions that are not satisfactory.
48 changes: 48 additions & 0 deletions quality_control_oca/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Setting up images for inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. Go to *Quality Control > Tests > Tests*.
#. Add a new test.
#. Check the *Enable images* box.

.. image:: /quality_control_oca/static/src/img/enable_image.png
:height: 100
:width: 200
:alt: Enable images

#. Fill in the other fields.
#. Relate the test to the inspection.

Set required images for inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. Go to *Quality Control > Testing > Tests*.
#. Add a new test.
#. Check the *Enable images* box.
#. Check the *Required images* box.

.. image:: /quality_control_oca/static/src/img/enable_required_image.png
:height: 100
:width: 200
:alt: Requires images

#. Fill in the other fields.
#. Relate the test to the inspection.

Add images to inspections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#. Go to *Quality Control > Inspections > Inspections*.
#. Add a new inspection.
#. Add a new test, using the smart button *Set test*.

.. image:: /quality_control_oca/static/src/img/add_test.png
:height: 100
:width: 200
:alt: Add test

#. Once the test is selected, if the field *Enable images* is enabled, a new field will be shown in the questions to upload an image.
# In case the test has the field *Images required* checked, the questions in which your answer is not correct will require an image.

.. image:: /quality_control_oca/static/src/img/image_required_inspection.png
:height: 100
:width: 200
:alt: Image required for inspection
Loading

0 comments on commit bc0ab6e

Please sign in to comment.