Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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)
delivery = self.env['stock.picking'].search([('origin','=',self.name)]) self.x_delivery_state = delivery.state
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
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?
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 platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/19/16, 1:55 PM|
|Seen: 370 times|
|Last updated: 12/29/16, 3:04 PM|