This question has been flagged
6 Replies
5623 Views

How to add a new status in sale.order in odoo 9?


Avatar
Discard

What status do you want to add? What is the business reason to add this status? Can you clarify with a business case?

Author

I want to add status is "pending" .

This status is required for the sales manager can validate the sale and before the user can "confirm the order".

Best Answer

You have to redefine "state" in sale order as follows:

_columns = {'state': fields.selection([('draft', 'Draft Quotation'),
                                        ('to_check', 'Pending'),
                                        ('checked', 'Checked'),
                                        ('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', select=True)}

Then add button action in sale order as follows:

def menu_to_check(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'to_check'}, context=context)

        return res
def menu_checked(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'checked'}, context=context)

        return res

Also you have to add corresponding two "workflow.activity" xml:

and three "workflow.transition" records  xml:

Two buttons in sale order inherited xml:


Hope this may help you.

Don't forget to give groups for your "checked" button for sale_managers in above xml
Avatar
Discard
Best Answer

Hi,

1) Redefine Existing state field:

state = fields.Selection([   

     ('draft', 'Quotation'),      

    ('sent', 'Quotation Sent'),    

    ('sale', 'Sale Order'),     

  ('pending', 'Pending'),

    ('done', 'Done'),  

    ('cancel', 'Cancelled'),  

      ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft')


2) Redifine the field state in xml..and create new button and its action for proper working as per your requirements

Avatar
Discard
Author Best Answer

thanks to all and add the status,just that when I click on the button to change the status pending

from quotation to sales order change meand buttons disappear confirming order.

And my status must be before the sale is confirmed.

How could resolve this?

Avatar
Discard
Best Answer

Hello,

In the new API you can use selection_add parameter to append some new options to the selection field.

So you can do:

class SaleOrder(models.Model):
     _inherit = 'sale.order'
     state = fields.Selection(selection_add([('pending', 'Pending')])


You can check this documentation for more details ...


Hope this could hleps ...

Avatar
Discard