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.

1

How to Create Function (Dummy) One2many Field in models.Model ?

By
Miftah
on 4/16/15, 7:42 AM 753 views

I have create dummy One2many field in osv.osv like this :

def _get_picking_ids(self, cr, uid, ids, field_names, args, context=None):
        res = {}
        for po_id in ids:
            res[po_id] = []
        query = """
        SELECT p.id, po.id FROM stock_picking p, wtc_mutation_order po
            WHERE po.id in %s and p.origin = po.name
            GROUP BY p.id, po.id
        """
        cr.execute(query, (tuple(ids), ))
        picks = cr.fetchall()
        for pick_id, po_id in picks:
            res[po_id].append(pick_id)
        return res

'picking_ids': fields.function(_get_picking_ids, method=True, type='one2many', relation='stock.picking', string='Picking List'),

But how to make it in models.Model ?

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

1 follower(s)

Stats

Asked: 4/16/15, 7:42 AM
Seen: 753 times
Last updated: 7/10/15, 10:50 AM