Odoo Help


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.


States In Sale Orders

David Todd
on 5/19/16, 1:55 PM 281 views

There's probably a better way of doing this...

We're trying to modify our Sale Order Tree to have either a single column or multiple columns that will show which state each part of the selling process we are in. To be specific, we're interested in seeing the actual state the invoices and delivery orders are in. 

I know that the sale_order_tree view has a field called invoice_status, but this is very misleading as it only says whether or not an invoice has been created, not the state the invoice is in. 

My solution so far is to have two fields inside sale.order model:

(The fields are of type char and are compute)

Name: x_delivery_state_calc
delivery = self.env['stock.picking'].search([('origin','=',self.name)]) self.x_delivery_state = delivery.state

Name: x_invoice_state_calc

invoice = self.env['account.invoice'].search([('origin','=',self.name)]) self.x_invoice_state = invoice.state

This actually gives errors, but it's basically the same as doing (I'm interested in why it does that, but not the main purpose of this question):

for record in self:

invoice = self.env['account.invoice'].search([('origin','=',record['name'])]

record['x_invoice_state'] = invoice.state

Note that the fields I'm writing to are the same, but without the _calc. These fields are readonly selection type with the selection options being the states from both account_invoice.state and stock_picking.state.

I've also tried writing directly to the _calc field, but I know compute fields aren't stored in the database.

No matter how I write the value, I am unable to get those fields to show the data I want (ignore the top one, I manually added that to the database)

The data is available in the shell however, so I'm confused about why it is not available for the GUI

Triggering x_invoice_state_calc does write the data to the field, but not to the database. Is there a way that I can force this? Or is the compute just not happening? 

Ideally we would like for these fields to update to reflect the current state every time that you enter the sale orders tree


Ray Carnes

--Ray Carnes--
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 5/19/16, 8:17 PM

There is not a 1:1 relationship between Sales Orders and Delivery Orders and Invoices. You can have one Sales Order, 2 Delivery Orders and 3 Invoices. Perhaps take a step back with this knowledge and reassess. At earlier versions there was 'invoiced_rate' and 'shipped_rate' which would allow a progress bar to be shown. Order is 50% shipped and 100% paid for. Perhaps that would be better?

Thanks for getting back to me. Yes I was aware that there could be multiple invoices and delivery orders, but for our uses there is going to be one of each for every sale order created. After spending a couple days on this problem, we decided to simply add extra menu items in the Sales dashboard that lead to tree views of the invoices and delivery orders. I did check those fields that you suggested and they don't seem to exist in Odoo 9, or maybe I'm checking in the wrong spot

David Todd
on 5/20/16, 10:22 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

1 follower(s)


Asked: 5/19/16, 1:55 PM
Seen: 281 times
Last updated: 5/20/16, 6:45 AM