[MIG] quality_control: Migration to 10.0

This commit is contained in:
Simone Rubino
2017-11-21 12:55:50 +01:00
committed by Antoni Marroig Campomar
parent 69cb19a67d
commit 6be2e0e616
101 changed files with 21758 additions and 20797 deletions

View File

@@ -1,9 +1,5 @@
# -*- 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
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import qc_trigger
from . import qc_trigger_line

View File

@@ -3,9 +3,10 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
class ProductCategory(models.Model):

View File

@@ -3,9 +3,10 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
class ProductProduct(models.Model):

View File

@@ -3,9 +3,10 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
class ProductTemplate(models.Model):

View File

@@ -3,10 +3,12 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, exceptions, fields, models, _
import openerp.addons.decimal_precision as dp
from odoo import api, exceptions, fields, models, _
from odoo.tools import formatLang
import odoo.addons.decimal_precision as dp
class QcInspection(models.Model):
@@ -33,12 +35,12 @@ class QcInspection(models.Model):
self.product = False
name = fields.Char(
string='Inspection number', required=True, default='/', select=True,
string='Inspection number', required=True, default='/',
readonly=True, states={'draft': [('readonly', False)]}, copy=False)
date = fields.Datetime(
string='Date', required=True, readonly=True, copy=False,
default=fields.Datetime.now,
states={'draft': [('readonly', False)]}, select=True)
states={'draft': [('readonly', False)]})
object_id = fields.Reference(
string='Reference', selection=_links_get, readonly=True,
states={'draft': [('readonly', False)]}, ondelete="set null")
@@ -47,7 +49,7 @@ class QcInspection(models.Model):
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, select=True)
comodel_name='qc.test', string='Test', readonly=True)
inspection_lines = fields.One2many(
comodel_name='qc.inspection.line', inverse_name='inspection_id',
string='Inspection lines', readonly=True,
@@ -64,14 +66,15 @@ class QcInspection(models.Model):
('success', 'Quality success'),
('failed', 'Quality failed'),
('canceled', 'Canceled')],
string='State', readonly=True, default='draft')
string='State', readonly=True, default='draft',
track_visibility='onchange')
success = fields.Boolean(
compute="_success", string='Success',
help='This field will be marked if all tests have succeeded.',
store=True)
auto_generated = fields.Boolean(
string='Auto-generated', readonly=True, copy=False,
help='If an inspection is auto-generated, it can be canceled nor '
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,
@@ -85,17 +88,18 @@ class QcInspection(models.Model):
@api.model
def create(self, vals):
if vals.get('name', '/') == '/':
vals['name'] = self.env['ir.sequence'].get('qc.inspection')
vals['name'] = self.env['ir.sequence'] \
.next_by_code('qc.inspection')
return super(QcInspection, self).create(vals)
@api.multi
def unlink(self):
for inspection in self:
if inspection.auto_generated:
raise exceptions.Warning(
raise exceptions.UserError(
_("You cannot remove an auto-generated inspection."))
if inspection.state != 'draft':
raise exceptions.Warning(
raise exceptions.UserError(
_("You cannot remove an inspection that is not in draft "
"state."))
return super(QcInspection, self).unlink()
@@ -108,7 +112,7 @@ class QcInspection(models.Model):
def action_todo(self):
for inspection in self:
if not inspection.test:
raise exceptions.Warning(
raise exceptions.UserError(
_("You must first set the test to perform."))
self.write({'state': 'ready'})
@@ -118,12 +122,12 @@ class QcInspection(models.Model):
for line in inspection.inspection_lines:
if line.question_type == 'qualitative':
if not line.qualitative_value:
raise exceptions.Warning(
raise exceptions.UserError(
_("You should provide an answer for all "
"qualitative questions."))
else:
if not line.uom_id:
raise exceptions.Warning(
raise exceptions.UserError(
_("You should provide a unit of measure for "
"quantitative questions."))
if inspection.success:
@@ -235,8 +239,8 @@ class QcInspectionLine(models.Model):
if self.uom_id.id == self.test_uom_id.id:
amount = self.quantitative_value
else:
amount = self.env['product.uom']._compute_qty(
self.uom_id.id, self.quantitative_value,
amount = self.env['product.uom']._compute_quantity(
self.quantitative_value,
self.test_uom_id.id)
self.success = self.max_value >= amount >= self.min_value
@@ -248,7 +252,9 @@ class QcInspectionLine(models.Model):
self.valid_values = ", ".join([x.name for x in
self.possible_ql_values if x.ok])
else:
self.valid_values = "%s-%s" % (self.min_value, self.max_value)
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

View File

@@ -3,10 +3,11 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, exceptions, fields, models, _
import openerp.addons.decimal_precision as dp
from odoo import api, exceptions, fields, models, _
import odoo.addons.decimal_precision as dp
class QcTest(models.Model):
@@ -21,9 +22,14 @@ class QcTest(models.Model):
link_obj = self.env['res.request.link']
return [(r.object, r.name) for r in link_obj.search([])]
@api.onchange('type')
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, select=True)
string='Name', required=True, translate=True)
test_lines = fields.One2many(
comodel_name='qc.test.question', inverse_name='test',
string='Questions', copy=True)
@@ -34,7 +40,7 @@ class QcTest(models.Model):
type = fields.Selection(
[('generic', 'Generic'),
('related', 'Related')],
string='Type', select=True, required=True, default='generic')
string='Type', required=True, default='generic')
category = fields.Many2one(
comodel_name='qc.test.category', string='Category')
company_id = fields.Many2one(
@@ -54,22 +60,25 @@ class QcTestQuestion(models.Model):
def _check_valid_answers(self):
if (self.type == 'qualitative' and self.ql_values and
not self.ql_values.filtered('ok')):
raise exceptions.Warning(
_("There isn't no value marked as OK. You have to mark at "
"least one."))
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"you have to mark at least one value as OK.")
% self.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.Warning(
_("Minimum value can't be higher than maximum value."))
raise exceptions.ValidationError(
_("Question '%s' is not valid: "
"minimum value can't be higher than maximum value.")
% self.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, select=True, translate=True)
string='Name', required=True, translate=True)
type = fields.Selection(
[('qualitative', 'Qualitative'),
('quantitative', 'Quantitative')], string='Type', required=True)
@@ -91,7 +100,7 @@ class QcTestQuestionValue(models.Model):
test_line = fields.Many2one(
comodel_name="qc.test.question", string="Test question")
name = fields.Char(
string='Name', required=True, select=True, translate=True)
string='Name', required=True, translate=True)
ok = fields.Boolean(
string='Correct answer?',
help="When this field is marked, the answer is considered correct.")

View File

@@ -3,9 +3,10 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, exceptions, fields, models, _
from odoo import api, exceptions, fields, models, _
class QcTestTemplateCategory(models.Model):
@@ -32,13 +33,13 @@ class QcTestTemplateCategory(models.Model):
('parent_id', '!=', False)])
ids = list(set([x.parent_id.id for x in parents]))
if not level:
raise exceptions.Warning(
_('Error ! You can not create recursive categories.'))
raise exceptions.UserError(
_('Error! You can not create recursive categories.'))
level -= 1
name = fields.Char('Name', required=True, translate=True)
parent_id = fields.Many2one(
comodel_name='qc.test.category', string='Parent category', select=True)
comodel_name='qc.test.category', string='Parent category')
complete_name = fields.Char(
compute="_get_complete_name", string='Full name')
child_ids = fields.One2many(

View File

@@ -3,16 +3,17 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
class QcTrigger(models.Model):
_name = 'qc.trigger'
_description = 'Quality control trigger'
name = fields.Char(string='Name', required=True, select=True,
name = fields.Char(string='Name', required=True,
translate=True)
active = fields.Boolean(string='Active', default=True)
company_id = fields.Many2one(

View File

@@ -3,9 +3,10 @@
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2017 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
def _filter_trigger_lines(trigger_lines):