Odoo Help


How to Show Workflow buttons for two different users from sale order?

on 2/23/15, 7:35 PM 1,022 views

Hi all,

I have 3 users firstlevel,second level and admin users.

Need 3 approval for existing sale orders /quotation activity

when I create a new quotation ,then First Level Button should visible,after click on this button Second Level Button should visible ,then only confirm sale button should visible.

user1 have only privlige is approve firstlevel,User2 has only privilege is approve second level,Admin have all rights to first and second level approval.How to acheive this task in sale order work flow?

In  sale order form ,confirm order button should shown only after this two approval. 

User 1 will shows only firstlevel button 

User 2 will shows only secondlevel button 

admin will shows these 2 button .How to acheive this task..

This is my code========================================

.py file--


from openerp.osv import fields, osv
from openerp.tools.translate import _

class sale_order(osv.osv):
    extension to existing sale.order model
    _inherit = 'sale.order'
    _columns = {
        'state': fields.selection([
            ('draft', 'Draft Quotation'),
            ('quotation_approved', 'First Approval'),
            ('quotation_second', 'Second Approval'),
            ('sent', 'Quotation Sent'),
            ('cancel', 'Cancelled'),
            ('waiting_date', 'Waiting Schedule'),
            ('progress', 'Sales Order'),
            ('manual', 'Sale to Invoice'),
            ('invoice_except', 'Invoice Exception'),
            ('done', 'Done'),
            ], 'Status', readonly=True, track_visibility='onchange',
            help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
    def action_quotation_approve(self,cr,uid,ids,context=None):
        return True
    def action_quotation_approve_second(self,cr,uid,ids,context=None):
        return True


<?xml version="1.0" encoding="utf-8"?>
        <record id="my_quotation_form" model="ir.ui.view">
            <field name="name">sale.order.form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                    <button name="action_quotation_send" position="before">
                        <button name="approve_quotation" string="First Approval" states="draft"
                            type="workflow" class="oe_highlight" groups="base.group_user"/>
                          <button name="action_quotation_approve_second" string="Second Approval" states="draft"
                            type="workflow" class="oe_highlight" groups="base.group_user"/>
                    <button name="action_quotation_send" position="attributes">
                        <attribute name="states">quotation_approved,quotation_second,sent,progress,manual</attribute>
                    <button name="print_quotation" position="attributes">
                        <attribute name="states">quotation_approved,sent,progress,manual</attribute>
                     <button name="action_button_confirm" position="attributes">
                        <attribute name="states">quotation_approved,quotation_second,sent,progress,manual</attribute>
                    <field name="state" position="attributes">
                        <attribute name="statusbar_visible">draft,quotation_approved,quotation_second,sent,progress,done</attribute>
        <record id="my_action_quotations" model="ir.actions.act_window">
            <field name="name">My Quotations</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="sale.view_quotation_tree"/>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field name="context">{'search_default_my_sale_orders_filter': 1}</field>
            <field name="domain">[('state','in',('draft','quotation_approved','quotation_second', 'sent','cancel'))]</field>
            <field name="search_view_id" ref="sale.view_sales_order_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                You Can See Here all the Approval Types Here
                Odoo will help you handle efficiently the complete sale flow:
                from the quotation to the sales order, the
                delivery, the invoicing and the payment collection.
                The social feature helps you organize discussions on each sales
                order, and allow your customers to keep track of the evolution
                of the sales order.

        <menuitem action="my_action_quotations"
            name="Approval Details"


<?xml version="1.0" encoding="utf-8"?>
        <record id="act_quotation_approved" model="workflow.activity">
            <field name="wkf_id" ref="sale.wkf_sale"/>
            <field name="name">Approved</field>
            <field name="kind">function</field>
            <field name="action">action_quotation_approve()</field>
        <record id="trans_quotation_draft_to_approved" model="workflow.transition">
            <field name="act_from" ref="sale.act_draft"/>
            <field name="act_to" ref="act_quotation_approved"/>
            <field name="signal">approve_quotation</field>
        <record id="act_quotation_approved_second" model="workflow.activity">
            <field name="wkf_id" ref="sale.wkf_sale"/>
            <field name="name">Second</field>
            <field name="kind">function</field>
            <field name="action">action_quotation_approve_second()</field>
        <record id="trans_quotation_draft_to_approved_second" model="workflow.transition">
            <field name="act_from" ref="sale.act_draft"/>
            <field name="act_to" ref="act_quotation_approved_second"/>
            <field name="signal">approve_quotation_second</field>


    "name": "My Sale Approvals",
    "version": "1.0",
    "category": "Sales Management",
    "depends": ['sale'],
    "description": """
    This is for demo extension to sale order
    'demo': [],
    'data': [
    'test': [],
    'author': "Me",
    'installable': True,
    'auto_install': False,

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/23/15, 7:35 PM
Seen: 1022 times
Last updated: 3/16/15, 8:10 AM