Skip to Content
Menu
This question has been flagged
2 Replies
7796 Views

Odoo 13


How can I get a list of sales orders, showing the status of each order? The status indicators would be something like the following.


Confirmed - A PO was received and the quote confirmed. Now the order needs to be processed.

Partial - Some items have shipped. Some items still need to be processed.

Done - All items have shipped.


Thanks,
David


Avatar
Discard
Best Answer

Hi:

You can add a computed field to the sale.order model and use it to filter the list.

Avatar
Discard
Author

I'm a software engineer so this should be no problem, but I'm totally new to Odoo.

Can you provide some details on how to accomplish this in Odoo?

The link provided by Chris gives the details of how to do this through the UI.

There is also a second way of doing this through python code using class inheritance. The code option is a little more convoluted and useful only in scenarios where you are hosting Odoo yourself.

Author

This solution looks like exactly what I need! Thanks so much for the help.

What dependent fields do you recommend I use to compute this new field? I assume I'll need to compare Quantity to Delivered, but I'm not sure how to get the source code names of those fields.

Also, I'll have to iterate through each line of the sales order to get Quantity and Delivered values for each line. How do I iterate through the lines?

Where can I find a list of available fields and their definitions?

You can activate developer mode and go to Settings > Technical > Models to see the fields and their definitions.

Author

I found the Dependencies and Compute advanced properties, for my newly created field, but these properties are disabled. The interface won't allow me to edit them. What can I do to enable them?

Author

I'm able to edit the properties now. I neglected to click Edit.

How do I iterate through the lines of the sales order and get the Quantity of each line?

Here's an example of adding up the delivered quantities in the sale.order.line model. The total field is to be defined in the sale.order model

for record in self:

record['x_total_qty_delivered'] = sum(line.qty_delivered for line in record.order_line)

Author

Excellent help. Thanks!

It's working now. Here is the complete solution.

Using Studio...

Add a new text field to the Sales Order form.

Set it's name to Delivery Status.

Click "More".

Activate Read Only.

Set Dependencies and Compute as shown below.

Text Field

Delivery Status

x_studio_delivery_status

Dependencies:

order_line.product_uom_qty, order_line.qty_delivered

Compute:

for record in self:

# Calculate sum of quantity on order.

qty_sum = sum(line.product_uom_qty for line in record.order_line)

# Calculate sum of deliverd.

del_sum = sum(line.qty_delivered for line in record.order_line)

if del_sum == 0:

# None delivered, so this is a new order.

record['x_studio_delivery_status'] ="New"

elif qty_sum != del_sum:

# Some delivered, but not all.

record['x_studio_delivery_status'] ="Partial"

else:

# The number delivered is equal to the number ordered, so order fully shipped.

record['x_studio_delivery_status'] ="Done"

When I tried to use this, the value of the variable qty_sum seems to be from the first order line only. Any ideas what might be wrong?

Check the definition of the qty_sum field to make sure it is recomputed every time the order lines are updated. Also, store=False.

Thanks Paresh. I think it's working now.

Thanks Dajac, this is really helpful. It should be part of Odoo really.

Related Posts Replies Views Activity
1
Oct 24
183
2
Mar 24
689
2
Mar 24
1322
0
Sep 23
354
1
Sep 23
458