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

Domain default method how to call

By
Prakash
on 2/16/13, 5:19 AM 2,014 views

In Domain how to call default method:-

    def _get_lotproduct(self, cr, uid, context=None):
        lot_obj = self.pool.get('stock.production.lot')
        lotids = lot_obj.search(cr, uid, [])
        product_id = []
        for val in lot_obj.browse(cr, uid, lotids):
            product_id.append(val.product_id.id)
        return product_id[0]


 'product_id': fields.many2one('product.product', 'Product',  domain="[('product_id','=',_get_lotproduct)]"),

    _defaults = {
           'product_id'   : _get_lotproduct
    }

domain="[('product_id','=',_get_lotproduct)]" Is it possible to call default method in domain?

1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 3/8/13, 7:11 AM

Hi..

In defaults, you can only set a default value for the field and not domain...

Instead u can do the other way, add another field which will fetch the domain value and that field try to use it as a domain to your fields..

Example:

lets say, 'field1': => used to store the domain value 'field2':.... domain=[('product_id','=',field1)]

hope this helps you

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

0 follower(s)

Stats

Asked: 2/16/13, 5:19 AM
Seen: 2014 times
Last updated: 3/16/15, 8:10 AM