Odoo Help

Welcome!

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.

0

How to get client order ref on delivery orders?

By
Andreas Marpmann
on 2/12/15, 8:45 AM 544 views

I only find modules or answers for v6 and v8.
Can someone help me on v7?

 

class stock_picking_out(orm.Model):
    _inherit = 'stock.picking.out'  
    
    def _get_sale_client_order_ref(self, cr, uid, ids, field_name, arg, context={}):
        res = {}
        for session in self.browse(cr,uid,ids,context=context):
            if (session.sale_id):
                res[session.id] = session.sale_id.client_order_ref or False
        return res
           
    _columns = {
        "client_order_reference": fields.function(_get_sale_client_order_ref, type='char', size=64,
                                                 method=True, string="Sales Order Customer Reference"
                                                 )
    }
   

1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 2/12/15, 9:45 AM

Instead of using a function field, you could try with related field
(http://odoo-new-api-guide-line.readthedocs.org/en/latest/fields.html#related-field)

class stock_picking_out(orm.Model):
    _inherit = 'stock.picking.out'  
    _columns = {
        "client_order_reference": fields.related('sale_id', 'client_order_ref', type='char', size=64,
                   string="Sales Order Customer Reference"
         )
    }

NOTE:  If you try to store a related field at stock.picking.out by adding parameter store=True, then you need to define this column at stock.picking also.(This is a special case only applicable for stock.picking, stock.picking.out and stock.picking.in)

Thanks for your note to the code has helped.

Metrolux Gmbh, Andreas Marpmann
on 2/12/15, 10:23 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

2 follower(s)

Stats

Asked: 2/12/15, 8:45 AM
Seen: 544 times
Last updated: 3/16/15, 8:10 AM