This question has been flagged
2 Replies
4378 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.

Avatar
Discard
Best Answer

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!

Avatar
Discard
Author

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?

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

Author

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.

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),

Author

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?

Author Best Answer

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.

Avatar
Discard