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 update domain set in fields_view_get?

By
Atchuthan - Technical Consultant, Sodexis Inc
on 6/16/14, 6:46 AM 8,941 views

For instance, take the account_check_writing module, in which we have fields_view_get on account.voucher.  Here a domain is set for journal_id field.

Now, I have another module, in which I need to set domain to domain for journal_id.

Should I set the domain available in account_check_writing in my module, so that both the conditions are satisfied or Is there any other better method to solve this problem.

2

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 6/16/14, 7:06 AM

In the custom module inherit  the class and add fields_view_get method default code with additional add your domain conditions.

Example

class account_voucher(osv.osv):
    _inherit = 'account.voucher'


    def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
        """
            Add domain 'allow_check_writting = True' on journal_id field and remove 'widget = selection' on the same
            field because the dynamic domain is not allowed on such widget
        """
        if not context: context = {}
        res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
        doc = etree.XML(res['arch'])
        nodes = doc.xpath("//field[@name='journal_id']")
        if context.get('write_check', False) :
            for node in nodes:
                node.set('domain', "[('type', '=', 'bank'), ('allow_check_writing','=',True),('your_field','=','value')]")
                node.set('widget', '')
            res['arch'] = etree.tostring(doc)
        return res

yes, I have done added the domain in my own module. But, logically speaking, my new module does not have anything to do with account_check_writing. and I have to add Account Check writing module in the depends. So How to solve this dependency issue?

Atchuthan - Technical Consultant, Sodexis Inc
on 6/17/14, 1:04 AM

If you using account_check_writing module and if you need to change the account_check_writing functionality (domain filter) then override the account_check_writing module fields_view_get method based on your requirement. otherwise create your own fields_view_get method in custom module.

Prakash
on 6/17/14, 3:06 AM

so, I can set domain based on Account check writing module and my own module without adding dependency... Am I right?

Atchuthan - Technical Consultant, Sodexis Inc
on 6/17/14, 3:09 AM

In the custom module if you using _inherit = 'account.voucher' then need to dependency account.voucher in the custom module.

Prakash
on 6/17/14, 3:46 AM

yes, So i have to add account_voucher module in depend instead of account_check_writing

Atchuthan - Technical Consultant, Sodexis Inc
on 6/17/14, 3:47 AM

Yes depend need to add only "account_voucher".

Prakash
on 6/17/14, 4:00 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: 6/16/14, 6:46 AM
Seen: 8941 times
Last updated: 7/10/15, 4:05 AM