[IMP] sale: changes related to the cleaning of the SO workflow

bzr revid: qdp-launchpad@openerp.com-20120525133536-2rrkqkffpdmt35nt
This commit is contained in:
Quentin (OpenERP) 2012-05-25 15:35:36 +02:00
parent 9433fedf2a
commit c4d31012d1
9 changed files with 71 additions and 60 deletions

View File

@ -33,7 +33,12 @@
</div>
</div>
<h1 class="oe_edi_doc_title">Order <t t-esc="doc.name"/>: <t t-esc="_.str.sprintf('%.2f',doc.amount_total)"/> <t t-esc="doc.currency.code"/></h1>
<t t-if="(doc.state == 'draft' or doc.state == 'sent')">
<h1 class="oe_edi_doc_title">Quotation <t t-esc="doc.name"/>: <t t-esc="_.str.sprintf('%.2f',doc.amount_total)"/> <t t-esc="doc.currency.code"/></h1>
</t>
<t t-if="(doc.state != 'draft' and doc.state != 'sent')">
<h1 class="oe_edi_doc_title">Order <t t-esc="doc.name"/>: <t t-esc="_.str.sprintf('%.2f',doc.amount_total)"/> <t t-esc="doc.currency.code"/></h1>
</t>
<table width="100%" class="oe_edi_data oe_edi_shade">
<tr class="oe_edi_floor">
@ -116,7 +121,7 @@
</div>
</t>
<t t-name="Edi.sale.order.sidebar">
<t t-if="doc.order_policy &amp;&amp; (doc.order_policy == 'prepaid' || doc.order_policy == 'manual')">
<t t-if="doc.order_policy and (doc.order_policy == 'prepaid' || doc.order_policy == 'manual') and (doc.state != 'draft' and doc.state != 'sent')">
<t t-if="doc.company_address.paypal_account || doc.company_address.bank_ids">
<p class="oe_edi_sidebar_title">Pay Online</p>
<t t-if="doc.company_address.paypal_account">

View File

