[FIX] Purchase: replace SQL by ORM because ORM replace date=False by date is null automatically. Fix #4691
This commit is contained in:
parent
53f4e87627
commit
38f0e59d37
|
@ -58,15 +58,14 @@ class purchase_order(osv.osv):
|
|||
if not value: return False
|
||||
if type(ids)!=type([]):
|
||||
ids=[ids]
|
||||
pol_obj = self.pool.get('purchase.order.line')
|
||||
for po in self.browse(cr, uid, ids, context=context):
|
||||
if po.order_line:
|
||||
cr.execute("""update purchase_order_line set
|
||||
date_planned=%s
|
||||
where
|
||||
order_id=%s and
|
||||
(date_planned=%s or date_planned<%s)""", (value,po.id,po.minimum_planned_date,value))
|
||||
cr.execute("""update purchase_order set
|
||||
minimum_planned_date=%s where id=%s""", (value, po.id))
|
||||
pol_ids = pol_obj.search(cr, uid, [
|
||||
('order_id', '=', po.id), '|', ('date_planned', '=', po.minimum_planned_date), ('date_planned', '<', value)
|
||||
], context=context)
|
||||
pol_obj.write(cr, uid, pol_ids, {'date_planned': value}, context=context)
|
||||
self.pool.get('purchase.order').write(cr, uid, po.id, {'minimum_planned_date': value}, context=context)
|
||||
self.invalidate_cache(cr, uid, context=context)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue