[IMP] Change test_state according to procurement_ids, do not allow running a procurement twice when it was successful and adapt view in sale_journal
bzr revid: jco@openerp.com-20130816102734-j4xrxqbz26q942ps
This commit is contained in:
parent
2642c4a379
commit
349833452a
|
@ -27,6 +27,7 @@ class procurement_order(osv.osv):
|
|||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
procurement_id = super(procurement_order, self).create(cr, uid, vals, context=context)
|
||||
# TODO: maybe this is not necessary anymore as we do this already
|
||||
self.run(cr, uid, [procurement_id], context=context)
|
||||
self.check(cr, uid, [procurement_id], context=context)
|
||||
return procurement_id
|
||||
|
|
|
@ -154,13 +154,14 @@ class procurement_order(osv.osv):
|
|||
|
||||
def run(self, cr, uid, ids, context=None):
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
if self._assign(cr, uid, procurement, context=context):
|
||||
procurement.refresh()
|
||||
self._run(cr, uid, procurement, context=context or {})
|
||||
self.write(cr, uid, [procurement.id], {'state': 'running'}, context=context)
|
||||
else:
|
||||
self.message_post(cr, uid, [procurement.id], body=_('No rule matching this procurement'), context=context)
|
||||
self.write(cr, uid, [procurement.id], {'state': 'exception'}, context=context)
|
||||
if procurement.state not in ("running", "done"):
|
||||
if self._assign(cr, uid, procurement, context=context):
|
||||
procurement.refresh()
|
||||
self._run(cr, uid, procurement, context=context or {})
|
||||
self.write(cr, uid, [procurement.id], {'state': 'running'}, context=context)
|
||||
else:
|
||||
self.message_post(cr, uid, [procurement.id], body=_('No rule matching this procurement'), context=context)
|
||||
self.write(cr, uid, [procurement.id], {'state': 'exception'}, context=context)
|
||||
return True
|
||||
|
||||
def check(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group/filter[@string='Journal']" position="after">
|
||||
<xpath expr="//group/filter[@string='Picking Type']" position="after">
|
||||
<filter string="Invoice Type" domain="[]" context="{'group_by':'invoice_type_id'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
|
|
@ -205,16 +205,20 @@ class sale_order(osv.osv):
|
|||
write_done_ids = []
|
||||
write_cancel_ids = []
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
#TODO: Need to rethink what happens when cancelling
|
||||
for line in order.order_line:
|
||||
for procurement in line.procurement_ids:
|
||||
if procurement.state == 'done':
|
||||
write_done_ids.append(line.id)
|
||||
else:
|
||||
finished = False
|
||||
if (procurement.state == 'cancel'):
|
||||
canceled = True
|
||||
if line.state != 'exception':
|
||||
states = [x.state for x in line.procurement_ids]
|
||||
cancel = all([x == 'cancel' for x in states])
|
||||
doneorcancel = all([x in ('done', 'cancel') for x in states])
|
||||
if cancel:
|
||||
canceled = True
|
||||
if line.state != 'exception':
|
||||
write_cancel_ids.append(line.id)
|
||||
if not doneorcancel:
|
||||
finished = False
|
||||
if doneorcancel and not cancel:
|
||||
write_done_ids.append(line.id)
|
||||
|
||||
if write_done_ids:
|
||||
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
|
||||
if write_cancel_ids:
|
||||
|
@ -256,8 +260,7 @@ class sale_order(osv.osv):
|
|||
res = []
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
for line in order.order_line:
|
||||
if line.procurement_id:
|
||||
res.append(line.procurement_id.id)
|
||||
res += [x.id for x in line.procurement_ids]
|
||||
return res
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
|
|
Loading…
Reference in New Issue