Skip to content

Commit

Permalink
[MIG] quality_control: Migration to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Humanes authored and peluko00 committed May 14, 2024
1 parent 6be2e0e commit 2842351
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 115 deletions.
3 changes: 2 additions & 1 deletion quality_control_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Usage

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/129/10.0
:target: https://runbot.odoo-community.org/runbot/129/11.0


Known issues / Roadmap
Expand Down Expand Up @@ -80,6 +80,7 @@ Contributors
* Ana Juaristi <[email protected]>
* Lois Rilo <[email protected]>
* Simone Rubino <[email protected]>
* Juan Humanes <[email protected]>

Do not contact contributors directly about support or help with technical issues.

Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
Expand Down
4 changes: 2 additions & 2 deletions quality_control_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand All @@ -8,9 +7,10 @@

{
"name": "Quality control",
"version": "10.0.1.0.3",
"version": "11.0.1.0.0",
"category": "Quality control",
"license": "AGPL-3",
"summary": "Generic infrastructure for quality tests.",
"author": "OdooMRP team, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture/tree/10.0/quality_control",
Expand Down
28 changes: 10 additions & 18 deletions quality_control_oca/i18n/quality_control.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -160,7 +160,7 @@ msgid "Draft"
msgstr ""

#. module: quality_control
#: code:addons/quality_control/models/qc_test_category.py:37
#: code:addons/quality_control/models/qc_test_category.py:36
#, python-format
msgid "Error! You can not create recursive categories."
msgstr ""
Expand Down Expand Up @@ -392,8 +392,8 @@ msgstr ""

#. module: quality_control
#: model:ir.model,name:quality_control.model_product_product
#: model:ir.model.fields,field_description:quality_control.field_qc_inspection_line_product
#: model:ir.model.fields,field_description:quality_control.field_qc_inspection_product
#: model:ir.model.fields,field_description:quality_control.field_qc_inspection_line_product_id
#: model:ir.model.fields,field_description:quality_control.field_qc_inspection_product_id
#: model:ir.model.fields,field_description:quality_control.field_qc_trigger_product_line_product
#: model:ir.ui.view,arch_db:quality_control.qc_inspection_line_search_view
#: model:ir.ui.view,arch_db:quality_control.qc_inspection_search_view
Expand All @@ -402,30 +402,22 @@ msgstr ""

#. module: quality_control
#: model:ir.model,name:quality_control.model_product_category
#: model:ir.model.fields,field_description:quality_control.field_qc_trigger_product_category_line_product_category
msgid "Product Category"
msgstr ""

#. module: quality_control
#: model:ir.model,name:quality_control.model_product_template
#: model:ir.model.fields,field_description:quality_control.field_qc_trigger_product_template_line_product_template
msgid "Product Template"
msgstr ""

#. module: quality_control
#: model:ir.model.fields,help:quality_control.field_qc_inspection_line_product
#: model:ir.model.fields,help:quality_control.field_qc_inspection_product
#: model:ir.model.fields,help:quality_control.field_qc_inspection_line_product_id
#: model:ir.model.fields,help:quality_control.field_qc_inspection_product_id
msgid "Product associated with the inspection"
msgstr ""

#. module: quality_control
#: model:ir.model.fields,field_description:quality_control.field_qc_trigger_product_category_line_product_category
msgid "Product category"
msgstr ""

#. module: quality_control
#: model:ir.model.fields,field_description:quality_control.field_qc_trigger_product_template_line_product_template
msgid "Product template"
msgstr ""

#. module: quality_control
#: selection:qc.inspection.line,question_type:0
#: selection:qc.test.question,type:0
Expand Down Expand Up @@ -519,13 +511,13 @@ msgid "Question"
msgstr ""

#. module: quality_control
#: code:addons/quality_control/models/qc_test.py:73
#: code:addons/quality_control/models/qc_test.py:72
#, python-format
msgid "Question '%s' is not valid: minimum value can't be higher than maximum value."
msgstr ""

#. module: quality_control
#: code:addons/quality_control/models/qc_test.py:64
#: code:addons/quality_control/models/qc_test.py:63
#, python-format
msgid "Question '%s' is not valid: you have to mark at least one value as OK."
msgstr ""
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import qc_trigger
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/product_category.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/product_product.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/models/product_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand Down
87 changes: 44 additions & 43 deletions quality_control_oca/models/qc_inspection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand All @@ -14,25 +13,25 @@
class QcInspection(models.Model):
_name = 'qc.inspection'
_description = 'Quality control inspection'
_inherit = ['mail.thread', 'ir.needaction_mixin']
_inherit = ['mail.thread', 'mail.activity.mixin']

@api.one
@api.depends('inspection_lines', 'inspection_lines.success')
def _success(self):
self.success = all([x.success for x in self.inspection_lines])
def _compute_success(self):
for i in self:
i.success = all([x.success for x in i.inspection_lines])

@api.multi
def _links_get(self):
link_obj = self.env['res.request.link']
return [(r.object, r.name) for r in link_obj.search([])]

@api.one
@api.depends('object_id')
def _get_product(self):
if self.object_id and self.object_id._name == 'product.product':
self.product = self.object_id
else:
self.product = False
def _compute_product_id(self):
for i in self:
if i.object_id and i.object_id._name == 'product.product':
i.product_id = i.object_id
else:
i.product_id = False

name = fields.Char(
string='Inspection number', required=True, default='/',
Expand All @@ -44,9 +43,10 @@ def _get_product(self):
object_id = fields.Reference(
string='Reference', selection=_links_get, readonly=True,
states={'draft': [('readonly', False)]}, ondelete="set null")
product = fields.Many2one(
comodel_name="product.product", compute="_get_product", store=True,
help="Product associated with the inspection")
product_id = fields.Many2one(
comodel_name="product.product", compute="_compute_product_id",
store=True, help="Product associated with the inspection",
oldname='product')
qty = fields.Float(string="Quantity", default=1.0)
test = fields.Many2one(
comodel_name='qc.test', string='Test', readonly=True)
Expand All @@ -69,7 +69,7 @@ def _get_product(self):
string='State', readonly=True, default='draft',
track_visibility='onchange')
success = fields.Boolean(
compute="_success", string='Success',
compute="_compute_success", string='Success',
help='This field will be marked if all tests have succeeded.',
store=True)
auto_generated = fields.Boolean(
Expand Down Expand Up @@ -228,42 +228,43 @@ class QcInspectionLine(models.Model):
_name = 'qc.inspection.line'
_description = "Quality control inspection line"

@api.one
@api.depends('question_type', 'uom_id', 'test_uom_id', 'max_value',
'min_value', 'quantitative_value', 'qualitative_value',
'possible_ql_values')
def quality_test_check(self):
if self.question_type == 'qualitative':
self.success = self.qualitative_value.ok
else:
if self.uom_id.id == self.test_uom_id.id:
amount = self.quantitative_value
def _compute_quality_test_check(self):
for l in self:
if l.question_type == 'qualitative':
l.success = l.qualitative_value.ok
else:
amount = self.env['product.uom']._compute_quantity(
self.quantitative_value,
self.test_uom_id.id)
self.success = self.max_value >= amount >= self.min_value
if l.uom_id.id == l.test_uom_id.id:
amount = l.quantitative_value
else:
amount = self.env['product.uom']._compute_quantity(
l.quantitative_value,
l.test_uom_id.id)
l.success = l.max_value >= amount >= l.min_value

@api.one
@api.depends('possible_ql_values', 'min_value', 'max_value', 'test_uom_id',
'question_type')
def get_valid_values(self):
if self.question_type == 'qualitative':
self.valid_values = ", ".join([x.name for x in
self.possible_ql_values if x.ok])
else:
self.valid_values = "%s ~ %s" % (
formatLang(self.env, self.min_value),
formatLang(self.env, self.max_value))
if self.env.ref("product.group_uom") in self.env.user.groups_id:
self.valid_values += " %s" % self.test_uom_id.name
def _compute_valid_values(self):
for l in self:
if l.question_type == 'qualitative':
l.valid_values = \
", ".join([x.name for x in l.possible_ql_values if x.ok])
else:
l.valid_values = "%s ~ %s" % (
formatLang(self.env, l.min_value),
formatLang(self.env, l.max_value))
if self.env.ref("product.group_uom") \
in self.env.user.groups_id:
l.valid_values += " %s" % l.test_uom_id.name

inspection_id = fields.Many2one(
comodel_name='qc.inspection', string='Inspection', ondelete='cascade')
name = fields.Char(string="Question", readonly=True)
product = fields.Many2one(
comodel_name="product.product", related="inspection_id.product",
store=True)
product_id = fields.Many2one(
comodel_name="product.product", related="inspection_id.product_id",
store=True, oldname='product')
test_line = fields.Many2one(
comodel_name='qc.test.question', string='Test question',
readonly=True)
Expand All @@ -275,7 +276,7 @@ def get_valid_values(self):
qualitative_value = fields.Many2one(
comodel_name='qc.test.question.value', string='Qualitative value',
help="Value of the result for a qualitative question.",
domain="[('id', 'in', possible_ql_values[0][2])]")
domain="[('id', 'in', possible_ql_values)]")
notes = fields.Text(string='Notes')
min_value = fields.Float(
string='Min', digits=dp.get_precision('Quality Control'),
Expand All @@ -299,6 +300,6 @@ def get_valid_values(self):
('quantitative', 'Quantitative')],
string='Question type', readonly=True)
valid_values = fields.Char(string="Valid values", store=True,
compute="get_valid_values")
compute="_compute_valid_values")
success = fields.Boolean(
compute="quality_test_check", string="Success?", store=True)
compute="_compute_quality_test_check", string="Success?", store=True)
27 changes: 13 additions & 14 deletions quality_control_oca/models/qc_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand Down Expand Up @@ -55,24 +54,24 @@ class QcTestQuestion(models.Model):
_description = 'Quality control question'
_order = 'sequence, id'

