[MERGE] lp:802322
bzr revid: qdp-launchpad@openerp.com-20111018084234-ele9nnaowd83nrsv
This commit is contained in:
commit
00c0894d91
|
@ -375,11 +375,10 @@ class procurement_order(osv.osv):
|
|||
id = procurement.move_id.id
|
||||
if not (procurement.move_id.state in ('done','assigned','cancel')):
|
||||
ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
|
||||
cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
|
||||
res = cr.fetchone()[0]
|
||||
if not res and not ok:
|
||||
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 res:
|
||||
elif not order_point_id:
|
||||
message = _("No minimum orderpoint rule defined.")
|
||||
elif not ok:
|
||||
message = _("Not enough stock.")
|
||||
|
|
|
@ -67,8 +67,7 @@ class procurement_order(osv.osv):
|
|||
report_except = 0
|
||||
report_later = 0
|
||||
while True:
|
||||
cr.execute("select id from procurement_order where state='confirmed' and procure_method='make_to_order' order by priority,date_planned limit 500 offset %s", (offset,))
|
||||
ids = map(lambda x: x[0], cr.fetchall())
|
||||
ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_order')], offset=offset, limit=500, order='priority, date_planned', context=context)
|
||||
for proc in procurement_obj.browse(cr, uid, ids, context=context):
|
||||
if maxdate >= proc.date_planned:
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr)
|
||||
|
@ -156,11 +155,7 @@ class procurement_order(osv.osv):
|
|||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
warehouse_ids = warehouse_obj.search(cr, uid, [], context=context)
|
||||
|
||||
cr.execute('select p.id from product_product p \
|
||||
join product_template t on (p.product_tmpl_id=t.id) \
|
||||
where p.active=True and t.purchase_ok=True')
|
||||
products_id = [x for x, in cr.fetchall()]
|
||||
products_id = product_obj.search(cr, uid, [('purchase_ok', '=', True)], order='id', context=context)
|
||||
|
||||
for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context):
|
||||
context['warehouse'] = warehouse
|
||||
|
@ -183,6 +178,7 @@ class procurement_order(osv.osv):
|
|||
'product_qty': -product.virtual_available,
|
||||
'product_uom': product.uom_id.id,
|
||||
'location_id': location_id,
|
||||
'company_id': warehouse.company_id.id,
|
||||
'procure_method': 'make_to_order',
|
||||
})
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
|
||||
|
@ -241,8 +237,7 @@ class procurement_order(osv.osv):
|
|||
if op.procurement_draft_ids:
|
||||
# Check draft procurement related to this order point
|
||||
pro_ids = [x.id for x in op.procurement_draft_ids]
|
||||
cr.execute('select id, product_qty from procurement_order where id in %s order by product_qty desc', (tuple(pro_ids), ))
|
||||
procure_datas = cr.dictfetchall()
|
||||
procure_datas = procurement_obj.read(cr, uid, pro_ids, ['id','product_qty'], context=context, order='product_qty desc')
|
||||
to_generate = qty
|
||||
for proc_data in procure_datas:
|
||||
if to_generate >= proc_data['product_qty']:
|
||||
|
@ -259,6 +254,7 @@ class procurement_order(osv.osv):
|
|||
'date_planned': newdate.strftime('%Y-%m-%d'),
|
||||
'product_id': op.product_id.id,
|
||||
'product_qty': qty,
|
||||
'company_id': op.company_id.id,
|
||||
'product_uom': op.product_uom.id,
|
||||
'location_id': op.location_id.id,
|
||||
'procure_method': 'make_to_order',
|
||||
|
|
|
@ -803,6 +803,8 @@ class procurement_order(osv.osv):
|
|||
pricelist_obj = self.pool.get('product.pricelist')
|
||||
prod_obj = self.pool.get('product.product')
|
||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
warehouse_obj = self.pool.get('stock.warehouse')
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
res_id = procurement.move_id.id
|
||||
partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
|
||||
|
@ -811,7 +813,7 @@ class procurement_order(osv.osv):
|
|||
partner_id = partner.id
|
||||
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
|
||||
pricelist_id = partner.property_product_pricelist_purchase.id
|
||||
|
||||
warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', procurement.company_id.id or company.id)], context=context)
|
||||
uom_id = procurement.product_id.uom_po_id.id
|
||||
|
||||
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
|
||||
|
@ -842,12 +844,14 @@ class procurement_order(osv.osv):
|
|||
'notes': product.description_purchase,
|
||||
'taxes_id': [(6,0,taxes)],
|
||||
}
|
||||
|
||||
name = seq_obj.get(cr, uid, 'purchase.order') or _('PO: %s') % procurement.name
|
||||
po_vals = {
|
||||
'name': name,
|
||||
'origin': procurement.origin,
|
||||
'partner_id': partner_id,
|
||||
'partner_address_id': address_id,
|
||||
'location_id': procurement.location_id.id,
|
||||
'warehouse_id': warehouse_id and warehouse_id[0] or False,
|
||||
'pricelist_id': pricelist_id,
|
||||
'date_order': order_dates.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'company_id': procurement.company_id.id,
|
||||
|
|
Loading…
Reference in New Issue