Purnendu Singh (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-sale_order_wkf-psi into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-sale_order_wkf-psi/+merge/96300
Hello,
* Improve the workflow and one state 'sent' to support the feature of printing
and sending the quotation by mail.
* Added buttons send, Print Quatation, Open Invoice, Open Delivery Order.
* Update attrs on Open Invoice and Delivery Order to support their visibility
based on order_policy and states
Thanks,
Purnendu Singh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-sale_order_wkf-psi/+merge/96300
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-sale_order_wkf-psi.
=== modified file 'sale/edi/sale_order_action_data.xml'
--- sale/edi/sale_order_action_data.xml 2011-11-09 17:38:17 +0000
+++ sale/edi/sale_order_action_data.xml 2012-03-07 06:35:26 +0000
@@ -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 -->
=== modified file 'sale/sale.py'
--- sale/sale.py 2012-02-28 14:08:16 +0000
+++ sale/sale.py 2012-03-07 06:35:26 +0000
@@ -201,10 +201,11 @@
'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 @@
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")
@@ -501,6 +513,64 @@
'res_id': inv_ids and inv_ids[0] or False,
}
+ def action_view_invoice(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ inv_ids = []
+ for so in self.browse(cr, uid, ids, context=context):
+ inv_ids+= [invoice.id for invoice in so.invoice_ids]
+
+ res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
+ res_id = res and res[1] or False
+
+ return {
+ 'name': _('Customer Invoices'),
+ 'view_type': 'form',
+ 'view_mode': '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',
+ 'res_id': inv_ids and inv_ids[0] or False,
+ }
+
+ def action_view_delivery(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ pick_ids = []
+ for so in self.browse(cr, uid, ids, context=context):
+ pick_ids += [picking.id for picking in so.picking_ids]
+ if len(pick_ids) > 1:
+ res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_tree')
+ res_id = res and res[1] or False,
+ return {
+ 'name': _('Delivery Order'),
+ 'view_type': 'form',
+ 'view_mode': 'tree',
+ 'view_id': res_id,
+ 'res_model': 'stock.picking',
+ 'context': "{'type':'out'}",
+ 'type': 'ir.actions.act_window',
+ 'nodestroy': True,
+ 'target': 'current',
+ 'res_id': pick_ids or False,
+ }
+ else:
+ res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_form')
+ res_id = res and res[1] or False,
+ return {
+ 'name': _('Delivery Order'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'view_id': res_id,
+ 'res_model': 'stock.picking',
+ 'context': "{'type':'out'}",
+ 'type': 'ir.actions.act_window',
+ 'nodestroy': True,
+ 'target': 'current',
+ 'res_id': pick_ids and pick_ids[0] or False,
+ }
+
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
res = False
invoices = {}
@@ -658,6 +728,30 @@
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']
+ 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,
+ '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={}):
=== modified file 'sale/sale_view.xml'
--- sale/sale_view.xml 2012-01-31 13:36:57 +0000
+++ sale/sale_view.xml 2012-03-07 06:35:26 +0000
@@ -200,20 +200,25 @@
<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_quotation_sent" string="Send" type="object" icon="terp-mail-message-new" states="draft"/>
+ <button name="manual_invoice" states="manual" string="Create Final Invoice" icon="gtk-go-forward" type="object"/>
+ <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
+ <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="action_view_invoice" string="Open Invoice" icon="gtk-go-forward" type="object"
+ attrs="{'invisible': ['|','|','|',('state', 'not in', ('progress',)), ('invoiced', '=', True),'&',('order_policy','=','picking'),
+ ('state', '!=','done'),'&','&',('order_policy','=','postpaid'),('state', '=','progress'),('shipped','=',False)]}"/>
+ <button name="action_view_delivery" string="Open Delivery Order" icon="gtk-go-forward" type="object"
+ attrs="{'invisible': ['|','|', ('picking_ids','=',[]), ('state', 'not in', ('progress','manual')),('shipped','=',True)]}"/>
+ <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="%(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="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">
=== modified file 'sale/sale_workflow.xml'
--- sale/sale_workflow.xml 2011-12-19 16:54:40 +0000
+++ sale/sale_workflow.xml 2012-03-07 06:35:26 +0000
@@ -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"/>
@@ -180,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"/>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp