mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
Several fixes:
* add stage states * default values for relational fields must return a recordset. * do not allow to create qc issues from kanban quick create.
This commit is contained in:
committed by
Jordi Ballester Alomar
parent
508fe0a28b
commit
e16506f189
@@ -1,9 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import qc_issue
|
||||
from . import qc_stage
|
||||
from . import qc_problem
|
||||
from . import qc_problem_group
|
||||
from . import qc_stage
|
||||
from . import qc_issue_stage
|
||||
from . import qc_issue
|
||||
|
||||
@@ -23,9 +23,9 @@ class QualityControlIssue(models.Model):
|
||||
|
||||
def _get_default_stage_id(self):
|
||||
""" Gives default stage_id """
|
||||
team_id = self.env['qc.team']._get_default_qc_team_id(
|
||||
team = self.env['qc.team']._get_default_qc_team_id(
|
||||
user_id=self.env.uid)
|
||||
return self.issue_stage_find([], team_id, [('fold', '=', False)])
|
||||
return self.issue_stage_find([], team, [('fold', '=', False)])
|
||||
|
||||
@api.multi
|
||||
def _read_group_stage_ids(self, domain, read_group_order=None,
|
||||
@@ -64,8 +64,7 @@ class QualityControlIssue(models.Model):
|
||||
track_visibility='onchange')
|
||||
product_id = fields.Many2one(
|
||||
comodel_name="product.product", string="Product",
|
||||
readonly=True, states={"new": [("readonly", False)]},
|
||||
required=True)
|
||||
readonly=True, states={"new": [("readonly", False)]}, required=True)
|
||||
product_tracking = fields.Selection(related="product_id.tracking")
|
||||
product_qty = fields.Float(
|
||||
string="Product Quantity", required=True, default=1.0,
|
||||
@@ -73,8 +72,8 @@ class QualityControlIssue(models.Model):
|
||||
digits_compute=dp.get_precision("Product Unit of Measure"))
|
||||
product_uom = fields.Many2one(
|
||||
comodel_name="product.uom", string="Product Unit of Measure",
|
||||
required=True, default=_get_uom,
|
||||
readonly=True, states={"new": [("readonly", False)]},)
|
||||
default=_get_uom, required=True, readonly=True,
|
||||
states={"new": [("readonly", False)]})
|
||||
lot_id = fields.Many2one(
|
||||
comodel_name="stock.production.lot", string="Lot/Serial Number",
|
||||
readonly=True, states={"new": [("readonly", False)]},)
|
||||
@@ -117,7 +116,7 @@ class QualityControlIssue(models.Model):
|
||||
'stage_id': _read_group_stage_ids
|
||||
}
|
||||
|
||||
def issue_stage_find(self, cases, team_id, domain=None, order='sequence'):
|
||||
def issue_stage_find(self, cases, team, domain=None, order='sequence'):
|
||||
""" Override of the base.stage method
|
||||
Parameter of the stage search taken from the problem:
|
||||
- team_id: if set, stages must belong to this team or
|
||||
@@ -125,26 +124,25 @@ class QualityControlIssue(models.Model):
|
||||
stages
|
||||
"""
|
||||
team_ids = set()
|
||||
if team_id:
|
||||
team_ids.add(team_id)
|
||||
for problem in cases:
|
||||
if problem.team_id:
|
||||
team_ids.add(problem.team_id.id)
|
||||
if team:
|
||||
team_ids.add(team.id)
|
||||
for issue in cases:
|
||||
if issue.team_id:
|
||||
team_ids.add(issue.team_id.id)
|
||||
search_domain = []
|
||||
if team_ids:
|
||||
search_domain += [('|')] * (len(team_ids) - 1)
|
||||
for team_id in team_ids:
|
||||
search_domain.append(('qc_team_id', '=', team_id.id))
|
||||
search_domain.append(('qc_team_id', '=', team_id))
|
||||
search_domain += list(domain)
|
||||
# perform search, return the first found
|
||||
stage_ids = self.env['qc.issue.stage'].search(
|
||||
stage = self.env['qc.issue.stage'].search(
|
||||
search_domain, order=order, limit=1)
|
||||
if stage_ids:
|
||||
return stage_ids[0]
|
||||
return False
|
||||
return stage
|
||||
|
||||
@api.multi
|
||||
def action_confirm(self):
|
||||
self._check_required_fields()
|
||||
self.write({'state': 'progress'})
|
||||
|
||||
@api.multi
|
||||
@@ -171,3 +169,8 @@ class QualityControlIssue(models.Model):
|
||||
if product:
|
||||
self.product_id = product
|
||||
self.product_uom = product.product_tmpl_id.uom_id
|
||||
|
||||
@api.onchange("stage_id")
|
||||
def _onchange_stage_id(self):
|
||||
if self.stage_id.state:
|
||||
self.state = self.stage_id.state
|
||||
|
||||
@@ -39,3 +39,6 @@ class QualityControlIssueStage(models.Model):
|
||||
string='Folded in Pipeline', default=False,
|
||||
help='This stage is folded in the kanban view when there are no '
|
||||
'records in that stage to display.')
|
||||
state = fields.Selection(
|
||||
string="QC Status",
|
||||
selection=lambda self: self.env['qc.issue']._fields['state'].selection)
|
||||
|
||||
@@ -19,9 +19,9 @@ class QcProblem(models.Model):
|
||||
|
||||
def _get_default_stage_id(self):
|
||||
""" Gives default stage_id """
|
||||
team_id = self.env['qc.team']._get_default_qc_team_id(
|
||||
team = self.env['qc.team']._get_default_qc_team_id(
|
||||
user_id=self.env.uid)
|
||||
return self.stage_find([], team_id, [('fold', '=', False)])
|
||||
return self.stage_find([], team, [('fold', '=', False)])
|
||||
|
||||
@api.multi
|
||||
def _read_group_stage_ids(self, domain, read_group_order=None,
|
||||
@@ -86,7 +86,7 @@ class QcProblem(models.Model):
|
||||
'stage_id': _read_group_stage_ids
|
||||
}
|
||||
|
||||
def stage_find(self, cases, team_id, domain=None, order='sequence'):
|
||||
def stage_find(self, cases, team, domain=None, order='sequence'):
|
||||
""" Override of the base.stage method
|
||||
Parameter of the stage search taken from the problem:
|
||||
- team_id: if set, stages must belong to this team or
|
||||
@@ -94,8 +94,8 @@ class QcProblem(models.Model):
|
||||
stages
|
||||
"""
|
||||
team_ids = set()
|
||||
if team_id:
|
||||
team_ids.add(team_id)
|
||||
if team:
|
||||
team_ids.add(team.id)
|
||||
for problem in cases:
|
||||
if problem.team_id:
|
||||
team_ids.add(problem.team_id.id)
|
||||
@@ -103,11 +103,9 @@ class QcProblem(models.Model):
|
||||
if team_ids:
|
||||
search_domain += [('|')] * (len(team_ids) - 1)
|
||||
for team_id in team_ids:
|
||||
search_domain.append(('qc_team_id', '=', team_id.id))
|
||||
search_domain.append(('qc_team_id', '=', team_id))
|
||||
search_domain += list(domain)
|
||||
# perform search, return the first found
|
||||
stage_ids = self.env['qc.stage'].search(
|
||||
stage = self.env['qc.stage'].search(
|
||||
search_domain, order=order, limit=1)
|
||||
if stage_ids:
|
||||
return stage_ids[0]
|
||||
return False
|
||||
return stage
|
||||
|
||||
@@ -87,7 +87,8 @@
|
||||
<field name="name">qc.issue.kanban</field>
|
||||
<field name="model">qc.issue</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_kanban_small_column" default_group_by="stage_id">
|
||||
<kanban class="o_kanban_small_column" default_group_by="stage_id"
|
||||
quick_create="false" create="true">
|
||||
<field name="stage_id"/>
|
||||
<field name="color"/>
|
||||
<templates>
|
||||
|
||||
Reference in New Issue
Block a user