[IMP] sale: workflow improvements and send quatation in mail feature implementation
bzr revid: psi@tinyerp.com-20120229094632-wvu5h6w0avbhto1b
This commit is contained in:
parent
1cef20a8c3
commit
8dcc88469e
|
@ -2,14 +2,7 @@
|
|||
<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>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<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">
|
||||
|
@ -30,9 +23,18 @@
|
|||
so users can freely customize/delete them -->
|
||||
<data noupdate="1">
|
||||
<!-- bind the mailing server action to sale.order confirmed activity -->
|
||||
<!--
|
||||
<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>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="name">Auto-email confirmed sale orders</field>
|
||||
</record>
|
||||
<record id="sale.act_wait_ship" model="workflow.activity">
|
||||
<field name="action_id" ref="ir_actions_server_edi_sale"/>
|
||||
</record>
|
||||
</record> -->
|
||||
|
||||
|
||||
<!--Email template -->
|
||||
|
|
|
@ -201,10 +201,11 @@ class sale_order(osv.osv):
|
|||
'origin': fields.char('Source Document', size=64, help="Reference of the document that generated this sales order request."),
|
||||
'client_order_ref': fields.char('Customer Reference', size=64),
|
||||
'state': fields.selection([
|
||||
('draft', 'Quotation'),
|
||||
('draft', 'Draft Quotation'),
|
||||
('sent', 'Quotation Sent'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('manual', 'To Invoice'),
|
||||
('progress', 'In Progress'),
|
||||
('manual', 'Sale to Invoice'),
|
||||
('progress', 'Sale in Progress'),
|
||||
('shipping_except', 'Shipping Exception'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
|
@ -470,6 +471,17 @@ class sale_order(osv.osv):
|
|||
inv_obj.button_compute(cr, uid, [inv_id])
|
||||
return inv_id
|
||||
|
||||
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)
|
||||
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}
|
||||
|
||||
def manual_invoice(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
@ -658,6 +670,34 @@ class sale_order(osv.osv):
|
|||
self.log(cr, uid, o.id, message)
|
||||
return True
|
||||
|
||||
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']
|
||||
#EDI EXport data
|
||||
id = ids[0]
|
||||
if not self.browse(cr, uid, id, context).partner_id.opt_out:
|
||||
order.edi_export_and_email(template_ext_id='sale.email_template_edi_sale', context=context)
|
||||
ctx = context.copy()
|
||||
ctx.update({'active_model': 'sale.order', 'active_id': id, '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,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
'nodestroy': True,
|
||||
}
|
||||
|
||||
def _hook_message_sent(self, cr, uid, sale_id, context=None):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', sale_id, 'quotation_sent', cr)
|
||||
return True
|
||||
|
||||
def procurement_lines_get(self, cr, uid, ids, *args):
|
||||
res = []
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
|
|
|
@ -200,20 +200,21 @@
|
|||
<button name="%(action_view_sale_advance_payment_inv)d" string="Advance Invoice" type="action" icon="gtk-execute" states="draft,manual" groups="base.group_extended"/>
|
||||
</group>
|
||||
<group col="17" colspan="4">
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,progress,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,sent,progress,invoiced,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
|
||||
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice" icon="gtk-go-forward"/>
|
||||
<button name="invoice_corrected" states="invoice_except" string="Ignore Exception" icon="gtk-apply"/>
|
||||
<button name="ship_recreate" states="shipping_except" string="Recreate Packing" icon="gtk-ok"/>
|
||||
<button name="ship_corrected" states="shipping_except" string="Ignore Exception" icon="gtk-apply"/>
|
||||
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="action_quotation_sent" string="Send" type="object" icon="terp-mail-message-new" states="draft"/>
|
||||
<button name="%(report_sale_order)d" string="Print Order" type="action" icon="gtk-print" states="waiting_date,manual,progress,done,shipping_except,invoice_except"/>
|
||||
<button name="manual_invoice" states="manual" string="Create Final Invoice" icon="gtk-go-forward" type="object"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name="cancel" states="draft" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="print_quotation" string="Print Quotation" type="object" icon="gtk-print" states="draft"/>
|
||||
<button name="order_confirm" states="draft,sent" string="Confirm Order" icon="gtk-apply"/>
|
||||
<button name="cancel" states="draft,sent" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="invoice_cancel" states="invoice_except" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="%(report_sale_order)d" string="Print Quotation" type="action" icon="gtk-print" states="draft"/>
|
||||
<button name="order_confirm" states="draft" string="Confirm Order" icon="gtk-apply"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Other Information">
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
<field name="flow_start">True</field>
|
||||
<field name="name">draft</field>
|
||||
</record>
|
||||
<record id="act_sent" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_sale"/>
|
||||
<field name="name">sent</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'sent'})</field>
|
||||
</record>
|
||||
<record id="act_router" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_sale"/>
|
||||
<field name="name">router</field>
|
||||
|
@ -123,6 +129,24 @@
|
|||
<field name="signal">order_confirm</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_draft_sent" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_sent"/>
|
||||
<field name="signal">quotation_sent</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_sent_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_sent"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_sent_router" model="workflow.transition">
|
||||
<field name="act_from" ref="act_sent"/>
|
||||
<field name="act_to" ref="act_router"/>
|
||||
<field name="signal">order_confirm</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_draft_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
|
|
Loading…
Reference in New Issue