@ -56,8 +56,6 @@ class email_template(osv.osv):
:param str model: model name of the document record this mail is related to.
:param int res_id: id of the document record this mail is related to.
"""
if context is None:
context = {}
if not template: return u""
if context is None:
context = {}
@ -149,7 +147,7 @@ class email_template(osv.osv):
help="Optional preferred server for outgoing mails. If not set, the highest "
"priority one will be used."),
'body_text': fields.text('Text Contents', translate=True, help="Plaintext version of the message (placeholders may be used here)"),
'body_html': fields.text('Rich-Text Contents', translate=True, help="Rich-Text/HTML version of the message (placeholders may be used here)"),
'body_html': fields.text('Rich-text Contents', translate=True, help="Rich-text/HTML version of the message (placeholders may be used here)"),
'message_id': fields.char('Message-Id', size=256, help="Message-ID SMTP header to use in outgoing messages based on this template. "
"Please note that this overrides the 'Resource Tracking' option, "
"so if you simply need to track replies to outgoing emails, enable "

View File

@ -121,7 +121,8 @@ class mail_message_common(osv.osv_memory):
'body_html': fields.text('Rich-text Contents', help="Rich-text/HTML version of the message"),
'body': fields.function(get_body, fnct_search = search_body, string='Message Content', type='text',
help="Content of the message. This content equals the body_text field for plain-test messages, and body_html for rich-text/HTML messages. This allows having one field if we want to access the content matching the message subtype."),
'parent_id': fields.many2one('mail.message', 'Parent Message', help="Parent message, used for displaying as threads with hierarchy", select=True, ondelete='set null',),
'parent_id': fields.many2one('mail.message', 'Parent Message', help="Parent message, used for displaying as threads with hierarchy",
select=True, ondelete='set null',),
'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'),
}

View File

@ -260,6 +260,7 @@ class mail_compose_message(osv.osv_memory):
subtype=mail.subtype, headers=headers, context=context)]
# in normal mode, we send the email immediately, as the user expects us to (delay should be sufficiently small)
mail_message.send(cr, uid, msg_ids, context=context)
return {'type': 'ir.actions.act_window_close'}
def render_template(self, cr, uid, template, model, res_id, context=None):

View File

@ -60,19 +60,20 @@ SALE_ORDER_EDI_STRUCT = {
'payment_term': True,
'order_policy': True,
'user_id': True,
'state': True,
}
class sale_order(osv.osv, EDIMixin):
_inherit = 'sale.order'
def action_quotation_sent(self, cr, uid, ids, context=None):
def action_quotation_send(self, cr, uid, ids, context=None):
if context is None:
context = {}
sale_objs = self.browse(cr, uid, ids, context=context)
edi_token = self.pool.get('edi.document').export_edi(cr, uid, sale_objs, context = context)[0]
web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
ctx = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token))
return super(sale_order, self).action_quotation_sent(cr, uid, ids, context=ctx)
return super(sale_order, self).action_quotation_send(cr, uid, ids, context=ctx)
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
"""Exports a Sale order"""

View File

@ -2,7 +2,6 @@
<openerp>
<data>
<!-- EDI Export + Send email Action -->
<!--
<record id="ir_actions_server_edi_sale" model="ir.actions.server">
<field name="code">if not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='sale.email_template_edi_sale', context=context)</field>
<field name="state">code</field>
@ -11,7 +10,6 @@
<field name="condition">True</field>
<field name="name">Auto-email confirmed sale orders</field>
</record>
-->
<!-- EDI related Email Templates menu -->
<record model="ir.actions.act_window" id="action_email_templates">
@ -31,11 +29,9 @@
so users can freely customize/delete them -->
<data noupdate="1">
<!-- bind the mailing server action to sale.order confirmed activity -->
<!--
<record id="sale.act_wait_ship" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_edi_sale"/>
</record>
-->
<!--Email template -->
@ -51,7 +47,7 @@
<p>Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},</p>
<p>Here is your order confirmation for ${object.partner_id.name}: </p>
<p>Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'}: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
@ -68,12 +64,12 @@
</p>
<p>
You can view the order confirmation document, download it and pay online using the following link:
You can view the ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} document, download it and pay online using the following link:
</p>
<a style="display:block; width: 150px; height:20px; margin-left: 120px; color: #FFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; text-align: center; text-decoration: none !important; line-height: 1; padding: 5px 0px 0px 0px; background-color: #8E0000; border-radius: 5px 5px; background-repeat: repeat no-repeat;"
href="${ctx.get('edi_web_url_view') or ''}">View Order</a>
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account:
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state not in ('draft', 'sent'):
<%
comp_name = quote(object.company_id.name)
order_name = quote(object.name)
@ -133,7 +129,7 @@
<field name="body_text"><![CDATA[
Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
Here is your order confirmation for ${object.partner_id.name}:
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'}:
| Order number: *${object.name}*
| Order total: *${object.amount_total} ${object.pricelist_id.currency_id.name}*
| Order date: ${object.date_order}
@ -145,10 +141,10 @@ Here is your order confirmation for ${object.partner_id.name}:
% endif
| Your contact: ${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
You can view the order confirmation, download it and even pay online using the following link:
You can view the ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'}, download it and even pay online using the following link:
${ctx.get('edi_web_url_view') or 'n/a'}
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account:
% if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state not in ('draft', 'sent'):
<%
comp_name = quote(object.company_id.name)
order_name = quote(object.name)

View File

@ -207,8 +207,8 @@ class sale_order(osv.osv):
('sent', 'Quotation Sent'),
('cancel', 'Cancelled'),
('waiting_date', 'Waiting Schedule'),
('manual', 'Sale to Invoice'),
('progress', 'Sale Order'),
('manual', 'Sale to Invoice'),
('shipping_except', 'Shipping Exception'),
('invoice_except', 'Invoice Exception'),
('done', 'Done'),
@ -469,13 +469,13 @@ class sale_order(osv.osv):
return inv_id
def print_quotation(self, cr, uid, ids, context=None):
assert len(ids) == 1, 'This option should only be used for a single id at a time'
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', ids[0], 'quotation_sent', cr)
datas = {
'model': 'sale.order',
'ids': ids,
'form': self.read(cr, uid, ids, context=context)[0],
'form': self.read(cr, uid, ids[0], context=context),
}
return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order', 'datas': datas, 'nodestroy': True}
@ -511,66 +511,72 @@ class sale_order(osv.osv):
}
def action_view_invoice(self, cr, uid, ids, context=None):
'''
This function returns an action that display existing invoices of given sale order ids. It can either be a in a list or in a form view, if there is only one invoice to show.
'''
mod_obj = self.pool.get('ir.model.data')
result = {
'name': _('Cutomer Invoice'),
'view_type': 'form',
'res_model': 'account.invoice',
'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
}
#compute the number of invoices to display
inv_ids = []
result = {}
for so in self.browse(cr, uid, ids, context=context):
inv_ids+= [invoice.id for invoice in so.invoice_ids]
inv_ids += [invoice.id for invoice in so.invoice_ids]
#choose the view_mode accordingly
if len(inv_ids)>1:
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')
result.update({
'view_mode': 'tree,form',
'res_id': inv_ids or False
'view_mode': 'tree,form',
'res_id': inv_ids or False
})
else:
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
result.update({
'view_mode': 'form',
'res_id': inv_ids and inv_ids[0] or False,
'view_mode': 'form',
'res_id': inv_ids and inv_ids[0] or False,
})
res_id = res and res[1] or False,
result.update({
'name': _('Cutomer Invoice'),
'view_type': 'form',
'view_id': [res_id],
'res_model': 'account.invoice',
'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
})
result.update(view_id = res and res[1] or False)
return result
def action_view_delivery(self, cr, uid, ids, context=None):
'''
This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show.
'''
mod_obj = self.pool.get('ir.model.data')
result = {
'name': _('Delivery Order'),
'view_type': 'form',
'res_model': 'stock.picking',
'context': "{'type':'out'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
}
#compute the number of delivery orders to display
pick_ids = []
result = {}
for so in self.browse(cr, uid, ids, context=context):
pick_ids += [picking.id for picking in so.picking_ids]
#choose the view_mode accordingly
if len(pick_ids) > 1:
res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_tree')
result.update({
'view_mode': 'tree,form',
'res_id': pick_ids or False
'view_mode': 'tree,form',
'res_id': pick_ids or False
})
else:
res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_form')
result.update({
'view_mode': 'form',
'res_id': pick_ids and pick_ids[0] or False,
'view_mode': 'form',
'res_id': pick_ids and pick_ids[0] or False,
})
res_id = res and res[1] or False,
result.update({
'name': _('Delivery Order'),
'view_type': 'form',
'view_id': res_id,
'res_model': 'stock.picking',
'context': "{'type':'out'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
})
result.update(view_id = res and res[1] or False)
return result
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
@ -730,7 +736,11 @@ class sale_order(osv.osv):
self.confirm_send_note(cr, uid, ids, context)
return True
def action_quotation_sent(self, cr, uid, ids, context=None):
def action_quotation_send(self, cr, uid, ids, context=None):
'''
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'
mod_obj = self.pool.get('ir.model.data')
template = mod_obj.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')
template_id = template and template[1] or False
@ -1476,7 +1486,6 @@ class sale_order_line(osv.osv):
sale_order_line()
class mail_message(osv.osv):
_name = 'mail.message'
_inherit = 'mail.message'
def _postprocess_sent_message(self, cr, uid, message, context=None):

View File

@ -102,8 +102,8 @@
<button name="invoice_corrected" states="invoice_except" string="Ignore Exception"/>
<button name="ship_recreate" states="shipping_except" string="Recreate Delivery Order"/>
<button name="ship_corrected" states="shipping_except" string="Ignore Exception"/>
<button name="action_quotation_sent" string="Send by Mail" type="object" states="draft" class="oe_form_button_hi"/>
<button name="action_quotation_sent" string="Send by Mail" type="object" states="sent"/>
<button name="action_quotation_send" string="Send by Mail" type="object" states="draft" class="oe_form_button_hi"/>
<button name="action_quotation_send" string="Send by Mail" type="object" states="sent"/>
<button name="manual_invoice" states="manual" string="Create Final Invoice" type="object"/>
<button name="print_quotation" string="Send by Post" type="object" states="draft" class="oe_form_button_hi"/>
<button name="print_quotation" string="Send by Post" type="object" states="sent"/>

View File

@ -204,7 +204,7 @@
<field name="act_to" ref="act_invoice"/>
<field name="signal">manual_invoice</field>
</record>
<record id="trans_invoice_invoice_end" model="workflow.transition">
<field name="act_from" ref="act_invoice"/>
<field name="act_to" ref="act_invoice_end"/>