@api.one
@api.constrains('ql_values')
def _check_valid_answers(self):
if (self.type == 'qualitative' and self.ql_values and
not self.ql_values.filtered('ok')):
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"you have to mark at least one value as OK.")
% self.name_get()[0][1])
for tc in self:
if (tc.type == 'qualitative' and tc.ql_values and
not tc.ql_values.filtered('ok')):
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"you have to mark at least one value as OK.")
% tc.name_get()[0][1])

@api.one
@api.constrains('min_value', 'max_value')
def _check_valid_range(self):
if self.type == 'quantitative' and self.min_value > self.max_value:
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"minimum value can't be higher than maximum value.")
% self.name_get()[0][1])
for tc in self:
if tc.type == 'quantitative' and tc.min_value > tc.max_value:
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"minimum value can't be higher than maximum value.")
% tc.name_get()[0][1])

sequence = fields.Integer(
string='Sequence', required=True, default="10")
Expand Down
5 changes: 2 additions & 3 deletions quality_control_oca/models/qc_test_category.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand All @@ -15,7 +14,7 @@ class QcTestTemplateCategory(models.Model):

@api.multi
@api.depends('name', 'parent_id')
def _get_complete_name(self):
def _compute_get_complete_name(self):
for record in self:
names = [record.name or '']
parent = record.parent_id
Expand All @@ -41,7 +40,7 @@ def _check_recursion(self):
parent_id = fields.Many2one(
comodel_name='qc.test.category', string='Parent category')
complete_name = fields.Char(
compute="_get_complete_name", string='Full name')
compute="_compute_get_complete_name", string='Full name')
child_ids = fields.One2many(
comodel_name='qc.test.category', inverse_name='parent_id',
string='Child categories')
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
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
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
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010 NaN Projectes de Programari Lliure, S.L.
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
Expand Down
1 change: 0 additions & 1 deletion quality_control_oca/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_quality_control
Loading

0 comments on commit 2842351

Please sign in to comment.