[IMP] account, purchase, sale: Improve code to add a link in mail
bzr revid: psi@tinyerp.com-20120328060443-34pimg3azu50dy4v
This commit is contained in:
parent
cede2bb069
commit
4a274f3dda
|
@ -389,26 +389,22 @@ class account_invoice(osv.osv):
|
|||
}
|
||||
|
||||
def action_invoice_sent(self, cr, uid, ids, context=None):
|
||||
email_template_obj = self.pool.get('email.template')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
|
||||
template_id = email_template_obj.search(cr, uid, [('model_id', '=', 'account.invoice')], context=context)
|
||||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'account.invoice')], context=context)[0]
|
||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
||||
res_id = res and res[1] or False
|
||||
|
||||
ctx = context.copy()
|
||||
ctx.update({'active_model': 'account.invoice', 'active_id': ids[0], 'mail.compose.template_id': template_id})
|
||||
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mail.compose.message',
|
||||
'views': [(res_id, 'form')],
|
||||
'view_id': res_id,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
'nodestroy': True,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mail.compose.message',
|
||||
'views': [(res_id, 'form')],
|
||||
'view_id': res_id,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
'nodestroy': True,
|
||||
}
|
||||
|
||||
def confirm_paid(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -66,12 +66,12 @@ write({'state':'cancel'})</field>
|
|||
<field name="act_to" ref="act_open"/>
|
||||
<field name="signal">invoice_open</field>
|
||||
</record>
|
||||
<record id="t_open_sent" model="workflow.transition">
|
||||
<record id="open_to_sent" model="workflow.transition">
|
||||
<field name="act_from" ref="act_open"/>
|
||||
<field name="act_to" ref="act_sent"/>
|
||||
<field name="signal">invoice_sent</field>
|
||||
</record>
|
||||
<record id="t_open_paid" model="workflow.transition">
|
||||
<record id="open_to_paid" model="workflow.transition">
|
||||
<field name="act_from" ref="act_open"/>
|
||||
<field name="act_to" ref="act_paid"/>
|
||||
<field name="trigger_model">account.move.line</field>
|
||||
|
@ -85,7 +85,7 @@ write({'state':'cancel'})</field>
|
|||
<field name="trigger_expr_id">move_line_id_payment_get()</field>
|
||||
<field name="condition">test_paid()</field>
|
||||
</record>
|
||||
<record id="t_sent_cancel" model="workflow.transition">
|
||||
<record id="sent_to_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_sent"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">invoice_cancel</field>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
from osv import fields, osv, orm
|
||||
from edi import EDIMixin
|
||||
from edi.models import edi
|
||||
|
||||
INVOICE_LINE_EDI_STRUCT = {
|
||||
'name': True,
|
||||
|
@ -71,6 +72,18 @@ INVOICE_EDI_STRUCT = {
|
|||
class account_invoice(osv.osv, EDIMixin):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
def action_invoice_sent(self, cr, uid, ids, context=None):
|
||||
""""Override this method to add a link to mail"""
|
||||
if context is None:
|
||||
context = {}
|
||||
invoice_objs = self.browse(cr, uid, ids, context=context)
|
||||
edi_token = self.pool.get('edi.document').export_edi(cr, uid, invoice_objs, context = context)[0]
|
||||
web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
edi_context = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token))
|
||||
ctx = context.copy()
|
||||
ctx.update(edi_context)
|
||||
return super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=ctx)
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
"""Exports a supplier or customer invoice"""
|
||||
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
|
||||
|
|
|
@ -24,6 +24,7 @@ from dateutil.relativedelta import relativedelta
|
|||
|
||||
from osv import fields, osv, orm
|
||||
from edi import EDIMixin
|
||||
from edi.models import edi
|
||||
from tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from tools.translate import _
|
||||
|
||||
|
@ -61,6 +62,18 @@ PURCHASE_ORDER_EDI_STRUCT = {
|
|||
class purchase_order(osv.osv, EDIMixin):
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
def wkf_send_rfq(self, cr, uid, ids, context=None):
|
||||
""""Override this method to add a link to mail"""
|
||||
if context is None:
|
||||
context = {}
|
||||
purchase_objs = self.browse(cr, uid, ids, context=context)
|
||||
edi_token = self.pool.get('edi.document').export_edi(cr, uid, purchase_objs, context = context)[0]
|
||||
web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
edi_context = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token))
|
||||
ctx = context.copy()
|
||||
ctx.update(edi_context)
|
||||
return super(purchase_order, self).wkf_send_rfq(cr, uid, ids, context=ctx)
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
"""Exports a purchase order"""
|
||||
edi_struct = dict(edi_struct or PURCHASE_ORDER_EDI_STRUCT)
|
||||
|
|
|
@ -330,18 +330,13 @@ class purchase_order(osv.osv):
|
|||
|
||||
def wkf_send_rfq(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'purchase.order')])
|
||||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'purchase.order')], context=context)[0]
|
||||
|
||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
||||
res_id = res and res[1] or False
|
||||
|
||||
#EDI EXport data
|
||||
id = ids[0]
|
||||
order = self.browse(cr, uid, id, context)
|
||||
#if not order.partner_id.opt_out:
|
||||
#order.edi_export_and_email(template_ext_id='purchase.email_template_edi_purchase', context=context)
|
||||
ctx = context.copy()
|
||||
ctx.update({'active_model': 'purchase.order', 'active_id': id, 'mail.compose.template_id': template_id})
|
||||
ctx.update({'active_model': 'purchase.order', 'active_id': ids[0], 'mail.compose.template_id': template_id})
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
|
|
|
@ -474,13 +474,13 @@ class sale_order(osv.osv):
|
|||
def print_quotation(self, cr, uid, ids, context=None):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
wf_service.trg_validate(uid, 'sale.order', id, 'quotation_sent', cr)
|
||||
wf_service.trg_validate(uid, 'sale.order', id, 'quotation_sent', cr)
|
||||
datas = {
|
||||
'model': 'sale.order',
|
||||
'ids': ids,
|
||||
'form': self.read(cr, uid, ids, context=context)[0],
|
||||
}
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True}
|
||||
}
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True}
|
||||
|
||||
def manual_invoice(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
|
@ -735,17 +735,17 @@ class sale_order(osv.osv):
|
|||
|
||||
def action_quotation_sent(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'sale.order')], context=context)
|
||||
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','email_compose_message_wizard_form')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'sale.order')], context=context)[0]
|
||||
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
|
||||
res_id = res and res[1] or False
|
||||
ctx = context.copy()
|
||||
ctx.update({'active_model': 'sale.order', 'active_id': ids[0], 'mail.compose.template_id': template_id})
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mail.compose.message',
|
||||
'views': [(resource_id,'form')],
|
||||
'view_id': resource_id,
|
||||
'views': [(res_id,'form')],
|
||||
'view_id': res_id,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
|
|
Loading…
Reference in New Issue