[IMP] sale: use the new signal_xxx methods instead of trg_validate.
bzr revid: cha@tinyerp.com-20130131044608-h5dj2xfqyo8ewm6k
This commit is contained in:
parent
02a2c8574d
commit
19368fb65c
|
@ -418,8 +418,7 @@ class sale_order(osv.osv):
|
||||||
This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow
|
This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow
|
||||||
'''
|
'''
|
||||||
assert len(ids) == 1, 'This option should only be used for a single id at a time'
|
assert len(ids) == 1, 'This option should only be used for a single id at a time'
|
||||||
wf_service = netsvc.LocalService("workflow")
|
self.signal_quotation_sent(cr, uid, [ids[0]])
|
||||||
wf_service.trg_validate(uid, 'sale.order', ids[0], 'quotation_sent', cr)
|
|
||||||
datas = {
|
datas = {
|
||||||
'model': 'sale.order',
|
'model': 'sale.order',
|
||||||
'ids': ids,
|
'ids': ids,
|
||||||
|
@ -432,12 +431,10 @@ class sale_order(osv.osv):
|
||||||
view of one of the newly created invoices
|
view of one of the newly created invoices
|
||||||
"""
|
"""
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
mod_obj = self.pool.get('ir.model.data')
|
||||||
wf_service = netsvc.LocalService("workflow")
|
|
||||||
|
|
||||||
# create invoices through the sales orders' workflow
|
# create invoices through the sales orders' workflow
|
||||||
inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
|
inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
|
||||||
for id in ids:
|
self.signal_manual_invoice(cr, uid, ids)
|
||||||
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
|
|
||||||
inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
|
inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
|
||||||
# determine newly created invoices
|
# determine newly created invoices
|
||||||
new_inv_ids = list(inv_ids1 - inv_ids0)
|
new_inv_ids = list(inv_ids1 - inv_ids0)
|
||||||
|
@ -555,7 +552,6 @@ class sale_order(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_cancel(self, cr, uid, ids, context=None):
|
def action_cancel(self, cr, uid, ids, context=None):
|
||||||
wf_service = netsvc.LocalService("workflow")
|
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
sale_order_line_obj = self.pool.get('sale.order.line')
|
sale_order_line_obj = self.pool.get('sale.order.line')
|
||||||
|
@ -566,8 +562,7 @@ class sale_order(osv.osv):
|
||||||
_('Cannot cancel this sales order!'),
|
_('Cannot cancel this sales order!'),
|
||||||
_('First cancel all invoices attached to this sales order.'))
|
_('First cancel all invoices attached to this sales order.'))
|
||||||
for r in self.read(cr, uid, ids, ['invoice_ids']):
|
for r in self.read(cr, uid, ids, ['invoice_ids']):
|
||||||
for inv in r['invoice_ids']:
|
self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, r['invoice_ids'])
|
||||||
wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr)
|
|
||||||
sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
|
sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
|
||||||
{'state': 'cancel'})
|
{'state': 'cancel'})
|
||||||
self.write(cr, uid, ids, {'state': 'cancel'})
|
self.write(cr, uid, ids, {'state': 'cancel'})
|
||||||
|
@ -575,8 +570,7 @@ class sale_order(osv.osv):
|
||||||
|
|
||||||
def action_button_confirm(self, cr, uid, ids, context=None):
|
def action_button_confirm(self, cr, uid, ids, context=None):
|
||||||
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
|
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
|
||||||
wf_service = netsvc.LocalService('workflow')
|
self.signal_order_confirm(cr, uid, ids)
|
||||||
wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)
|
|
||||||
|
|
||||||
# redisplay the record as a sales order
|
# redisplay the record as a sales order
|
||||||
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
|
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
|
||||||
|
@ -992,8 +986,7 @@ class mail_compose_message(osv.Model):
|
||||||
context = context or {}
|
context = context or {}
|
||||||
if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'):
|
if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'):
|
||||||
context = dict(context, mail_post_autofollow=True)
|
context = dict(context, mail_post_autofollow=True)
|
||||||
wf_service = netsvc.LocalService("workflow")
|
self.pool.get('sale.order').signal_quotation_sent(cr, uid, context['default_res_id'])
|
||||||
wf_service.trg_validate(uid, 'sale.order', context['default_res_id'], 'quotation_sent', cr)
|
|
||||||
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
|
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -80,7 +80,6 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
||||||
|
|
||||||
sales_order_line_obj = self.pool.get('sale.order.line')
|
sales_order_line_obj = self.pool.get('sale.order.line')
|
||||||
sales_order_obj = self.pool.get('sale.order')
|
sales_order_obj = self.pool.get('sale.order')
|
||||||
wf_service = netsvc.LocalService('workflow')
|
|
||||||
for line in sales_order_line_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
for line in sales_order_line_obj.browse(cr, uid, context.get('active_ids', []), context=context):
|
||||||
if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
|
if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
|
||||||
if not line.order_id.id in invoices:
|
if not line.order_id.id in invoices:
|
||||||
|
@ -103,7 +102,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
||||||
flag = False
|
flag = False
|
||||||
break
|
break
|
||||||
if flag:
|
if flag:
|
||||||
wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'manual_invoice', cr)
|
sales_order_obj.signal_manual_invoice(cr, uid, line.order_id.id)
|
||||||
sales_order_obj.write(cr, uid, [line.order_id.id], {'state': 'progress'})
|
sales_order_obj.write(cr, uid, [line.order_id.id], {'state': 'progress'})
|
||||||
|
|
||||||
if not invoices:
|
if not invoices:
|
||||||
|
|
|
@ -52,10 +52,8 @@ class sale_make_invoice(osv.osv_memory):
|
||||||
context = {}
|
context = {}
|
||||||
data = self.read(cr, uid, ids)[0]
|
data = self.read(cr, uid, ids)[0]
|
||||||
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_inv = data['invoice_date'])
|
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_inv = data['invoice_date'])
|
||||||
wf_service = netsvc.LocalService("workflow")
|
order_obj.signal_manual_invoice(cr, uid, context.get(('active_ids'), []))
|
||||||
for id in context.get(('active_ids'), []):
|
|
||||||
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
|
|
||||||
|
|
||||||
for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context):
|
for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context):
|
||||||
for i in o.invoice_ids:
|
for i in o.invoice_ids:
|
||||||
newinv.append(i.id)
|
newinv.append(i.id)
|
||||||
|
|
Loading…
Reference in New Issue