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 to add a new state to sales order? [Closed]

By
Anabela Damas
on 4/18/13, 11:47 AM 5,091 views

The Question has been closed

by
Anabela Damas
on 05/06/2013 14:00:35

I've try to add a state to sale order but I can't add the new state to statusbar.

Mymodule.py

class sale_order(osv.osv):
    _inherit = "sale.order"
    _name = "sale.order"
    _columns = {
        'state': fields.selection([
            ('draft', 'Draft Quotation'),
            ('sent', 'Quotation Sent'),
            ('waitingdocs', 'Waiting Docs'),
            ('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),
    }
    _defaults = {
        'state': 'draft',
    }
sale_order()

mymodule_view.xml

<record id="view_order_form_changed" model="ir.ui.view">
        <field name="name">sale.order.form.changed</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
        <xpath expr="/form/header/button[@name='print_quotation']" position="after">
            <button name="waiting_docs" states="draft" string="Newbutton" class="oe_highlight" type="object"/>
        </xpath>
        <xpath expr="/form/header/field[@name='state']" position="replace">
            <field name="state" widget="statusbar" statusbar_visible="draft,waitingdocs,sent,invoiced,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
        </xpath>
        <xpath expr="/form/sheet/h1" position="replace">
            <h1>
                    <label string="Quotation " attrs="{'invisible': [('state','not in',('draft','sent','waitingdocs'))]}"/>
                    <label string="Sales Order " attrs="{'invisible': [('state','in',('draft','sent','waitingdocs'))]}"/>
                    <field name="name" class="oe_inline" readonly="1"/>
                </h1>
        </xpath>
        </field>
    </record>

But this changes doesn't make any difference...

I've discovered that if I don't have the module "account_accountant", everything work fine. And if I install the "account_accountant" my new state only appears in the statusbar if the SO is in the my new state.

I would like that my new state appears in the status bar always, like it is when I don't have the module "account_accountant" installed.

Did you restart the server and update the module?

Sudhir Arya (SA)
on 4/18/13, 11:52 AM

I had created a new module for courier service through interface, not with python code. How can i add 4 different states(Send, Transporting Delivered, Delivery Failed) in the module through interface? Thanks in advance. Awaiting Your Reply.

Remya
on 4/19/13, 5:10 AM

Sorry through interface I've no idea ... Yes I've restarted the server... I've two Database in one the same code work in the other one not. I was seeing what were the diferences and I realise that was the module "aaccount_accountant" that was the difference. So in the Database with the "account_accountant" instaled my new state only appear in the status bar when the SO is in this new state, otherwise my new state doesn't appear in the status bar... Without the module "account_accountant" everything works fine, my new module appears in the status bar all the time.

Versão Integral, Anabela Damas
on 4/19/13, 5:47 AM

I don't know how to do for my new status appears in the statusbar, with the "account_accountant" installed.

Versão Integral, Anabela Damas
on 4/19/13, 5:48 AM
2
Alex Malone
On 4/19/13, 8:11 AM

It sounds like this is an inheritance issue to me. What may be happening is that whilst you are changing the state field in your module, so is the account_accountant module.

Now, without correctly defining your inheritance structure, OpenERP will make its own mind up as to which module to load first. If it is loading your module first, then the account_accountant module, then the other module will overwrite your changes.

Some things to test to see if this is the case:

1) Make your module depend on account_accountant

i.e. add account_accountant to the list of dependancies within __openerp__.py. This will ensure your module gets loaded last and thus doesnt get overwritten.

2) If you dont want to change dependancies, for example if your module needs to be independant of account_accountant, then try changing the priorities of your views. Add this to your view definition:

<field name="priority">1000</field>

So that your view definition becomes:

<record id="view_order_form_changed" model="ir.ui.view">
    <field name="name">sale.order.form.changed</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">

Experiment with the number, I can never remember whether you want a low or high number!

Hope this helps.

0
Anil Bhatt
On 1/18/15, 8:04 AM

I have similar issue where i'm adding a state for sales order and it getting added on return of purchase order. How can i stop this?

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 4/18/13, 11:47 AM
Seen: 5091 times
Last updated: 9/17/15, 2:55 PM