[REM] mrp: Remove unnecessary stock_move_consume wizard and stock value variation and workcenter load report

This commit is contained in:
Josse Colpaert
2016-09-28 12:42:59 +02:00
parent 1dedb95c41
commit 3597942721
8 changed files with 0 additions and 279 deletions
-2
View File
@@ -40,7 +40,6 @@ Dashboard / Reports for MRP will include:
'data/mrp_data.yml',
'wizard/mrp_product_produce_views.xml',
'wizard/change_production_qty_views.xml',
'wizard/stock_move_consume_views.xml',
'wizard/mrp_workcenter_block_view.xml',
'views/mrp_views_menus.xml',
'views/stock_move_views.xml',
@@ -60,7 +59,6 @@ Dashboard / Reports for MRP will include:
'views/mrp_templates.xml',
'views/stock_scrap_views.xml',
'report/mrp_report_views_main.xml',
'report/mrp_report_views.xml',
'report/mrp_production_templates.xml',
'report/mrp_bom_structure_report_templates.xml',
'report/mrp_bom_cost_report_templates.xml',
-1
View File
@@ -3,4 +3,3 @@
import mrp_bom_cost_report
import mrp_bom_structure_report
import mrp_report
-80
View File
@@ -1,80 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools import drop_view_if_exists
class WorkCenterLoad(models.Model):
_name = "report.workcenter.load"
_description = "Work Center Load"
_auto = False
_log_access = False
name = fields.Char('Week', required=True)
workcenter_id = fields.Many2one('mrp.workcenter', 'Work Center', required=True)
duration = fields.Float('Duration')
@api.model_cr
def init(self):
drop_view_if_exists(self._cr, 'report_workcenter_load')
self._cr.execute("""
create view report_workcenter_load as (
SELECT
min(wl.id) as id,
to_char(p.date_planned_start,'YYYY:mm:dd') as name,
SUM(wl.duration_expected) AS duration,
wl.workcenter_id as workcenter_id
FROM
mrp_workorder wl
LEFT JOIN mrp_production p
ON p.id = wl.production_id
GROUP BY
wl.workcenter_id,
to_char(p.date_planned_start,'YYYY:mm:dd')
)""")
class ValueVariation(models.Model):
_name = "report.mrp.inout"
_description = "Stock value variation"
_auto = False
_log_access = False
_rec_name = 'date'
date = fields.Char('Week', required=True)
value = fields.Float('Stock value', required=True, digits=(16, 2))
company_id = fields.Many2one('res.company', 'Company', required=True)
@api.model_cr
def init(self):
drop_view_if_exists(self._cr, 'report_mrp_inout')
self._cr.execute("""
create view report_mrp_inout as (
select
min(sm.id) as id,
to_char(sm.date,'YYYY:IW') as date,
sum(case when (sl.usage='internal') then
sm.price_unit * sm.product_qty
else
0.0
end - case when (sl2.usage='internal') then
sm.price_unit * sm.product_qty
else
0.0
end) as value,
sm.company_id
from
stock_move sm
left join product_product pp
on (pp.id = sm.product_id)
left join product_template pt
on (pt.id = pp.product_tmpl_id)
left join stock_location sl
on ( sl.id = sm.location_id)
left join stock_location sl2
on ( sl2.id = sm.location_dest_id)
where
sm.state = 'done'
group by
to_char(sm.date,'YYYY:IW'), sm.company_id
)""")
-90
View File
@@ -1,90 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_workcenter_load_tree" model="ir.ui.view">
<field name="name">report.workcenter.load.tree</field>
<field name="model">report.workcenter.load</field>
<field name="arch" type="xml">
<tree string="Work Center Loads">
<field name="name"/>
<field name="workcenter_id"/>
<field name="duration"/>
</tree>
</field>
</record>
<record id="view_workcenter_load_graph" model="ir.ui.view">
<field name="name">report.workcenter.load.graph</field>
<field name="model">report.workcenter.load</field>
<field name="arch" type="xml">
<graph string="Work Center load" type="bar">
<field name="name"/>
<field name="duration" operator="+"/>
<field group="True" name="workcenter_id"/>
</graph>
</field>
</record>
<record id="view_workcenter_load_search" model="ir.ui.view">
<field name="name">report.workcenter.load.search</field>
<field name="model">report.workcenter.load</field>
<field name="arch" type="xml">
<search string="Work Center load">
<field name="name" string="Week"/>
<field name="workcenter_id"/>
</search>
</field>
</record>
<!-- stock.move compared to internal location src/dest -->
<record id="view_report_in_out_picking_tree" model="ir.ui.view">
<field name="name">report.mrp.inout.tree</field>
<field name="model">report.mrp.inout</field>
<field name="arch" type="xml">
<tree string="Stock value variation">
<field name="company_id" groups="base.group_multi_company"/>
<field name="date"/>
<field name="value"/>
</tree>
</field>
</record>
<record id="view_report_in_out_picking_form" model="ir.ui.view">
<field name="name">report.mrp.inout.form</field>
<field name="model">report.mrp.inout</field>
<field name="arch" type="xml">
<form string="Stock value variation">
<group col="4">
<field name="date"/>
<field name="value"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</form>
</field>
</record>
<record id="view_report_in_out_picking_graph" model="ir.ui.view">
<field name="name">report.mrp.inout.graph</field>
<field name="model">report.mrp.inout</field>
<field name="arch" type="xml">
<graph string="Stock value variation" type="bar">
<field name="company_id" groups="base.group_multi_company"/>
<field name="date"/>
<field name="value" operator="+"/>
</graph>
</field>
</record>
<record id="action_report_in_out_picking_tree" model="ir.actions.act_window">
<field name="name">Weekly Stock Value Variation</field>
<field name="res_model">report.mrp.inout</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="help">Weekly Stock Value Variation enables you to track the stock value evolution linked to manufacturing activities, receipts of products and delivery orders.</field>
</record>
</data>
</odoo>
-4
View File
@@ -21,8 +21,6 @@ access_stock_picking_mrp_worker,stock.picking mrp_worker,stock.model_stock_picki
access_stock_warehouse,stock.warehouse mrp_worker,stock.model_stock_warehouse,mrp.group_mrp_user,1,0,0,0
access_procurement_user,procurement.order.user,model_procurement_order,base.group_user,1,1,1,1
access_mrp_production_stock_worker,mrp.production stock_worker,model_mrp_production,stock.group_stock_user,1,0,0,0
access_report_workcenter_load,report.workcenter.load,model_report_workcenter_load,mrp.group_mrp_manager,1,1,1,1
access_report_mrp_inout,report.mrp.inout,model_report_mrp_inout,mrp.group_mrp_manager,1,1,1,1
access_product_product_user,product.product user,product.model_product_product,mrp.group_mrp_user,1,0,0,0
access_product_template_user,product.template user,product.model_product_template,mrp.group_mrp_user,1,0,0,0
access_product_uom_user,product.uom user,product.model_product_uom,mrp.group_mrp_user,1,0,0,0
@@ -43,8 +41,6 @@ access_stock_move_mrp_manager,stock.move mrp_manager,stock.model_stock_move,mrp.
access_stock_production_lot_user,stock.production.lot,stock.model_stock_production_lot,mrp.group_mrp_user,1,1,1,1
access_stock_warehouse_orderpoint_user,stock.warehouse.orderpoint,stock.model_stock_warehouse_orderpoint,mrp.group_mrp_user,1,0,0,0
access_stock_picking_mrp_manager,stock.picking mrp_manager,stock.model_stock_picking,mrp.group_mrp_manager,1,0,0,0
access_report_mrp_inout_user,report.mrp.inout user,model_report_mrp_inout,mrp.group_mrp_user,1,0,0,0
access_report_workcenter_load_user,report.workcenter.load.user,model_report_workcenter_load,mrp.group_mrp_user,1,0,0,0
access_mrp_bom_stockuser,mrp.bom,model_mrp_bom,stock.group_stock_user,1,0,0,0
access_mrp_bom_line_stockuser,mrp.bom.line,model_mrp_bom_line,stock.group_stock_user,1,0,0,0
access_product_uom_categ_mrp_manager,product.uom.categ mrp_manager,product.model_product_uom_categ,mrp.group_mrp_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
21 access_stock_warehouse stock.warehouse mrp_worker stock.model_stock_warehouse mrp.group_mrp_user 1 0 0 0
22 access_procurement_user procurement.order.user model_procurement_order base.group_user 1 1 1 1
23 access_mrp_production_stock_worker mrp.production stock_worker model_mrp_production stock.group_stock_user 1 0 0 0
access_report_workcenter_load report.workcenter.load model_report_workcenter_load mrp.group_mrp_manager 1 1 1 1
access_report_mrp_inout report.mrp.inout model_report_mrp_inout mrp.group_mrp_manager 1 1 1 1
24 access_product_product_user product.product user product.model_product_product mrp.group_mrp_user 1 0 0 0
25 access_product_template_user product.template user product.model_product_template mrp.group_mrp_user 1 0 0 0
26 access_product_uom_user product.uom user product.model_product_uom mrp.group_mrp_user 1 0 0 0
41 access_stock_production_lot_user stock.production.lot stock.model_stock_production_lot mrp.group_mrp_user 1 1 1 1
42 access_stock_warehouse_orderpoint_user stock.warehouse.orderpoint stock.model_stock_warehouse_orderpoint mrp.group_mrp_user 1 0 0 0
43 access_stock_picking_mrp_manager stock.picking mrp_manager stock.model_stock_picking mrp.group_mrp_manager 1 0 0 0
access_report_mrp_inout_user report.mrp.inout user model_report_mrp_inout mrp.group_mrp_user 1 0 0 0
access_report_workcenter_load_user report.workcenter.load.user model_report_workcenter_load mrp.group_mrp_user 1 0 0 0
44 access_mrp_bom_stockuser mrp.bom model_mrp_bom stock.group_stock_user 1 0 0 0
45 access_mrp_bom_line_stockuser mrp.bom.line model_mrp_bom_line stock.group_stock_user 1 0 0 0
46 access_product_uom_categ_mrp_manager product.uom.categ mrp_manager product.model_product_uom_categ mrp.group_mrp_manager 1 1 1 1
-1
View File
@@ -3,4 +3,3 @@
import mrp_product_produce
import change_production_qty
import stock_move_consume
-62
View File
@@ -1,62 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools import float_compare
from odoo.addons import decimal_precision as dp
class StockMoveConsume(models.TransientModel):
_name = "stock.move.consume"
_description = "Consume Products"
product_id = fields.Many2one(
'product.product', 'Product',
index=True, required=True)
product_qty = fields.Float(
'Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True)
product_uom = fields.Many2one(
'product.uom', 'Product Unit of Measure',
required=True)
location_id = fields.Many2one(
'stock.location', 'Location',
required=True)
restrict_lot_id = fields.Many2one(
'stock.production.lot', 'Lot')
# TOFIX: product_uom should not have different category of default UOM of product. Qty should be convert into UOM of original move line before going in consume and scrap
def default_get(self, fields):
res = super(StockMoveConsume, self).default_get(fields)
move = self.env['stock.move'].browse(self._context['active_id'])
if 'product_id' in fields:
res['product_id'] = move.product_id.id
if 'product_uom' in fields:
res['product_uom'] = move.product_uom.id
if 'product_qty' in fields:
res['product_qty'] = move.product_uom_qty
if 'location_id' in fields:
res['location_id'] = move.location_id.id
return res
@api.multi
def do_move_consume(self):
Production = self.env['mrp.production']
move = self.env['stock.move'].browse(self._context['active_id'])
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
for wizard in self:
qty = wizard.product_uom._compute_quantity(wizard.product_qty, wizard.product_id.uom_id)
remaining_qty = move.product_qty - qty
# check for product quantity is less than previously planned
if float_compare(remaining_qty, 0, precision_digits=precision) >= 0:
move.action_consume(qty, wizard.location_id.id, restrict_lot_id=wizard.restrict_lot_id.id)
else:
consumed_qty = min(move.product_qty, qty)
move.action_consume(consumed_qty, wizard.location_id.id, restrict_lot_id=wizard.restrict_lot_id.id)
# consumed more in wizard than previously planned
extra_more_qty = qty - consumed_qty
# create new line for a remaining qty of the product
extra_move = Production._make_consume_line_from_data(move.raw_material_production_id, wizard.product_id, wizard.product_id.uom_id.id, extra_more_qty)
extra_move.write({'restrict_lot_id': wizard.restrict_lot_id.id})
extra_move.action_done()
return {'type': 'ir.actions.act_window_close'}
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Consume, scrap move -->
<record id="view_stock_move_consume_wizard" model="ir.ui.view">
<field name="name">Consume Move</field>
<field name="model">stock.move.consume</field>
<field name="arch" type="xml">
<form string="Consume Move">
<group string="Consume Products">
<field name="product_id" readonly="1"/>
<label for="product_qty"/>
<div>
<field name="product_qty" class="oe_inline"/>
<field name="product_uom" class="oe_inline" readonly="1" groups="product.group_uom"/>
</div>
<field name="restrict_lot_id" domain="[('product_id','=',product_id)]" groups="stock.group_production_lot"
context="{'default_product_id': product_id}"/>
<field name="location_id" groups="stock.group_stock_multi_locations"/>
</group>
<footer>
<button name="do_move_consume" string="Ok" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="move_consume" model="ir.actions.act_window">
<field name="name">Consume Move</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.consume</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</odoo>