Skip to content

Commit

Permalink
mrp_production_traceability
Browse files Browse the repository at this point in the history
IMP meta data
ADD Prodcution Lots Traceability tree view
  • Loading branch information
eLBati committed Jun 13, 2017
1 parent 82d2177 commit 797354c
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 30 deletions.
35 changes: 35 additions & 0 deletions mrp_production_traceability/README.rst
@@ -1,3 +1,7 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

Traceability for production orders
==================================

Expand All @@ -10,6 +14,21 @@ Traceability" button in the form of lots.
The lot, and the final product production, are displayed in the movements of
stock, also you can search and filter by these new fields.

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/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/manufacture/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Expand All @@ -19,3 +38,19 @@ Contributors
* Ana Juaristi <anajuaristi@avanzosc.es>
* Daniel Campos <danielcampos@avanzosc.es>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
31 changes: 6 additions & 25 deletions mrp_production_traceability/__openerp__.py
@@ -1,38 +1,18 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# -*- coding: utf-8 -*-
# Copyright (c)
# 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
# 2015 AvanzOsc (http://www.avanzosc.es)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2017 Lorenzo Battistini - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "MRP Production Traceability",
"version": "1.0",
"version": "8.0.1.0.0",
"author": "OdooMRP team,"
"AvanzOSC,"
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
"website": "http://www.odoomrp.com",
"category": "Manufacturing",
"contributors": [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <anajuaristi@avanzosc.es>",
"Daniel Campos <danielcampos@avanzosc.es>",
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
],
"depends": [
"mrp",
"stock",
Expand All @@ -42,6 +22,7 @@
"views/mrp_production_view.xml",
"views/track_lot_view.xml",
"views/stock_move_view.xml",
"wizard/open_lots_tree_view.xml",
],
"installable": True,
}
38 changes: 34 additions & 4 deletions mrp_production_traceability/models/stock_production_lot.py
@@ -1,13 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models, api, _
# Copyright (c)
# 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
# 2015 AvanzOsc (http://www.avanzosc.es)
# Copyright 2017 Lorenzo Battistini - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api, _, fields


class stock_production_lot(models.Model):
_inherit = 'stock.production.lot'

track_lot_component_ids = fields.One2many(
'mrp.track.lot', 'component_lot', readonly=True,
string="Components tracking"
)
track_lot_final_ids = fields.One2many(
'mrp.track.lot', 'product_lot', readonly=True,
string="Final Products tracking"
)
parent_id = fields.Many2one(
'stock.production.lot', compute="_compute_parent_id", store=True,
string="Final production lot", readonly=True
)
children_ids = fields.One2many(
'stock.production.lot', 'parent_id', 'Components')

@api.multi
@api.depends("track_lot_component_ids", "track_lot_final_ids")
def _compute_parent_id(self):
track_model = self.env['mrp.track.lot']
for lot in self:
lot.parent_id = None
final_lot_ids = track_model.search([
('component_lot', '=', lot.id)
])
if len(final_lot_ids) == 1:
lot.parent_id = final_lot_ids[0].product_lot.id

@api.multi
def total_traceability(self):
""" It traces the information of lots
Expand Down
25 changes: 24 additions & 1 deletion mrp_production_traceability/views/stock_move_view.xml
Expand Up @@ -2,7 +2,7 @@
<openerp>
<data>

<!-- stock.move.view -->
<!-- stock.production.lot views -->
<record id="view_production_lot_form_inh_productiontrace" model="ir.ui.view">
<field name="name">view.production.lot.form.inh.productiontrace</field>
<field name="model">stock.production.lot</field>
Expand All @@ -12,8 +12,31 @@
<button name="total_traceability" icon="fa-arrows-v" class="oe_stat_button" type="object" string="Full traceability"
attrs="{'invisible': [('quant_ids','=',[])]}"/>
</button>
<field name="ref" position="after">
<field name="parent_id"></field>
</field>
</field>
</record>

<record id="view_lot_traceability_tree" model="ir.ui.view">
<field name="name">stock.production.lot.traceability.tree</field>
<field name="model">stock.production.lot</field>
<field name="field_parent">children_ids</field>
<field name="arch" type="xml">
<tree string="Production lot traceability" toolbar="1">
<field name="name"/>
</tree>
</field>
</record>
<record id="action_lot_traceability_tree" model="ir.actions.act_window">
<field name="name">Production Lots traceability</field>
<field name="res_model">stock.production.lot</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_lot_traceability_tree"/>
</record>

<!-- stock.move views -->
<record id="stock_move_tree_inh_productiontrace" model="ir.ui.view">
<field name="name">stock.move.tree.inh.productiontrace</field>
<field name="model">stock.move</field>
Expand Down
1 change: 1 addition & 0 deletions mrp_production_traceability/wizard/__init__.py
Expand Up @@ -3,3 +3,4 @@
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import mrp_product_produce
from . import open_lots_tree
22 changes: 22 additions & 0 deletions mrp_production_traceability/wizard/open_lots_tree.py
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Lorenzo Battistini - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields, api


class OpenLotsTree(models.TransientModel):
_name = 'stock.production.lot.open.tree'
lot_id = fields.Many2one(
'stock.production.lot', required=True, string="Production lot")

@api.multi
def open_lots_tree(self):
self.ensure_one()
data_model = self.env['ir.model.data']
act_model = self.env['ir.actions.act_window']
id = data_model.get_object_reference(
'mrp_production_traceability', 'action_lot_traceability_tree')[1]
result = act_model.browse(id).read()[0]
result['domain'] = [('id', '=', self.lot_id.id)]
return result
36 changes: 36 additions & 0 deletions mrp_production_traceability/wizard/open_lots_tree_view.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_open_lots_tree" model="ir.ui.view">
<field name="name">stock.production.lot.open.tree.form</field>
<field name="model">stock.production.lot.open.tree</field>
<field name="arch" type="xml">
<form string="Prodcution Lots Traceability">
<group>
<field name="lot_id"></field>
</group>
<footer>
<button string="Open Lots Tree" name="open_lots_tree" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="action_view_open_lots_tree" model="ir.actions.act_window">
<field name="name">Prodcution Lots Traceability</field>
<field name="res_model">stock.production.lot.open.tree</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_open_lots_tree"/>
<field name="target">new</field>
</record>

<menuitem id="menu_action_view_open_lots_tree" name="Production Lots Tree"
parent="stock.menu_traceability" action="action_view_open_lots_tree"
sequence="4" />

</data>
</openerp>

0 comments on commit 797354c

Please sign in to comment.