bzr revid: fp@tinyerp.com-20081126104239-xwn3mu291wryiyzo
This commit is contained in:
Fabien Pinckaers 2008-11-26 11:42:39 +01:00
parent 611055e4e1
commit 410b7dc970
3 changed files with 48 additions and 18 deletions

View File

@ -361,6 +361,24 @@ class mrp_production(osv.osv):
res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
return res
def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}):
result = {}
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = {
'hour_total': 0.0,
'cycle_total': 0.0,
}
for wc in prod.workcenter_lines:
result[prod.id]['hour_total'] += wc.hour
result[prod.id]['cycle_total'] += wc.cycle
return result
def _production_date(self, cr, uid, ids, prop, unknow_none, context={}):
result = {}
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = prod.date_planned[:10]
return result
def _sale_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
return self._get_sale_order(cr,uid,ids,field_name='name')
@ -383,11 +401,13 @@ class mrp_production(osv.osv):
'location_dest_id': fields.many2one('stock.location', 'Finnished Products Location', required=True,
help="Location where the system will stock the finnished products."),
'date_planned_date': fields.function(_production_date, method=True, type='date', string='Planned Date'),
'date_planned': fields.datetime('Scheduled date', required=True, select=1),
'date_start': fields.datetime('Start Date'),
'date_finnished': fields.datetime('End Date'),
'bom_id': fields.many2one('mrp.bom', 'Bill of Material', domain=[('bom_id','=',False)]),
'routing_id': fields.many2one('mrp.routing', string='Routing', on_delete='set null'),
'picking_id': fields.many2one('stock.picking', 'Packing list', readonly=True,
help="This is the internal picking list take bring the raw materials to the production plan."),
@ -399,6 +419,9 @@ class mrp_production(osv.osv):
'workcenter_lines': fields.one2many('mrp.production.workcenter.line', 'production_id', 'Workcenters Utilisation'),
'state': fields.selection([('draft','Draft'),('picking_except', 'Packing Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Canceled'),('done','Done')],'Status', readonly=True),
'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'),
'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'),
'sale_name': fields.function(_sale_name_calc, method=True, type='char', string='Sale Name'),
'sale_ref': fields.function(_sale_ref_calc, method=True, type='char', string='Sale Ref'),
}
@ -449,8 +472,9 @@ class mrp_production(osv.osv):
if not bom_point:
bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties)
if bom_id:
self.write(cr, uid, [production.id], {'bom_id': bom_id})
bom_point = self.pool.get('mrp.bom').browse(cr, uid, [bom_id])[0]
bom_point = self.pool.get('mrp.bom').browse(cr, uid, bom_id)
routing_id = bom_point.routing_id.id or False
self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
if not bom_id:
raise osv.except_osv('Error', "Couldn't find bill of material for product")

View File

@ -377,9 +377,11 @@
<tree colors="red:date_planned&lt;current_date and state not in ('done','cancel')" string="Production orders">
<field name="name"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_qty" sum="Total Qty"/>
<field name="date_planned"/>
<field name="date_finnished"/>
<field name="routing_id" groups="base.group_extended"/>
<field name="hour_total" sum="Total Hours" groups="base.group_extended"/>
<field name="cycle_total" sum="Total Cycles" groups="base.group_extended"/>
<field name="origin"/>
<field name="state"/>
</tree>
@ -392,9 +394,10 @@
<field name="type">calendar</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="product_id" date_start="date_planned" string="Production Orders">
<calendar color="routing_id" date_start="date_planned" string="Production Orders">
<field name="origin"/>
<field name="name"/>
<field name="product_id"/>
<field name="product_qty"/>
</calendar>
</field>
</record>
@ -405,18 +408,19 @@
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Production orders" type="bar">
<field name="product_id"/>
<field name="product_qty" operator="+"/>
<field name="date_planned_date"/>
<field name="hour_total" operator="+"/>
<field name="cycle_total" operator="+"/>
</graph>
</field>
</record>
<wizard
string="Change Product Qty."
model="mrp.production"
name="change_production_qty"
id="mrp.wizard_change_production_qty"
keyword="client_action_multi"
multi="True"/>
<wizard
string="Change Product Qty."
model="mrp.production"
name="change_production_qty"
id="mrp.wizard_change_production_qty"
keyword="client_action_multi"
multi="True"/>
<record id="mrp_production_form_view" model="ir.ui.view">
<field name="name">mrp.production.form</field>
<field name="model">mrp.production</field>
@ -426,7 +430,7 @@
<group colspan="4" col="7">
<field name="name" select="1"/>
<field name="date_planned" select="1"/>
<field name="priority" groups="base.group_extended"/>
<field name="origin" select="1"/>
<newline/>
<field name="product_id" on_change="product_id_change(product_id)" select="1"/>
<field name="product_qty"/>
@ -443,7 +447,7 @@
<field name="location_src_id" select="2" domain="[('usage','=','internal')]" on_change="location_id_change(location_src_id,location_dest_id)"/>
<field name="location_dest_id" domain="[('usage','=','internal')]"/>
<field name="bom_id" select="2" domain="[('product_id','=',product_id),('bom_id','=',False)]"/>
<field name="origin" select="1"/>
<field name="routing_id" groups="base.group_extended" select="1"/>
<newline/>
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list"/>
<group col="9" colspan="4">
@ -467,6 +471,8 @@
<field colspan="4" name="workcenter_lines" nolabel="1" widget="one2many_list"/>
</page>
<page string="Extra Information">
<field name="priority" groups="base.group_extended"/>
<newline/>
<field name="date_start" select="2"/>
<field name="date_finnished"/>
<field name="picking_id"/>

View File

@ -492,7 +492,7 @@
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Calendar View" date_start="min_date" date_stop="max_date" color="address_id">
<field name="name"/>
<field name="origin"/>
<field name="type"/>
<field name="address_id"/>
</calendar>