[IMP] nan_mrp_without_internal_picking: removed code and workflow transitions redefinition not required and formatting

This commit is contained in:
Guillem Barba 2012-04-30 11:38:55 +02:00
parent d5ebeffe3d
commit 311643b66b
4 changed files with 81 additions and 88 deletions

View File

@ -27,27 +27,27 @@
#
##############################################################################
{
"name" : "MRP Without internal Picking",
"version" : "0.1",
"author" : "NaN Projectes de Programari Lliure S.L.",
"category" : "Generic Modules/Production",
"name": "MRP Without internal Picking",
"version": "0.1",
"author": "NaN Projectes de Programari Lliure S.L.",
"category": "Generic Modules/Production",
"website": "http://www.nan-tic.com",
"description": """
"description": """
""",
"depends" : [
"mrp"
"depends": [
"mrp",
],
"init_xml" : [],
"update_xml" : [
"init_xml": [],
"update_xml": [
"workflow.xml",
"mrp_view.xml",
"mrp_view.xml",
],
"demo_xml" : [],
"demo_xml": [],
"test": [
],
"active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

94
mrp.py
View File

@ -27,19 +27,18 @@
#
##############################################################################
from osv import osv, fields
from osv import osv
import netsvc
from tools.translate import _
from datetime import datetime
class mrp_production(osv.osv):
_inherit = 'mrp.production'
# mrp.production
def action_confirm(self, cr, uid, ids):
proc_ids = []
seq_obj = self.pool.get('ir.sequence')
move_obj = self.pool.get('stock.move')
proc_obj = self.pool.get('procurement.order')
wf_service = netsvc.LocalService("workflow")
@ -47,21 +46,24 @@ class mrp_production(osv.osv):
if not production.product_lines:
self.action_compute(cr, uid, [production.id])
production = self.browse(cr, uid, [production.id])[0]
routing_loc = None
routing_loc = None
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
routing_loc = production.bom_id.routing_id.location_id
routing_loc = routing_loc.id
if (production.bom_id.routing_id and
production.bom_id.routing_id.location_id):
routing_loc = production.bom_id.routing_id.location_id.id
source = production.product_id.product_tmpl_id.property_stock_production.id
source = production.product_id.product_tmpl_id\
.property_stock_production.id
data = {
'name':'PROD:' + production.name,
'name': 'PROD:' + production.name,
'date': production.date_planned,
'product_id': production.product_id.id,
'product_qty': production.product_qty,
'product_uom': production.product_uom.id,
'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,
'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_dest_id': production.location_dest_id.id,
'move_dest_id': production.move_prod_id.id,
@ -70,76 +72,84 @@ class mrp_production(osv.osv):
}
res_final_id = move_obj.create(cr, uid, data)
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 0, [res_final_id])]})
self.write(cr, uid, [production.id], {
'move_created_ids': [(6, 0, [res_final_id])],
})
moves = []
for line in production.product_lines:
move_id = False
newdate = production.date_planned
if line.product_id.type in ('product', 'consu'):
res_dest_id = move_obj.create(cr, uid, {
'name':'PROD:' + production.name,
'name': 'PROD:' + production.name,
'date': production.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 and line.product_uos_qty or False,
'product_uos': line.product_uos and line.product_uos.id or False,
'location_id': routing_loc or production.location_src_id.id,
'product_uos_qty': (line.product_uos and
line.product_uos_qty or False),
'product_uos': (line.product_uos and
line.product_uos.id or False),
'location_id': (routing_loc or
production.location_src_id.id),
'location_dest_id': source,
'move_dest_id': res_final_id,
'state': 'waiting',
'company_id': production.company_id.id,
})
moves.append(res_dest_id)
proc_vals = self._calc_procurement_vals_from_product_line(cr,
proc_vals = self._calc_procurement_vals_from_product_line(cr,
uid, line, res_dest_id)
proc_id = proc_obj.create(cr, uid, proc_vals)
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
wf_service.trg_validate(uid, 'procurement.order', proc_id,
'button_confirm', cr)
proc_ids.append(proc_id)
self.write(cr, uid, [production.id], {'move_lines': [(6,0,moves)], 'state':'confirmed'})
message = _("Manufacturing order '%s' is scheduled for the %s.") % (
production.name,
datetime.strptime(production.date_planned,'%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y'),
)
self.write(cr, uid, [production.id], {
'move_lines': [(6, 0, moves)],
'state': 'confirmed',
})
message = _("Manufacturing order '%s' is scheduled for the %s.") \
% (
production.name,
datetime.strptime(production.date_planned,
'%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y'),
)
self.log(cr, uid, production.id, message)
return True
# mrp.production
def check_availability(self, cr, uid, ids, context=None):
for prod in self.browse(cr, uid, ids ):
for move in prod.move_lines:
for prod in self.browse(cr, uid, ids):
for move in prod.move_lines:
if move.state != 'assigned':
return False
return True
# mrp.production
def check_production(self, cr, uid, ids, context=None):
wf_service = netsvc.LocalService("workflow")
for prod in self.browse(cr, uid, ids ):
for prod in self.browse(cr, uid, ids):
for move in prod.move_lines:
for procurement in move.procurements:
wf_service.trg_validate(uid, 'procurement.order',
procurement.id, 'button_check', cr)
self.check_availability(cr, uid, ids, context)
if self.check_availability(cr, uid, ids, context):
self.action_ready(cr, uid, ids)
return True
# mrp.production
def force_production(self, cr, uid, ids, *args):
""" Assigns products.
@param *args: Arguments
@return: True
"""
move_ids=[]
for prod in self.browse(cr, uid, ids ):
move_ids += [x.id for x in prod.move_lines if x.state in ['confirmed','waiting']]
move_ids = []
for prod in self.browse(cr, uid, ids):
move_ids += [x.id for x in prod.move_lines
if x.state in ('confirmed', 'waiting')]
self.pool.get('stock.move').force_assign(cr, uid, move_ids)
self.action_ready(cr, uid, ids)
self.action_ready(cr, uid, ids)
return True
mrp_production()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>
<record id="mrp_production_form_check_view" model="ir.ui.view">
<field name="name">mrp.production.wo_internal_picking.form</field>
<field name="model">mrp.production</field>
<field name="type">form</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="button_recreate" states="picking_except" string="Recreate Picking" icon="terp-document-new" position="replace">
<button name="check_production" states="confirmed,picking_except" string="Check Availability" type="object" icon="gtk-jump-to"/>
</button>
</field>
</record>
<record id="mrp_production_form_check_view" model="ir.ui.view">
<field name="name">mrp.production.check.form</field>
<field name="model">mrp.production</field>
<field name="type">form</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<button name="button_recreate" states="picking_except" string="Recreate Picking" icon="terp-document-new" position="replace">
<button name="check_production" states="confirmed,picking_except" string="Check Availability" type="object" icon="gtk-jump-to"/>
</button>
</field>
</record>
</data>
</data>
</openerp>

View File

@ -1,34 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp.prod_act_picking" model="workflow.activity">
<data>
<record id="mrp.prod_act_picking" model="workflow.activity">
<field name="wkf_id" ref="mrp.wkf_prod"/>
<field name="name">picking</field>
<field name="kind">function</field>
<field name="action">action_confirm()</field>
</record>
<!-- <record id="mrp.prod_trans_draft_picking" model="workflow.transition">
<field name="act_from" ref="mrp.prod_act_draft"/>
<field name="act_to" ref="mrp.prod_act_ready"/>
<field name="signal">button_confirm</field>
<field name="condition">action_confirm()</field>
</record>
-->
<record id="mrp.prod_trans_draft_picking" model="workflow.transition">
<field name="act_from" ref="mrp.prod_act_draft"/>
<field name="act_to" ref="mrp.prod_act_picking"/>
<field name="signal">button_confirm</field>
<field name="condition">test_if_product()</field>
</record>
<record id="mrp.prod_trans_picking_ready" model="workflow.transition">
<field name="act_from" ref="mrp.prod_act_picking"/>
<field name="act_to" ref="mrp.prod_act_ready"/>
<field name="signal"></field>
<field name="condition">check_availability()</field>
</record>
</data>
</data>
</openerp>