[FIX+IMP] mrp_operations_extension

FIX: correct actions view reference on produce button
IMP: Changes in the calculation of number of cycles + hours
IMP: Group analytic lines
IMP: Remove product check
FIX: Wizard when produced from work order
IMP: Change product cost computation
This commit is contained in:
avanzosc1
2015-01-22 16:50:49 +01:00
committed by Pedro M. Baeza
parent 23c6cbf99e
commit fbdbde9806
5 changed files with 25 additions and 6 deletions

View File

@@ -31,11 +31,13 @@ class MrpBom(models.Model):
bom, product, factor, properties=properties, level=level,
routing_id=routing_id, previous_products=previous_products,
master_bom=master_bom)
result2 = self._get_workorder_operations(result2, level=level,
result2 = self._get_workorder_operations(result2, factor=factor,
level=level,
routing_id=routing_id)
return result, result2
def _get_workorder_operations(self, result2, level=0, routing_id=False):
def _get_workorder_operations(self, result2, factor, level=0,
routing_id=False):
routing_line_obj = self.env['mrp.routing.workcenter']
for work_order in result2:
seq = work_order['sequence'] - level
@@ -50,9 +52,18 @@ class MrpBom(models.Model):
if name_val in work_order['name']:
routing_line_id = routing_line.id
break
wc = routing_line_obj.browse(routing_line_id)
cycle = factor / wc.cycle_nbr
if wc.limited_production_capacity and not cycle.is_integer():
cycle = int(cycle) + 1
hour = wc.hour_nbr * cycle
default_wc_line = wc.op_wc_lines.filtered(lambda r: r.default)
work_order['cycle'] = cycle
work_order['hour'] = hour
work_order['time_start'] = default_wc_line.time_start or 0.0
work_order['time_stop'] = default_wc_line.time_stop or 0.0
if 'routing_wc_line' not in work_order:
work_order['routing_wc_line'] = routing_line_id
wc = self.env['mrp.routing.workcenter'].browse(routing_line_id)
work_order['do_production'] = wc.do_production
return result2

View File

@@ -85,3 +85,5 @@ class MrpProductionWorkcenterLine(models.Model):
routing_wc_line = fields.Many2one('mrp.routing.workcenter',
string='Routing WC Line')
do_production = fields.Boolean(string='Produce here')
time_start = fields.Float(string="Time Start")
time_stop = fields.Float(string="Time Stop")

View File

@@ -47,6 +47,10 @@
<xpath expr="//field[@name='workcenter_lines']/tree//field[@name='sequence']" position="after">
<field name="do_production" colspan="2" />
</xpath>
<xpath expr="//field[@name='workcenter_lines']/tree//field[@name='hour']" position="after">
<field name="time_start" widget="float_time" />
<field name="time_stop" widget="float_time" />
</xpath>
<xpath expr="//field[@name='workcenter_lines']/form//field[@name='name']" position="attributes">
<attribute name="colspan">2</attribute>
</xpath>

View File

@@ -52,7 +52,8 @@ class MrpWorkOrderProduce(models.TransientModel):
assert production_id
data = self.browse(cr, uid, ids[0], context=context)
self.pool['mrp.production'].action_produce(
cr, uid, production_id, False, data.mode, data, context=context)
cr, uid, production_id, data.product_qty,
data.mode, data, context=context)
return {}
def do_consume(self, cr, uid, ids, context=None):
@@ -72,7 +73,7 @@ class MrpWorkOrderProduce(models.TransientModel):
assert production_id
data = self.browse(cr, uid, ids[0], context=context)
self.pool['mrp.production'].action_produce(
cr, uid, production_id, False, 'consume_produce', data,
cr, uid, production_id, data.product_qty, 'consume_produce', data,
context=context)
return {}

View File

@@ -45,7 +45,7 @@
<!-- Consume -->
<record id="view_mrp_product_consume_wizard" model="ir.ui.view">
<field name="name">MRP Work Order Produce</field>
<field name="name">MRP Work Order Consume</field>
<field name="model">mrp.work.order.produce</field>
<field name="arch" type="xml">
<form string="Produce">
@@ -89,6 +89,7 @@
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_mrp_product_produce_wizard"/>
</record>
<record id="act_mrp_work_order_consume" model="ir.actions.act_window">