Mazhar Iqbal Rana
Mazhar Iqbal Rana

Reputation: 75

New State in Openerp7

... In openerp7

I want my new state to show up in sale module ... But it is not appearing Pls have a look at code below

In sale.py module I added state like:

class Sale_order(osv.Model):

_inherit = 'sale.order'

_columns = {
    'state': fields.selection([
        ('draft', 'Draft Quotation'),
        ('my_new_state', 'My New State'),
        ('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),
}

And in sale_view.xml, I added this piece of code..

<openerp>
<data>
    <!-- Inherit the sale order model's form view and customize -->
    <record id="sale_form_view" model="ir.ui.view">
        <field name="name">sale.order.form.inherit</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <!-- Statusbar widget should also contain the new status -->
            <field name="state" position="replace">
                <field name="state" widget="statusbar" statusbar_visible="draft,my_new_state,sent,invoiced,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
            </field>
        </field>
    </record>
</data>

But.... My new state is not appearing between draft quotation and quotation sent

Please guide

Why is this so

Thanks

Upvotes: 0

Views: 405

Answers (1)

zee
zee

Reputation: 184

First thing I would check is to make sure you are replacing the proper field in your view (if there are several instances of a field named "state" in the view you inherit, the wrong occurence could be replaced). Check the view by opening the 'Modify FormView' item in the developper tools/view.

If it is the wrong occurence you are replacing, you main need to change your view definition by using an xpath expression.

Second thing I would check, is make sure the sequence of your inherited view is smaller that the original view you are trying to replace/modify. You can check in 'Manage Views' item in the developper tools/view.

Third thing I would try is to rename your class from 'Sale_order' to 'sale_order' just to match the name of the original class your are trying to override.

Hope this helps.

Upvotes: 1

Related Questions