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.

0

How tochange the order of state from Sale Order in the statusbar? [Closed]

By
Anabela Damas
on 12/5/13, 11:03 AM 4,420 views

The Question has been closed

by
Anabela Damas
on 12/06/2013 11:25:14

Hi,

I'm trying to change the order from the states in the Sale Order form in the statusbar. I want to switch the order from the state "Sales Order"(progress) with "Sale to Invoice" (manual).

So I've tried to do like this:

    <record id="view_order_form_ch" model="ir.ui.view">
        <field name="name">sale.order.form.ch</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="priority">1000</field>
        <field name="arch" type="xml">

    <xpath expr="/form/header/field[@name='state']" position="replace">
       <field name="state" widget="statusbar" statusbar_visible="draft,sent,manual,progress,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
    </xpath>

        </field>
    </record>

But nothing happened.

To check if my code was being used, I change the "replace" in the code to "after". And my code is there but the states were in the same order that before, see image:

image description

So, how do I do to change "Sale to invoice" ('manual' state, in the image is green) with "Sales Order" ('progress' state, in the image is red )?

Thanks

1
Timo Talvitie
On 12/5/13, 12:01 PM

The visual order of the states is defined by the order that has been used in the selection field inside the python class. You'll need to inherit the sale.order model and override the state field so the order is changed from the original (see addons/sale/sale.py line 195) that looks like this...

    'state': fields.selection([
        ('draft', 'Draft Quotation'),
        ('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),

...to what you want, e.g. something like this:

    'state': fields.selection([
        ('draft', 'Draft Quotation'),
        ('sent', 'Quotation Sent'),
        ('cancel', 'Cancelled'),
        ('waiting_date', 'Waiting Schedule'),
        ('manual', 'Sale to Invoice'),
        ('progress', 'Sales Order'),
        ('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),

Note that this only changes the visual representation of the states though, so you will likely need to do some workflow customizing as well to make the business logic work the way you want.

I was convinced that the problem was in the view! Thanks a lot!

Versão Integral, Anabela Damas
on 12/5/13, 2:43 PM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 12/5/13, 11:03 AM
Seen: 4420 times
Last updated: 3/16/15, 8:10 AM