Skip to content

Commit

Permalink
Several improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed May 26, 2017
1 parent 626ef6d commit 2745524
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 11 deletions.
4 changes: 3 additions & 1 deletion quality_control_issue/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Quality Control Issue
=====================

WIP

This module extends the functionality of Non-Conformance Material Report
to allow you to report quality control issues.

Expand All @@ -19,7 +21,7 @@ Usage

To use this module, you need to:

#. Go to *Quality Control > NCMR > Non-Conforming Material Report*.
#. Go to *Quality Control > Issues > QC Issues*.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
Expand Down
1 change: 1 addition & 0 deletions quality_control_issue/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"data": [
"data/qc_issue_sequence.xml",
"views/qc_issue_view.xml",
"views/qc_problem_track_view.xml",
],
}
1 change: 1 addition & 0 deletions quality_control_issue/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import qc_issue
from . import qc_problem_track
26 changes: 24 additions & 2 deletions quality_control_issue/models/qc_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class QualityControlIssue(models.Model):
_name = "qc.issue"
_description = "Nonconforming Material Report"
_description = "Quality Control Issue"
_inherit = "mail.thread"

@api.model
Expand All @@ -18,10 +18,26 @@ def create(self, vals):
return super(QualityControlIssue, self).create(vals)

@api.one
@api.onchange("product_id")
def _get_uom(self):
self.product_uom = self.product_id.product_tmpl_id.uom_id

@api.one
@api.onchange('product_id')
def _set_lot_domain(self):
self.product_uom = self.product_id.product_tmpl_id.uom_id
if self.product_id:
return {'domain': {
'lot_id': [('product_id', '=', self.product_id.id)]}}
return {}

@api.one
@api.onchange("lot_id")
def _onchange_lot_id(self):
product = self.lot_id.product_id
if product:
self.product_id = product
self.product_uom = product.product_tmpl_id.uom_id

name = fields.Char(readonly=True)
state = fields.Selection(
selection=[("new", "New"),
Expand All @@ -32,6 +48,7 @@ def _get_uom(self):
comodel_name="product.product", string="Product",
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,
readonly=True, states={"new": [("readonly", False)]},
Expand All @@ -57,6 +74,11 @@ def _get_uom(self):
states={"done": [("readonly", True)]},)
description = fields.Text(
states={"done": [("readonly", True)]},)
problem_track_ids = fields.Many2many(
comodel_name="qc.problem.track", string="Problems",
relation="qc_issue_problem_rel", column1="qc_issue_id",
column2="qc_problem_id",
states={"done": [("readonly", True)]},)

@api.multi
def action_confirm(self):
Expand Down
18 changes: 18 additions & 0 deletions quality_control_issue/models/qc_problem_track.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- 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 openerp import api, fields, models


class QcProblemTrack(models.Model):
_name = "qc.problem.track"
_description = "Quality Control Problem Tracking"
_inherit = "mail.thread"

name = fields.Char()
notes = fields.Text()
issue_ids = fields.Many2many(
comodel_name="qc.issue", string="QC Issues",
relation="qc_issue_problem_rel", column1="qc_problem_id",
column2="qc_issue_id")
Binary file added quality_control_issue/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions quality_control_issue/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions quality_control_issue/views/qc_issue_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<odoo>

<record id="qc_issue_tree" model="ir.ui.view">
<field name="name">My view description</field>
<field name="name">qc.issue.tree</field>
<field name="model">qc.issue</field>
<field name="arch" type="xml">
<tree string="NCMRs">
Expand All @@ -19,7 +19,7 @@
</record>

<record id="qc_issue_form" model="ir.ui.view">
<field name="name">My view description</field>
<field name="name">qc.issue.form</field>
<field name="model">qc.issue</field>
<field name="arch" type="xml">
<form>
Expand Down Expand Up @@ -62,15 +62,20 @@
</group>
<group>
<field name="lot_id"
groups="stock.group_production_lot"/>
groups="stock.group_production_lot"
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_tracking" invisible="1"/>
<field name="product_qty"
attrs="{'invisible': [('product_tracking', '=', 'serial')]}"/>
<field name="product_uom"
groups="product.group_uom"/>
groups="product.group_uom"
attrs="{'invisible': [('product_tracking', '=', 'serial')]}"/>
<field name="location_id"/>
</group>
</group>
<group name="bottom">
<field name="problem_track_ids" widget="many2many_tags"/>
<field name="description"/>
</group>
</sheet>
Expand All @@ -83,19 +88,19 @@
</record>

<record id="qc_issue_action" model="ir.actions.act_window">
<field name="name">Non-Conforming Material Reports</field>
<field name="name">QC Issues</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">qc.issue</field>
<field name="view_type">form</field>
</record>

<menuitem id="menu_qc_ncmr"
parent="quality_control.qc_menu"
sequence="50" name="NCMR"/>
sequence="50" name="Issues"/>

<menuitem id="menu_qc_issue"
parent="quality_control_issue.menu_qc_ncmr"
action="qc_issue_action"
sequence="50" name="Non-Conforming Material Report"/>
sequence="20" name="Issues"/>

</odoo>
53 changes: 53 additions & 0 deletions quality_control_issue/views/qc_problem_track_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record id="qc_problem_track_tree" model="ir.ui.view">
<field name="name">My view description</field>
<field name="model">qc.problem.track</field>
<field name="arch" type="xml">
<tree string="Problem Tracking">
<field name="name"/>
</tree>
</field>
</record>

<record id="qc_problem_track_form" model="ir.ui.view">
<field name="name">My view description</field>
<field name="model">qc.problem.track</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="notes"/>
</group>
<notebook>
<page name="qc_issues" string="QC Issues">
<field name="issue_ids"/>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
</form>
</field>
</record>

<record id="qc_problem_track_action" model="ir.actions.act_window">
<field name="name">Problem Tracking</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">qc.problem.track</field>
<field name="view_type">form</field>
</record>

<menuitem id="menu_qc_problem_track"
parent="quality_control_issue.menu_qc_ncmr"
action="qc_problem_track_action"
sequence="40" name="Problem Tracking"/>

</odoo>

0 comments on commit 2745524

Please sign in to comment.