Help

0

Determine status of sales orders

Avatar
Dajac Inc.

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
2 Answers
1
Avatar
Paresh Wagh
Best Answer

Hi:

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

13 Comments
Avatar
Discard
Avatar
Dajac Inc.
-

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?

Avatar
Chris TRINGHAM
-
Avatar
Paresh Wagh
-

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.

Avatar
Dajac Inc.
-

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?

Avatar
Paresh Wagh
-

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

Avatar
Dajac Inc.
-

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?

Avatar
Dajac Inc.
-

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?

Avatar
Paresh Wagh
-

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)

Avatar
Dajac Inc.
-

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"

Avatar
Chris TRINGHAM
-

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?

Avatar
Paresh Wagh
-

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

Avatar
Chris TRINGHAM
-

Thanks Paresh. I think it's working now.

Avatar
Giles M
-

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