[IMP] sale,purchase,invoice: make `Send by mail` action more robust to template/view deletion
bzr revid: odo@openerp.com-20121023115628-3wvxcrkgazhi9p75
This commit is contained in:
parent
67d4646d09
commit
6fadb45325
|
@ -390,28 +390,32 @@ class account_invoice(osv.osv):
|
||||||
'''
|
'''
|
||||||
This function opens a window to compose an email, with the edi invoice template message loaded by default
|
This function opens a window to compose an email, with the edi invoice template message loaded by default
|
||||||
'''
|
'''
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
|
||||||
template = mod_obj.get_object_reference(cr, uid, 'account', 'email_template_edi_invoice')
|
ir_model_data = self.pool.get('ir.model.data')
|
||||||
template_id = template and template[1] or False
|
try:
|
||||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
template_id = ir_model_data.get_object_reference(cr, uid, 'account', 'email_template_edi_invoice')[1]
|
||||||
res_id = res and res[1] or False
|
except ValueError:
|
||||||
|
template_id = False
|
||||||
|
try:
|
||||||
|
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
|
||||||
|
except ValueError:
|
||||||
|
compose_form_id = False
|
||||||
ctx = dict(context)
|
ctx = dict(context)
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'default_model': 'account.invoice',
|
'default_model': 'account.invoice',
|
||||||
'default_res_id': ids[0],
|
'default_res_id': ids[0],
|
||||||
'default_use_template': True,
|
'default_use_template': bool(template_id),
|
||||||
'default_template_id': template_id,
|
'default_template_id': template_id,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_model': 'mail.compose.message',
|
'res_model': 'mail.compose.message',
|
||||||
'views': [(res_id, 'form')],
|
'views': [(compose_form_id, 'form')],
|
||||||
'view_id': res_id,
|
'view_id': compose_form_id,
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': ctx,
|
'context': ctx,
|
||||||
'nodestroy': True,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def confirm_paid(self, cr, uid, ids, context=None):
|
def confirm_paid(self, cr, uid, ids, context=None):
|
||||||
|
|
|
@ -148,7 +148,6 @@ class account_invoice(osv.osv, EDIMixin):
|
||||||
edi_document['partner_id'] = partner_edi_m2o
|
edi_document['partner_id'] = partner_edi_m2o
|
||||||
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
|
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
|
||||||
|
|
||||||
|
|
||||||
return partner_id
|
return partner_id
|
||||||
|
|
||||||
def edi_import(self, cr, uid, edi_document, context=None):
|
def edi_import(self, cr, uid, edi_document, context=None):
|
||||||
|
|
|
@ -349,28 +349,31 @@ class purchase_order(osv.osv):
|
||||||
'''
|
'''
|
||||||
This function opens a window to compose an email, with the edi purchase template message loaded by default
|
This function opens a window to compose an email, with the edi purchase template message loaded by default
|
||||||
'''
|
'''
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
ir_model_data = self.pool.get('ir.model.data')
|
||||||
template = mod_obj.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase')
|
try:
|
||||||
template_id = template and template[1] or False
|
template_id = ir_model_data.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase')[1]
|
||||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
except ValueError:
|
||||||
res_id = res and res[1] or False
|
template_id = False
|
||||||
|
try:
|
||||||
|
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
|
||||||
|
except ValueError:
|
||||||
|
compose_form_id = False
|
||||||
ctx = dict(context)
|
ctx = dict(context)
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'default_model': 'purchase.order',
|
'default_model': 'purchase.order',
|
||||||
'default_res_id': ids[0],
|
'default_res_id': ids[0],
|
||||||
'default_use_template': True,
|
'default_use_template': bool(template_id),
|
||||||
'default_template_id': template_id,
|
'default_template_id': template_id,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_model': 'mail.compose.message',
|
'res_model': 'mail.compose.message',
|
||||||
'views': [(res_id, 'form')],
|
'views': [(compose_form_id, 'form')],
|
||||||
'view_id': res_id,
|
'view_id': compose_form_id,
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': ctx,
|
'context': ctx,
|
||||||
'nodestroy': True,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#TODO: implement messages system
|
#TODO: implement messages system
|
||||||
|
|
|
@ -618,29 +618,32 @@ class sale_order(osv.osv):
|
||||||
This function opens a window to compose an email, with the edi sale template message loaded by default
|
This function opens a window to compose an email, with the edi sale template message loaded by default
|
||||||
'''
|
'''
|
||||||
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.'
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
ir_model_data = self.pool.get('ir.model.data')
|
||||||
template = mod_obj.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')
|
try:
|
||||||
template_id = template and template[1] or False
|
template_id = ir_model_data.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]
|
||||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
except ValueError:
|
||||||
res_id = res and res[1] or False
|
template_id = False
|
||||||
|
try:
|
||||||
|
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
|
||||||
|
except ValueError:
|
||||||
|
compose_form_id = False
|
||||||
ctx = dict(context)
|
ctx = dict(context)
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'default_model': 'sale.order',
|
'default_model': 'sale.order',
|
||||||
'default_res_id': ids[0],
|
'default_res_id': ids[0],
|
||||||
'default_use_template': True,
|
'default_use_template': bool(template_id),
|
||||||
'default_template_id': template_id,
|
'default_template_id': template_id,
|
||||||
'mark_so_as_sent': True
|
'mark_so_as_sent': True
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_model': 'mail.compose.message',
|
'res_model': 'mail.compose.message',
|
||||||
'views': [(res_id, 'form')],
|
'views': [(compose_form_id, 'form')],
|
||||||
'view_id': res_id,
|
'view_id': compose_form_id,
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': ctx,
|
'context': ctx,
|
||||||
'nodestroy': True,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def action_done(self, cr, uid, ids, context=None):
|
def action_done(self, cr, uid, ids, context=None):
|
||||||
|
|
Loading…
Reference in New Issue