From 3d9e2a6cb73134afbf9679d24a565a89b31446ed Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 27 Aug 2015 12:06:44 +0200 Subject: [PATCH] [IMP] mrp*: adaptation due to the new Sale module Major changes: - No use of UoS anymore Reason: complete rewrite of the Sale module. Responsible: fp, dbo, nim --- addons/mrp/mrp.py | 58 +++---------------------- addons/mrp/mrp_demo.xml | 3 -- addons/mrp/mrp_view.xml | 12 ----- addons/mrp/procurement.py | 2 - addons/mrp/security/ir.model.access.csv | 1 - addons/mrp/stock.py | 6 +-- addons/mrp/test/order_process.yml | 12 +---- addons/mrp/wizard/stock_move.py | 4 +- addons/mrp_repair/mrp_repair.py | 4 +- 9 files changed, 11 insertions(+), 91 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 59e81b14879..bd67839d8b3 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -62,7 +62,6 @@ class mrp_workcenter(osv.osv): 'costs_cycle': fields.float('Cost per cycle', help="Specify Cost of Work Center per cycle."), 'costs_cycle_account_id': fields.many2one('account.analytic.account', 'Cycle Account', domain=[('type','!=','view')], help="Fill this only if you want automatic analytic accounting entries on production orders."), - 'costs_journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal'), 'costs_general_account_id': fields.many2one('account.account', 'General Account', domain=[('deprecated', '=', False)]), 'resource_id': fields.many2one('resource.resource','Resource', ondelete='cascade', required=True), 'product_id': fields.many2one('product.product','Work Center Product', help="Fill this product to easily track your production costs in the analytic accounting."), @@ -320,9 +319,7 @@ class mrp_bom(osv.osv): 'name': bom_line_id.product_id.name, 'product_id': bom_line_id.product_id.id, 'product_qty': quantity, - 'product_uom': bom_line_id.product_uom.id, - 'product_uos_qty': bom_line_id.product_uos and _factor(bom_line_id.product_uos_qty * factor, bom_line_id.product_efficiency, bom_line_id.product_rounding) or False, - 'product_uos': bom_line_id.product_uos and bom_line_id.product_uos.id or False, + 'product_uom': bom_line_id.product_uom.id }) elif bom_id: all_prod = [bom.product_tmpl_id.id] + (previous_products or []) @@ -410,8 +407,6 @@ class mrp_bom_line(osv.osv): "it will be directly replaced by the raw materials of its own BoM, without triggering" "an extra manufacturing order."), 'product_id': fields.many2one('product.product', 'Product', required=True), - 'product_uos_qty': fields.float('Product UOS Qty'), - 'product_uos': fields.many2one('product.uom', 'Product UOS', help="Product UOS (Unit of Sale) is the unit of measurement for the invoicing and promotion of stock."), 'product_qty': fields.float('Product Quantity', required=True, digits_compute=dp.get_precision('Product Unit of Measure')), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True, help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control"), @@ -473,12 +468,7 @@ class mrp_bom_line(osv.osv): prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) res['value'] = { 'product_uom': prod.uom_id.id, - 'product_uos_qty': 0, - 'product_uos': False } - if prod.uos_id.id: - res['value']['product_uos_qty'] = product_qty * prod.uos_coeff - res['value']['product_uos'] = prod.uos_id.id return res class mrp_production(osv.osv): @@ -572,8 +562,6 @@ class mrp_production(osv.osv): domain=[('type', 'in', ['product', 'consu'])]), 'product_qty': fields.float('Product Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True, readonly=True, states={'draft': [('readonly', False)]}), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True, readonly=True, states={'draft': [('readonly', False)]}), - 'product_uos_qty': fields.float('Product UoS Quantity', readonly=True, states={'draft': [('readonly', False)]}), - 'product_uos': fields.many2one('product.uom', 'Product UoS', readonly=True, states={'draft': [('readonly', False)]}), 'progress': fields.function(_get_progress, type='float', string='Production progress'), @@ -698,8 +686,6 @@ class mrp_production(osv.osv): 'product_uom': False, 'bom_id': False, 'routing_id': False, - 'product_uos_qty': 0, - 'product_uos': False, 'product_tmpl_id': False }} bom_obj = self.pool.get('mrp.bom') @@ -710,10 +696,7 @@ class mrp_production(osv.osv): bom_point = bom_obj.browse(cr, uid, bom_id, context=context) routing_id = bom_point.routing_id.id or False product_uom_id = product.uom_id and product.uom_id.id or False - result['value'] = {'product_uos_qty': 0, 'product_uos': False, 'product_uom': product_uom_id, 'bom_id': bom_id, 'routing_id': routing_id, 'product_tmpl_id': product.product_tmpl_id} - if product.uos_id.id: - result['value']['product_uos_qty'] = product_qty * product.uos_coeff - result['value']['product_uos'] = product.uos_id.id + result['value'] = {'product_uom': product_uom_id, 'bom_id': bom_id, 'routing_id': routing_id, 'product_tmpl_id': product.product_tmpl_id} return result def bom_id_change(self, cr, uid, ids, bom_id, context=None): @@ -1065,7 +1048,7 @@ class mrp_production(osv.osv): analytic_line_obj = self.pool.get('account.analytic.line') for wc_line in production.workcenter_lines: wc = wc_line.workcenter_id - if wc.costs_journal_id and wc.costs_general_account_id: + if wc.costs_general_account_id: # Cost per hour value = wc_line.hour * wc.costs_hour account = wc.costs_hour_account_id.id @@ -1079,7 +1062,6 @@ class mrp_production(osv.osv): 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, - 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc_line.hour, @@ -1095,7 +1077,6 @@ class mrp_production(osv.osv): 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, - 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc_line.cycle, @@ -1138,8 +1119,6 @@ class mrp_production(osv.osv): 'product_id': production.product_id.id, 'product_uom': production.product_uom.id, 'product_uom_qty': production.product_qty, - 'product_uos_qty': production.product_uos and production.product_uos_qty or False, - 'product_uos': production.product_uos and production.product_uos.id or False, 'location_id': source_location_id, 'location_dest_id': destination_location_id, 'move_dest_id': production.move_prod_id.id, @@ -1214,7 +1193,7 @@ class mrp_production(osv.osv): }, context=context) return move - def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty, uos_id, uos_qty, context=None): + def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty, context=None): stock_move = self.pool.get('stock.move') loc_obj = self.pool.get('stock.location') # Internal shipment is created for Stockable and Consumer Products @@ -1235,8 +1214,6 @@ class mrp_production(osv.osv): 'product_id': product.id, 'product_uom_qty': qty, 'product_uom': uom_id, - 'product_uos_qty': uos_id and uos_qty or False, - 'product_uos': uos_id or False, 'location_id': source_location_id, 'location_dest_id': destination_location_id, 'company_id': production.company_id.id, @@ -1256,27 +1233,7 @@ class mrp_production(osv.osv): return move_id def _make_production_consume_line(self, cr, uid, line, context=None): - return self._make_consume_line_from_data(cr, uid, line.production_id, line.product_id, line.product_uom.id, line.product_qty, line.product_uos.id, line.product_uos_qty, context=context) - - - def _make_service_procurement(self, cr, uid, line, context=None): - prod_obj = self.pool.get('product.product') - if prod_obj.need_procurement(cr, uid, [line.product_id.id], context=context): - vals = { - 'name': line.production_id.name, - 'origin': line.production_id.name, - 'company_id': line.production_id.company_id.id, - 'date_planned': line.production_id.date_planned, - 'product_id': line.product_id.id, - 'product_qty': line.product_qty, - 'product_uom': line.product_uom.id, - 'product_uos_qty': line.product_uos_qty, - 'product_uos': line.product_uos.id, - } - proc_obj = self.pool.get("procurement.order") - proc = proc_obj.create(cr, uid, vals, context=context) - proc_obj.run(cr, uid, [proc], context=context) - + return self._make_consume_line_from_data(cr, uid, line.production_id, line.product_id, line.product_uom.id, line.product_qty, context=context) def action_confirm(self, cr, uid, ids, context=None): """ Confirms production order. @@ -1288,14 +1245,11 @@ class mrp_production(osv.osv): self.action_compute(cr, uid, uncompute_ids, context=context) for production in self.browse(cr, uid, ids, context=context): self._make_production_produce_line(cr, uid, production, context=context) - stock_moves = [] for line in production.product_lines: if line.product_id.type in ['product', 'consu']: stock_move_id = self._make_production_consume_line(cr, uid, line, context=context) stock_moves.append(stock_move_id) - else: - self._make_service_procurement(cr, uid, line, context=context) if stock_moves: self.pool.get('stock.move').action_confirm(cr, uid, stock_moves, context=context) production.write({'state': 'confirmed'}) @@ -1356,7 +1310,5 @@ class mrp_production_product_line(osv.osv): 'product_id': fields.many2one('product.product', 'Product', required=True), 'product_qty': fields.float('Product Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True), - 'product_uos_qty': fields.float('Product UOS Quantity'), - 'product_uos': fields.many2one('product.uom', 'Product UOS'), 'production_id': fields.many2one('mrp.production', 'Production Order', select=True), } diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 70a7bc0788a..e6e85b8e96a 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -12,13 +12,11 @@ - normal ASML - HOUR Costing Account For Hours of Assembly. - normal ASML - Cycle Costing Account For Cycle of Assembly. @@ -49,7 +47,6 @@ 0.05 - diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 701ab72fdbe..7df55ded81a 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -204,7 +204,6 @@ - @@ -518,8 +517,6 @@ - - @@ -611,11 +608,6 @@ name="%(mrp.action_change_production_qty)d" string="Update" states="confirmed" class="oe_edit_only oe_link"/> -