From 3597942721f9d2bc0f9ea0d7d71e7da367e68d66 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 8 Sep 2016 17:58:48 +0200 Subject: [PATCH] [REM] mrp: Remove unnecessary stock_move_consume wizard and stock value variation and workcenter load report --- addons/mrp/__manifest__.py | 2 - addons/mrp/report/__init__.py | 1 - addons/mrp/report/mrp_report.py | 80 ----------------- addons/mrp/report/mrp_report_views.xml | 90 ------------------- addons/mrp/security/ir.model.access.csv | 4 - addons/mrp/wizard/__init__.py | 1 - addons/mrp/wizard/stock_move_consume.py | 62 ------------- .../mrp/wizard/stock_move_consume_views.xml | 39 -------- 8 files changed, 279 deletions(-) delete mode 100644 addons/mrp/report/mrp_report.py delete mode 100644 addons/mrp/report/mrp_report_views.xml delete mode 100644 addons/mrp/wizard/stock_move_consume.py delete mode 100644 addons/mrp/wizard/stock_move_consume_views.xml diff --git a/addons/mrp/__manifest__.py b/addons/mrp/__manifest__.py index e8b5aa798e6..78b3a6e6c03 100644 --- a/addons/mrp/__manifest__.py +++ b/addons/mrp/__manifest__.py @@ -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', diff --git a/addons/mrp/report/__init__.py b/addons/mrp/report/__init__.py index a3ba4a1f517..ecdaf9eb691 100644 --- a/addons/mrp/report/__init__.py +++ b/addons/mrp/report/__init__.py @@ -3,4 +3,3 @@ import mrp_bom_cost_report import mrp_bom_structure_report -import mrp_report \ No newline at end of file diff --git a/addons/mrp/report/mrp_report.py b/addons/mrp/report/mrp_report.py deleted file mode 100644 index 0d8dc1bb32c..00000000000 --- a/addons/mrp/report/mrp_report.py +++ /dev/null @@ -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 - )""") diff --git a/addons/mrp/report/mrp_report_views.xml b/addons/mrp/report/mrp_report_views.xml deleted file mode 100644 index 3be954d9e7d..00000000000 --- a/addons/mrp/report/mrp_report_views.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - report.workcenter.load.tree - report.workcenter.load - - - - - - - - - - - report.workcenter.load.graph - report.workcenter.load - - - - - - - - - - - report.workcenter.load.search - report.workcenter.load - - - - - - - - - - - - report.mrp.inout.tree - report.mrp.inout - - - - - - - - - - - report.mrp.inout.form - report.mrp.inout - -
- - - - - -
-
-
- - - - report.mrp.inout.graph - report.mrp.inout - - - - - - - - - - - Weekly Stock Value Variation - report.mrp.inout - form - graph,tree - Weekly Stock Value Variation enables you to track the stock value evolution linked to manufacturing activities, receipts of products and delivery orders. - - -
-
diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv index 1ee0cd9f5b0..7e1203f4d5e 100644 --- a/addons/mrp/security/ir.model.access.csv +++ b/addons/mrp/security/ir.model.access.csv @@ -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 diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 956e2a72109..50258a9f61f 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -3,4 +3,3 @@ import mrp_product_produce import change_production_qty -import stock_move_consume diff --git a/addons/mrp/wizard/stock_move_consume.py b/addons/mrp/wizard/stock_move_consume.py deleted file mode 100644 index 6d6c9ddc179..00000000000 --- a/addons/mrp/wizard/stock_move_consume.py +++ /dev/null @@ -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'} diff --git a/addons/mrp/wizard/stock_move_consume_views.xml b/addons/mrp/wizard/stock_move_consume_views.xml deleted file mode 100644 index ee195070bac..00000000000 --- a/addons/mrp/wizard/stock_move_consume_views.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - Consume Move - stock.move.consume - -
- - - -
-
-
-
-
- - - Consume Move - ir.actions.act_window - stock.move.consume - form - form - new - - -
-