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

Is it Possible to write two domain for one field(in py file and xml file)??

By
Saravanan Sakthivel
on 7/1/14, 3:30 AM 1,171 views

For Example,

By default domain for jornnal_id in invoice is written in invoice py file(_get_journal()).But i need to add one more domain (domestic/export) journal.I have added in xml but its not working because default function calling.

Because i need to generate sequence based on journal in multi-company concept.

can any one help me????? 

0

Prakash

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

OpenERP Devloper at SunARC Technology

Prakash
On 7/1/14, 5:09 AM

In Custom Module inherit the field using replace tag add default code. In the same code additional add your domains. i.e Single field two or more domain (default openerp domain and your custom domain) condition And or OR based on your requirement.

0
Saravanan Sakthivel
On 7/1/14, 6:04 AM

Yeah That is fine.

But by default they have written two domains in python field.i need to customize that field in xml.how can i write??

def _get_journal(self, cr, uid, context=None):
        if context is None:
            context = {}
        type_inv = context.get('type', 'out_invoice')
        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
        company_id = context.get('company_id', user.company_id.id)
        type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'}
        journal_obj = self.pool.get('account.journal')
        domain = [('company_id', '=', company_id)]
        if isinstance(type_inv, list):
            domain.append(('type', 'in', [type2journal.get(type) for type in type_inv if type2journal.get(type)]))
        else:
            domain.append(('type', '=', type2journal.get(type_inv, 'sale')))
        res = journal_obj.search(cr, uid, domain, limit=1)
        return res and res[0] or False

 

i need to add one domain in xml...

<field name="journal_id" groups="account.group_account_user"
                                on_change="onchange_journal_id(journal_id, context)"  domain="[('seq_type', '=', seq_type),]"/>.

i added seq type field in both invoice form and journal form.based on this i am checking domain,but its not working????

oh.. code seems correct have u checked the seq_type value in db?..

Prakash
on 7/1/14, 7:16 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

1 follower(s)

Stats

Asked: 7/1/14, 3:30 AM
Seen: 1171 times
Last updated: 3/16/15, 8:10 AM