Skip to content

Commit

Permalink
fix stage state relation and update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Jul 31, 2017
1 parent d824263 commit 713ad85
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 15 deletions.
54 changes: 47 additions & 7 deletions quality_control_issue/README.rst
Expand Up @@ -6,17 +6,58 @@
Quality Control Issue
=====================

WIP

This module extends the functionality of quality Control to allow you to
report and manage quality control issues.

Configuration
=============

To configure this module in order to take advantage of the kanban views you
need to create the stages for *issues* and *problems*. To **create** stages in
any kanban view click on *Add New Column*. Then you can **reorder** the stages
just dragging them.

In created stages you can **configure** them clicking on the gear button that
appears at the right of the stage name and clicking on *Edit*. Note the
following behaviors:

* You can set a *Quality Control Team*.

* Stages with no team set will be shared by all teams.
* Stages with a team associated will be only available for that specific
team.
* In Issue Stages you can also relate a *QC State* to the stage.

* When you move to a different stage an issue with *QC state* defined the
state of the issue will also change according to it.
* The other way around, if you change the state, the system will look for
an appropriate stage and if existing the issue will be move to that stage.
* If you change the *QC team* of an issue, the system will get the default
stage for that team and apply it to the issue.

Usage
=====

To use this module, you need to:
To use Quality Control Issues, you need to:

#. Go to *Quality Control > Issues > QC Issues* or to *Quality Control >
Dashboard* and click on *Issues* in any of your teams.
#. Click on create to report an issue.
#. Select the product and quantity for the issue. Optionally you can specify
a location and relate the issue to some *Problem*.

To manage your Quality Control Problems, you have to:

#. Go to *Quality Control > Problem Tracking > Problems* or to *Quality
Control > Dashboard* and click on *Problems* in any of your teams.

Issue Dispositions:
-------------------

You can perform the following actions in quality control issues 'in progress':

#. Go to *Quality Control > Issues > QC Issues*.
* Scrap: Click on *Scrap Products* button.
* Create RMA: Install `rma_quality_control_issue` and see instructions there.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
Expand All @@ -28,9 +69,7 @@ Known issues / Roadmap
Todo:
-----

* Add Dispositions: RMA, scrap, rework...
* reference to PO, MO, QC...
* Link to Problem tracking...
* Add more dispositions: repair, refurbish...

Bug Tracker
===========
Expand All @@ -52,6 +91,7 @@ Contributors
------------

* Lois Rilo <lois.rilo@eficent.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>

Maintainer
----------
Expand Down
38 changes: 32 additions & 6 deletions quality_control_issue/models/qc_issue.py
Expand Up @@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import api, fields, models, _
from openerp.exceptions import UserError
import openerp.addons.decimal_precision as dp


Expand Down Expand Up @@ -141,15 +142,45 @@ def issue_stage_find(self, cases, team, domain=None, order='sequence'):
team_ids.add(issue.team_id.id)
search_domain = []
if team_ids:
search_domain += [('|')] * (len(team_ids) - 1)
search_domain += [('|')] * (len(team_ids))
search_domain.append(('qc_team_id', '=', False))
for team_id in team_ids:
search_domain.append(('qc_team_id', '=', team_id))
else:
search_domain.append(('qc_team_id', '=', False))
search_domain += list(domain)
# perform search, return the first found
stage = self.env['qc.issue.stage'].search(
search_domain, order=order, limit=1)
return stage

@api.multi
def write(self, vals):
stage_obj = self.env['qc.issue.stage']
state = vals.get('state')
if state:
if len(self.mapped('qc_team_id')) > 1:
raise UserError(_(
"Every issue must have the same QC team to perform this "
"action."))
team = self[0].qc_team_id
stage = self.issue_stage_find([], team, [('state', '=', state)])
if stage:
vals.update({'stage_id': stage.id})
return super(QualityControlIssue, self).write(vals)
team_id = vals.get('qc_team_id')
if team_id is not None:
team = self.env['qc.team'].browse(team_id)
stage = self.issue_stage_find([], team, [('fold', '=', False)])
if stage:
vals.update({'stage_id': stage.id})
stage_id = vals.get('stage_id')
if stage_id:
state = stage_obj.browse(stage_id).state
if state:
vals.update({'state': state})
return super(QualityControlIssue, self).write(vals)

@api.multi
def action_confirm(self):
self.write({'state': 'progress'})
Expand Down Expand Up @@ -179,11 +210,6 @@ def _onchange_lot_id(self):
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

@api.multi
def scrap_products(self):
self.ensure_one()
Expand Down
2 changes: 1 addition & 1 deletion quality_control_issue/models/qc_issue_stage.py
Expand Up @@ -40,5 +40,5 @@ def default_get(self, fields):
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",
string="QC State",
selection=lambda self: self.env['qc.issue']._fields['state'].selection)
5 changes: 4 additions & 1 deletion quality_control_issue/models/qc_problem.py
Expand Up @@ -101,9 +101,12 @@ def stage_find(self, cases, team, domain=None, order='sequence'):
team_ids.add(problem.team_id.id)
search_domain = []
if team_ids:
search_domain += [('|')] * (len(team_ids) - 1)
search_domain += [('|')] * (len(team_ids))
search_domain.append(('qc_team_id', '=', False))
for team_id in team_ids:
search_domain.append(('qc_team_id', '=', team_id))
else:
search_domain.append(('qc_team_id', '=', False))
search_domain += list(domain)
# perform search, return the first found
stage = self.env['qc.stage'].search(
Expand Down

0 comments on commit 713ad85

Please sign in to comment.