[MERGE] from trunk

bzr revid: chm@openerp.com-20121011071602-u23xansbga1i41vs
This commit is contained in:
Christophe Matthieu
2012-10-11 09:16:02 +02:00
6 changed files with 37 additions and 21 deletions
+1
View File
@@ -952,6 +952,7 @@
<data>
<xpath expr="//field[@name='move_id']" position="before">
<field name="bom_id" domain="[('product_id','=',product_id),('bom_id','=',False)]"/>
<field name="production_id" attrs="{'invisible': [('production_id','=',False)]}"/>
</xpath>
<xpath expr="//field[@name='close_move']" position="after">
<group colspan="4" groups="product.group_mrp_properties">
+11 -2
View File
@@ -31,6 +31,7 @@ class procurement_order(osv.osv):
_columns = {
'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True),
'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'),
'production_id': fields.many2one('mrp.production', 'Manufacturing Order'),
}
def check_produce_product(self, cr, uid, procurement, context=None):
@@ -79,8 +80,10 @@ class procurement_order(osv.osv):
procurement_obj = self.pool.get('procurement.order')
for procurement in procurement_obj.browse(cr, uid, ids, context=context):
res_id = procurement.move_id.id
#TOFIX: split into new function to compute manufacturing lead time
newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
newdate = newdate - relativedelta(days=company.manufacturing_lead)
#TOFIX: implement hook method for creating production order
produce_id = production_obj.create(cr, uid, {
'origin': procurement.origin,
'product_id': procurement.product_id.id,
@@ -95,16 +98,22 @@ class procurement_order(osv.osv):
'move_prod_id': res_id,
'company_id': procurement.company_id.id,
})
res[procurement.id] = produce_id
self.write(cr, uid, [procurement.id], {'state': 'running'})
self.running_send_note(cr, uid, ids, context=context)
self.write(cr, uid, [procurement.id], {'state': 'running', 'production_id': produce_id})
bom_result = production_obj.action_compute(cr, uid,
[produce_id], properties=[x.id for x in procurement.property_ids])
wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
if res_id:
move_obj.write(cr, uid, [res_id],
{'location_id': procurement.location_id.id})
self.production_order_create_note(cr, uid, ids, context=context)
return res
def production_order_create_note(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids, context=context):
body = "Manufacturing Order <em>%s</em> created." % ( procurement.production_id.name,)
self.message_post(cr, uid, [procurement.id], body=body, context=context)
procurement_order()
+1 -12
View File
@@ -362,11 +362,10 @@ class procurement_order(osv.osv):
""" Changes procurement state to Running and writes message.
@return: True
"""
message = _('From stock: products assigned.')
message = _('Products reserved from stock.')
self.write(cr, uid, ids, {'state': 'running',
'message': message}, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
self.running_send_note(cr, uid, ids, context=context)
return True
def _check_make_to_stock_service(self, cr, uid, procurement, context=None):
@@ -390,8 +389,6 @@ class procurement_order(osv.osv):
order_point_id = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id', '=', procurement.product_id.id)], context=context)
if not order_point_id and not ok:
message = _("Not enough stock and no minimum orderpoint rule defined.")
elif not order_point_id:
message = _("No minimum orderpoint rule defined.")
elif not ok:
message = _("Not enough stock.")
@@ -407,7 +404,6 @@ class procurement_order(osv.osv):
"""
for procurement in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, [procurement.id], {'state': 'running'})
self.running_send_note(cr, uid, ids, context=None)
return True
def action_produce_assign_product(self, cr, uid, ids, context=None):
@@ -469,7 +465,6 @@ class procurement_order(osv.osv):
@return: True
"""
res = self.write(cr, uid, ids, {'state': 'ready'})
self.ready_send_note(cr, uid, ids, context=None)
return res
def action_done(self, cr, uid, ids):
@@ -503,12 +498,6 @@ class procurement_order(osv.osv):
def confirm_send_note(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("Procurement <b>confirmed</b>."), context=context)
def running_send_note(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("Procurement set to <b>running</b>."), context=context)
def ready_send_note(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("Procurement set to <b>ready</b>."), context=context)
def cancel_send_note(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("Procurement <b>cancelled</b>."), context=context)
+11 -3
View File
@@ -20,6 +20,7 @@
##############################################################################
from osv import fields, osv
from tools.translate import _
class procurement_order(osv.osv):
_name = "procurement.order"
@@ -68,8 +69,10 @@ class procurement_order(osv.osv):
def action_produce_assign_service(self, cr, uid, ids, context=None):
project_task = self.pool.get('project.task')
for procurement in self.browse(cr, uid, ids, context=context):
#TOFIX: split into new function to compute task planning hours
project = self._get_project(cr, uid, procurement, context=context)
planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context)
#TOFIX: implement hook method for creating Task
task_id = project_task.create(cr, uid, {
'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name),
'date_deadline': procurement.date_planned,
@@ -82,11 +85,16 @@ class procurement_order(osv.osv):
'description': procurement.note,
'project_id': project and project.id or False,
'company_id': procurement.company_id.id,
},context=context)
self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':'from project: task created.'}, context=context)
self.running_send_note(cr, uid, ids, context=None)
},context=context)
self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':'from project: task created.'}, context=context)
self.project_task_create_note(cr, uid, ids, context=context)
return task_id
def project_task_create_note(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids, context=context):
body = _("Task <em>%s</em> created") % (procurement.task_id.name,)
self.message_post(cr, uid, [procurement.id], body=body, context=context)
procurement_order()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+6 -1
View File
@@ -1084,9 +1084,14 @@ class procurement_order(osv.osv):
}
res[procurement.id] = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context=new_context)
self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': res[procurement.id]})
self.running_send_note(cr, uid, [procurement.id], context=context)
self.purchase_order_create_note(cr, uid, ids, context=context)
return res
def purchase_order_create_note(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids, context=context):
body = "Draft Purchase Order <em>%s</em> created" % (procurement.purchase_id.name,)
self.message_post(cr, uid, [procurement.id], body=body, context=context)
procurement_order()
class mail_mail(osv.osv):
+7 -3
View File
@@ -57,6 +57,7 @@ class procurement_order(osv.osv):
break
assert line, 'Line cannot be False if we are on this state of the workflow'
origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name
#TOFIX: implement hook method for creating picking
picking_id = picking_obj.create(cr, uid, {
'origin': origin,
'company_id': line.company_id and line.company_id.id or False,
@@ -67,6 +68,7 @@ class procurement_order(osv.osv):
'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id),
'invoice_state': line.invoice_state,
})
#TOFIX: implement hook method for creating move
move_id = move_obj.create(cr, uid, {
'name': line.name,
'picking_id': picking_id,
@@ -92,6 +94,8 @@ class procurement_order(osv.osv):
move_obj.write(cr,uid, [proc.move_id.id], {
'state':'waiting'
}, context=context)
#TOFIX: implement hook method for creating new procurement
proc_id = proc_obj.create(cr, uid, {
'name': line.name,
'origin': origin,
@@ -115,9 +119,9 @@ class procurement_order(osv.osv):
if proc.move_id:
move_obj.write(cr, uid, [proc.move_id.id],
{'location_id':proc.location_id.id})
self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d') % proc_id})
self.running_send_note(cr, uid, [proc.id], context=context)
msg = _('Pulled from another location.')
self.write(cr, uid, [proc.id], {'state':'running', 'message': msg})
self.message_post(cr, uid, [proc.id], body=msg, context=context)
# trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed)
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr)
return False