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

What is the best way to lookup things from within a model?

By
Darrel
on 11/28/14, 2:58 PM 547 views

I need to collect information about an order after a stock.move is created.

So far I have this:

    def create(self, cr, uid, vals, context=None):
        new_id = super(stock_move, self).create(cr, uid, vals, context=context)

        params = {}
        params['order_number'] = 0
        params['shipment_id'] = 0
        params['sku'] = vals['product_id']
        params['qty'] = vals['product_qty']
        params['weight'] = 0
        params['value'] = 0
        params['address'] = 0
        params['email'] = 0

What I don't know is, a) How do I query for the missing pieces? order number, shipment id, weight, value, customer address and email

and b) Which models are storing these things?

 

I've been looking into this, by looking at the helper methods used by other models. I understand I can use

self.pool.get('MODEL_NAME') for many things, but am unclear on how to do lookups by based on the relations. I can see that stock.move has many2one relationships with, stock.location (for instance), which I could use to get the 'address' part of the data I need, but am not sure how to get the related object and it's values.

 

Any help would be appreciated.

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: 11/28/14, 2:58 PM
Seen: 547 times
Last updated: 3/16/15, 8:10 AM