Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
991 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
======================= | ||
Quality control formula | ||
======================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github | ||
:target: https://github.com/OCA/manufacture/tree/10.0/quality_control_formula | ||
:alt: OCA/manufacture | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-quality_control_formula | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/129/10.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Allow the user to use formulas to get the quantitative / qualitative value for an inspection line. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
1. Create a new test with one or more questions; | ||
|
||
2. In a test question, fill in the *formula* field with some python computation, the values that can be used are: | ||
|
||
* *input_value*: a new field of the inspection line; | ||
* variables from the previous inspection lines (use the handle to change the order), | ||
where the variable name is given by the *code* field; | ||
|
||
3. Create a new inspection from the test; | ||
|
||
4. The inspection lines are recomputed as soon as any field concerning the formula is modified. | ||
|
||
The inspection lines can also be recomputed with the *Compute lines* button in the inspection, | ||
or the *Compute* button on each line. | ||
|
||
Note that formula dependencies can be managed in the new menu *Quality control > Test > Test questions*, | ||
the sequence value will be maintained when the question becomes an inspection. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20quality_control_formula%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Agile Business Group | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/10.0/quality_control_formula>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Simone Rubino - Agile Business Group | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Quality control formula", | ||
"summary": "Use formulas in inspection lines.", | ||
"version": "10.0.1.0.0", | ||
"development_status": "Beta", | ||
"category": "Quality control", | ||
"website": "https://github.com/OCA/manufacture/tree/" | ||
"10.0/quality_control_formula", | ||
"author": "Agile Business Group, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"quality_control", | ||
], | ||
"data": [ | ||
"views/qc_inspection_line_views.xml", | ||
"views/qc_inspection_views.xml", | ||
"views/qc_test_question_views.xml", | ||
"views/qc_test_views.xml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * quality_control_formula | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-01-09 17:11+0000\n" | ||
"PO-Revision-Date: 2019-01-09 17:11+0000\n" | ||
"Last-Translator: Simone Rubino <simone.rubino@agilebg.com>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_inspection_line_code | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_test_question_code | ||
msgid "Code" | ||
msgstr "Codice" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.ui.view,arch_db:quality_control_formula.qc_inspection_form_view | ||
msgid "Compute" | ||
msgstr "Calcola" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.ui.view,arch_db:quality_control_formula.qc_inspection_form_view | ||
msgid "Compute lines" | ||
msgstr "Calcola righe" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_inspection_line_formula | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_test_question_formula | ||
msgid "Formula" | ||
msgstr "Formula" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_inspection_line_input_value | ||
msgid "Input value" | ||
msgstr "Valore in input" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,help:quality_control_formula.field_qc_inspection_line_formula | ||
msgid "Python formula for evaluating the current inspection line.Provided values are 'input_value' and the values of all the previous inspection lines (the variable name is the 'code' field)." | ||
msgstr "Formula Python formula per valutare la riga di ispezione.I valori disponibili sono 'input_value' e i valori di tutte le righe di ispezione precedenti (il nome della variabile equivale al campo 'codice')." | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,help:quality_control_formula.field_qc_test_question_formula | ||
msgid "Python formula for evaluating the current question.Provided values are 'input_value' and the values of all the previous questions (the variable name is the 'code' field)." | ||
msgstr "Formula Python formula per valutare la domanda del test.I valori disponibili sono 'input_value' e i valori di tutte le domande precedenti (il nome della variabile equivale al campo 'codice')." | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model,name:quality_control_formula.model_qc_inspection | ||
msgid "Quality control inspection" | ||
msgstr "Ispezione controllo di qualità" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model,name:quality_control_formula.model_qc_inspection_line | ||
msgid "Quality control inspection line" | ||
msgstr "Riga ispezione controllo qualità" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model,name:quality_control_formula.model_qc_test_question | ||
msgid "Quality control question" | ||
msgstr "Domanda di controllo qualità" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,field_description:quality_control_formula.field_qc_inspection_line_sequence | ||
msgid "Sequence" | ||
msgstr "Sequenza" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.actions.act_window,name:quality_control_formula.action_qc_test_questions | ||
#: model:ir.ui.menu,name:quality_control_formula.qc_test_questions_menu | ||
#: model:ir.ui.view,arch_db:quality_control_formula.qc_test_question_tree_view | ||
msgid "Test questions" | ||
msgstr "Domande dei test" | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,help:quality_control_formula.field_qc_inspection_line_code | ||
msgid "Used for the evaluation of formulas: name of the variable corresponding to this inspection line's value." | ||
msgstr "Utilizzato per la valutazione delle formule: il nome della variabile corrispondente al valore di questa ispezione." | ||
|
||
#. module: quality_control_formula | ||
#: model:ir.model.fields,help:quality_control_formula.field_qc_test_question_code | ||
msgid "Used for the evaluation of formulas: name of the variable corresponding to this question's value." | ||
msgstr "Utilizzato per la valutazione delle formule: il nome della variabile corrispondente al valore di questa domanda." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import qc_inspection | ||
from . import qc_inspection_line | ||
from . import qc_test_question |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Simone Rubino - Agile Business Group | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class QcInspection(models.Model): | ||
_inherit = 'qc.inspection' | ||
|
||
@api.multi | ||
def _prepare_inspection_line(self, test, line, fill=None): | ||
line_data = super(QcInspection, self) \ | ||
._prepare_inspection_line(test, line, fill=fill) | ||
line_data.update({ | ||
'code': line.code, | ||
'sequence': line.sequence, | ||
'formula': line.formula | ||
}) | ||
return line_data | ||
|
||
@api.multi | ||
def calculate_lines_values(self): | ||
self.mapped('inspection_lines').calculate_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Simone Rubino - Agile Business Group | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class QcInspectionLine(models.Model): | ||
_inherit = 'qc.inspection.line' | ||
_order = 'sequence, id' | ||
|
||
code = fields.Char( | ||
help="Used for the evaluation of formulas: " | ||
"name of the variable corresponding to " | ||
"this inspection line's value.") | ||
sequence = fields.Integer() | ||
formula = fields.Text( | ||
help="Python formula for evaluating the current inspection line." | ||
"Provided values are 'input_value' and " | ||
"the values of all the previous inspection lines " | ||
"(the variable name is the 'code' field).") | ||
input_value = fields.Char() | ||
|
||
@api.multi | ||
def calculate_value(self): | ||
for line in self: | ||
if not line.formula: | ||
continue | ||
formula_res = safe_eval( | ||
line.formula, line._prepare_formula_dict()) | ||
if line.question_type == 'qualitative': | ||
line.qualitative_value = formula_res | ||
elif line.question_type == 'quantitative': | ||
line.quantitative_value = formula_res | ||
|
||
@api.multi | ||
def _prepare_formula_dict(self): | ||
self.ensure_one() | ||
formula_dict = {'input_value': self.input_value} | ||
# Compute all the previous inspection lines | ||
previous_lines = self.inspection_id.inspection_lines.filtered( | ||
lambda l: l.sequence <= self.sequence) - self | ||
for line in previous_lines: | ||
line_value = 0 | ||
if line.question_type == 'qualitative': | ||
line_value = line.qualitative_value | ||
elif line.question_type == 'quantitative': | ||
line_value = line.quantitative_value | ||
formula_dict.update({line.code: line_value}) | ||
|
||
return formula_dict | ||
|
||
@api.multi | ||
def write(self, vals): | ||
res = super(QcInspectionLine, self).write(vals) | ||
# If any of the following fields is modified, | ||
# recompute all the inspection lines of its inspection | ||
# because the result might change / be invalid | ||
formula_fields = ['inspection_id', | ||
'code', 'input_value', 'formula', 'sequence'] | ||
if any(ff in vals for ff in formula_fields): | ||
self.mapped('inspection_id').calculate_lines_values() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Simone Rubino - Agile Business Group | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class QcTestQuestion(models.Model): | ||
_inherit = 'qc.test.question' | ||
|
||
code = fields.Char( | ||
help="Used for the evaluation of formulas: " | ||
"name of the variable corresponding to this question's value.") | ||
formula = fields.Text( | ||
help="Python formula for evaluating the current question." | ||
"Provided values are 'input_value' and " | ||
"the values of all the previous questions " | ||
"(the variable name is the 'code' field).") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow the user to use formulas to get the quantitative / qualitative value for an inspection line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
1. Create a new test with one or more questions; | ||
|
||
2. In a test question, fill in the *formula* field with some python computation, the values that can be used are: | ||
|
||
* *input_value*: a new field of the inspection line; | ||
* variables from the previous inspection lines (use the handle to change the order), | ||
where the variable name is given by the *code* field; | ||
|
||
3. Create a new inspection from the test; | ||
|
||
4. The inspection lines are recomputed as soon as any field concerning the formula is modified. | ||
|
||
The inspection lines can also be recomputed with the *Compute lines* button in the inspection, | ||
or the *Compute* button on each line. | ||
|
||
Note that formula dependencies can be managed in the new menu *Quality control > Test > Test questions*, | ||
the sequence value will be maintained when the question becomes an inspection. |
Oops, something went wrong.