diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 351e5fc8d2d..80574cf4a4d 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -53,11 +53,23 @@ class mrp_workcenter(osv.osv): 'costs_journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal'), 'costs_general_account_id': fields.many2one('account.account', 'General Account', domain=[('type','<>','view')]), 'resource_id': fields.many2one('resource.resource','Resource', ondelete='cascade', required=True), + 'product_id': fields.many2one('product.product','Workcenter Product', help="Fill this product to track easily your production costs in the analytic accounting."), } _defaults = { 'capacity_per_cycle': 1.0, 'resource_type': 'material', } + + def on_change_product_cost(self, cr, uid, ids, product_id, context=None): + if context is None: + context = {} + value = {} + + if product_id: + cost = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + value = {'costs_hour' :cost.standard_price} + return {'value': value} + mrp_workcenter() @@ -99,8 +111,8 @@ class mrp_routing_workcenter(osv.osv): 'name': fields.char('Name', size=64, required=True), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of routing workcenters."), 'cycle_nbr': fields.float('Number of Cycles', required=True, - help="Number of operations this workcenter can do."), - 'hour_nbr': fields.float('Number of Hours', required=True, help="Time in hours for doing one cycle."), + help="Number of iterations this workcenter has to do in the specified operation of the routing."), + 'hour_nbr': fields.float('Number of Hours', required=True, help="Time in hours for this workcenter to achieve the operation of the specified routing."), 'routing_id': fields.many2one('mrp.routing', 'Parent Routing', select=True, ondelete='cascade', help="Routing indicates all the workcenters used, for how long and/or cycles." \ "If Routing is indicated then,the third tab of a production order (workcenters) will be automatically pre-completed."), @@ -746,7 +758,10 @@ class mrp_production(osv.osv): 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, - 'code': wc.code + 'ref': wc.code, + 'product_id': wc.product_id.id, + 'unit_amount': wc_line.hour, + 'product_uom_id': wc.product_id.uom_id.id } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle @@ -759,7 +774,10 @@ class mrp_production(osv.osv): 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, - 'code': wc.code, + 'ref': wc.code, + 'product_id': wc.product_id.id, + 'unit_amount': wc_line.cycle, + 'product_uom_id': wc.product_id.uom_id.id } ) return amount diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 1eb8570ca29..33be81d0a10 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -162,12 +162,13 @@ + - - + + @@ -650,9 +651,9 @@ -