Odoo Help


Showing Delivery Information on Sales Orders?

on 1/12/15, 5:50 AM 1,300 views

I would like to add field picked_rate in sale.order.tree to show the  (%) of delivered

I used the answer  https://www.odoo.com/forum/help-1/question/showing-delivery-information-status-carrier-ref-backorders-on-sales-orders-29603

but the field picked_rate doesn't exist in sale.order !!!

On 1/16/15, 10:16 AM

here is the solution

class sale_order(osv.osv):
    _inherit = 'sale.order'
    def _picked_rate(self, cr, uid, ids, name, arg, context=None):
        if not ids:
            return {}
        res = {}
        tmp = {}
        for i in ids:
            tmp[i] = {'picked': 0.0, 'total': 0.0}
        cr.execute(''' SELECT s.id AS sale_order_id,sum(sm.product_uom_qty) AS nbr, sm.state AS move_state, spt.code AS picking_type
             FROM sale_order s
              LEFT JOIN procurement_group p ON (p.id=s.procurement_group_id)
              LEFT JOIN stock_picking sp ON (sp.group_id=p.id)
              LEFT JOIN stock_move sm ON (sm.picking_id=sp.id)
              LEFT JOIN stock_picking_type spt on (spt.id=sp.picking_type_id)
              WHERE s.id IN %s GROUP BY sm.state,s.id,spt.code ''', (tuple(ids),))
        for item in cr.dictfetchall():
            if item['move_state'] == 'cancel':
            if item['picking_type'] == 'incoming':  # this is a returned picking
                tmp[item['sale_order_id']]['total'] -= item['nbr'] or 0.0  # Deducting the return picking qty
#                 if item['procurement_state'] == 'done' or item['move_state'] == 'done':
                if  item['move_state'] == 'done':
                    tmp[item['sale_order_id']]['picked'] -= item['nbr'] or 0.0
                tmp[item['sale_order_id']]['total'] += item['nbr'] or 0.0
#                 if item['procurement_state'] == 'done' or item['move_state'] == 'done':
                if  item['move_state'] == 'done':
                    tmp[item['sale_order_id']]['picked'] += item['nbr'] or 0.0
        for order in self.browse(cr, uid, ids, context=context):
            if order.shipped:
                res[order.id] = 100.0
                res[order.id] = tmp[order.id]['total'] and (100.0 * tmp[order.id]['picked'] / tmp[order.id]['total']) or 0.0
        return res  

    _columns = {
        'picked_rate': fields.function(_picked_rate, method=True, string='Picked', type='float'),

then and override the sale.order.tree view and add:

<field name="picked_rate" widget="progressbar" string="Shipped"/>

Emad Jaddo
On 3/6/15, 7:33 AM

Where exactly do you add this code to add this field?

Just a beginner here so please give some details.

create new model or you can add the to the sale modules

on 3/6/15, 9:34 AM

I can define the variable in the sales model. I tried all field type, but I cannot find any that allow to input the above function. Can someone give a more detailed way to achieve this?

Emad Jaddo
on 3/6/15, 2:45 PM


| 6 5 7
Lodz, Poland

On 1/12/15, 10:57 AM

The field picked_rate no longer exists in v8.

yes I know how to add it ?

on 1/12/15, 11:14 AM

It is rather difficult with a new WMS system.

on 1/12/15, 12:13 PM

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 1/12/15, 5:50 AM
Seen: 1300 times
Last updated: 3/16/15, 8:10 AM