from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
from openerp.tools import float_compare
from openerp.tools.translate import _
-from openerp import netsvc
-from openerp import tools
+from openerp import tools, SUPERUSER_ID
from openerp import SUPERUSER_ID
from openerp.addons.product import _common
value = {'costs_hour': cost.standard_price}
return {'value': value}
-mrp_workcenter()
class mrp_routing(osv.osv):
'active': lambda *a: 1,
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.routing', context=context)
}
-mrp_routing()
class mrp_routing_workcenter(osv.osv):
"""
'cycle_nbr': lambda *a: 1.0,
'hour_nbr': lambda *a: 0.0,
}
-mrp_routing_workcenter()
class mrp_bom(osv.osv):
"""
location_id = False
return location_id
+ def _get_progress(self, cr, uid, ids, name, arg, context=None):
+ """ Return product quantity percentage """
+ result = dict.fromkeys(ids, 100)
+ for mrp_production in self.browse(cr, uid, ids, context=context):
+ if mrp_production.product_qty:
+ done = 0.0
+ for move in mrp_production.move_created_ids2:
+ if not move.scrapped and move.product_id == mrp_production.product_id:
+ done += move.product_qty
+ result[mrp_production.id] = done / mrp_production.product_qty * 100
+ return result
+
_columns = {
'name': fields.char('Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
'origin': fields.char('Source Document', size=64, 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'),
'location_src_id': fields.many2one('stock.location', 'Raw Materials Location', required=True,
readonly=True, states={'draft':[('readonly',False)]},
stock_mov_obj = self.pool.get('stock.move')
production = self.browse(cr, uid, production_id, context=context)
- wf_service = netsvc.LocalService("workflow")
if not production.move_lines and production.state == 'ready':
# trigger workflow if not products to consume (eg: services)
- wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce', cr)
+ self.signal_button_produce(cr, uid, [production_id])
produced_qty = 0
for produced_product in production.move_created_ids2:
new_parent_ids.append(final_product.id)
for new_parent_id in new_parent_ids:
stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]})
-
- wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr)
+ self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
+ self.signal_button_produce_done(cr, uid, [production_id])
return True
def _costs_generate(self, cr, uid, production):
account = wc.costs_hour_account_id.id
if value and account:
amount += value
- analytic_line_obj.create(cr, uid, {
+ # we user SUPERUSER_ID as we do not garantee an mrp user
+ # has access to account analytic lines but still should be
+ # able to produce orders
+ analytic_line_obj.create(cr, SUPERUSER_ID, {
'name': wc_line.name + ' (H)',
'amount': value,
'account_id': account,
account = wc.costs_cycle_account_id.id
if value and account:
amount += value
- analytic_line_obj.create(cr, uid, {
+ analytic_line_obj.create(cr, SUPERUSER_ID, {
'name': wc_line.name+' (C)',
'amount': value,
'account_id': account,
return True
def _make_production_line_procurement(self, cr, uid, production_line, shipment_move_id, context=None):
- wf_service = netsvc.LocalService("workflow")
procurement_order = self.pool.get('procurement.order')
production = production_line.production_id
location_id = production.location_src_id.id
'move_id': shipment_move_id,
'company_id': production.company_id.id,
})
- self._hook_create_post_procurement(cr, uid, production, procurement_id, context=context)
- wf_service.trg_validate(uid, procurement_order._name, procurement_id, 'button_confirm', cr)
+ procurement_order.signal_button_confirm(cr, uid, [procurement_id])
return procurement_id
def _make_production_internal_shipment_line(self, cr, uid, production_line, shipment_id, parent_move_id, destination_location_id=False, context=None):
@return: Newly generated Shipment Id.
"""
shipment_id = False
- wf_service = netsvc.LocalService("workflow")
uncompute_ids = filter(lambda x:x, [not x.product_lines and x.id or False for x in self.browse(cr, uid, ids, context=context)])
self.action_compute(cr, uid, uncompute_ids, context=context)
for production in self.browse(cr, uid, ids, context=context):
self._make_production_line_procurement(cr, uid, line, shipment_move_id, context=context)
if shipment_id:
- wf_service.trg_validate(uid, 'stock.picking', shipment_id, 'button_confirm', cr)
+ self.pool.get('stock.picking').signal_button_confirm(cr, uid, [shipment_id])
production.write({'state':'confirmed'}, context=context)
return shipment_id