Odoo Help

Welcome!

This community 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.

2

Hide button from sales manager and only sales person can view

By
Johny Levy
on 4/21/14, 7:54 AM 1,489 views

i have created a button 'Quotation to Approve' in a sale order form so that every time salesperson created a quotation he/she need to click that button to get approval from manager. however when sales manager want to create quotation, he/she also can view that button. i want to hide that button from sales manager and only sales person can view it. i tried to use groups=base.group_sale_salesman but still manager can view it. any ideas? i believe someone already done this before. hopefully i can get the solution here. thanks in advance.

3
Roc cheng
On 4/21/14, 11:44 PM

Hi,by setting groups on the button won't meet your needs,do you want that when the salemanager create quotation,the order needn't get approved? Edit workflow sale.order.basic,have you ever changed it(add the button 'Quotation to Approve' you created ..)?

In my opinion: your workflow like: Draft---->Quotation to Approve--->Quotation....

Add a transition Draft---->Quotation

The set the transition

<field name="signal"> check_user</field>

The signal may be a function:

exmpale: First defined create_uid on you model(record the create user):

'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True),

Then Judge the create user whether in gourp salemanger

def check_user(....):
     .
     .
    if self.pool.get('res.users').has_group(cr,create_uid.id , 'base.group_sale_manager'):
        return True
    return Flase

Another way overwirte create method,check the create user whether has salemanager group ,the changer the state, do the super(xxx, self).create(...) first(this way may ont good,you will not change some fied value that can be changed on draft state ) Hope it will help you!

i just want to hide 'Quotation to Approve' button from salemanager view and only saleperson can view it. do i need to edit workflow to enable this?

Johny Levy
on 4/22/14, 1:20 AM

could you expalin what the button 'Quotation to Approve' do(whether change the order state.etc)? maybe hide the button for the salemanager, the order won't changed anymore

Roc cheng
on 4/22/14, 3:15 AM

okay..the button 'Quotation to Approve' will change the state to 'Waiting for Approval' from Draft Quotation. i just want to hide the 'Quotation to Approve' button from salemanager.

Johny Levy
on 4/22/14, 8:14 AM

Here is my confused,If you hide the button 'Quotation to Approve' for salemanager,The order will not change the state to 'Waiting for Approval' from Draft Quotation. so the better way is change the workflow,when the sale manger create the order it's state auto move 'Waiting for Approval'(not click button trigger),

Roc cheng
on 4/22/14, 11:17 PM

i think you're right, do you have any reference on how to change the workflow so that salemanager create the order it's state auto move to other state?

Johny Levy
on 4/23/14, 12:36 AM
0
Johny Levy
On 4/23/14, 8:00 AM

i did try based on your way but the state doesn't change, it doesn't prompt me an error but the state still in draft quotation when i create a quotation. i defined create_uid in my model and set the transition. here my check_user function:

def check_user (self, cr, create_uid, context=None):
    context = context or {}
    if self.pool.get('res.users').has_group(cr,create_uid.id , 'base.group_sale_manager'):  
        return True
    return False

hope you can help me. thank you.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/21/14, 7:54 AM
Seen: 1489 times
Last updated: 3/16/15, 8:10 AM