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

Change domain without using on_change (SOLVED)

By
Pau Ubach
on 9/17/14, 4:56 AM 1,030 views

Hi, I need to define the domain when the view appears (no action required, it should be automatic).

I'm trying to include some functionality on default_get, but I'm not getting results. I mean, in an on_change function you can return domain, but in default_get only the dictionary with values is accepted. 

Any suggestion?

This is the function as I have now.

def get_customer(self):
            cust = customer_in_pricelist.get_customer()
            if cust:
                return {'domain': [('cus_id', '=', cust)]}
            return {'domain': [('cus_id', '=', 0)]}

I'm trying to use fields_view_get but I'm a bit lost.

Pau Ubach
on 9/17/14, 5:53 AM
0
Pau Ubach
On 9/17/14, 6:04 AM

Solved changing for fields_view_get:

 

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
           if context is None:
                context = {}
            res = super(bdd_quotations,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
            res['fields']['pr_id']['domain'] = [('cus_id','=',customer_in_pricelist.get_customer())]
            return res

0

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 9/17/14, 6:01 AM

Try a functional field (store = False), which returns value for your filtering critteria,

then can use this field to filter it in xml

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: 9/17/14, 4:56 AM
Seen: 1030 times
Last updated: 3/16/15, 8:10 AM