跳至内容
菜单
此问题已终结
6 回复
6246 查看

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


形象
丢弃

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

编写者

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".

最佳答案

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
形象
丢弃
最佳答案

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

形象
丢弃
编写者 最佳答案

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?

形象
丢弃
最佳答案

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

形象
丢弃