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

How to work onchange functionality only for Customer creation form not for Supplier creation form ?

By
babu
on 2/23/15, 6:49 AM 502 views

Hello Team,

I was added an onchange field to customer form, but it is need work for customer form not for Supplier form.here field will visible in both forms, but i need the onchange functionality work for only Customers creation form not for Suppliers creation form. How can i acheve this.

Can anyone please guide me.

Thanks in advance.

2
Mansi Kariya (mka)
On 2/23/15, 7:08 AM

hello,

while calling on change check whether partner is customer then only execute your code. As customer and supplier form, Both shares same object

You can eitehr add customer field to your onchange and check whether you are getting that field and accordingly execute or update context by passing customer field and check on your onchange method.

Here change for your xml , on_change="onchange_zipcode(zip, customer)

and in onchange method,

    def onchange_zipcode(self, cr, uid, ids, zip, customer, context=None):
        res = {}
        if not customer:
            return res
        #Execute your code, This code will be executed only if customer is set to true

 

Hope this will help you.

 

Thanks a lot mansi, it's work perfectly..

babu
on 2/23/15, 8:20 AM

Hello Mansi, I have one more doubt, if supplier has zip code need to get default supplier zip how can i do this. can you suggest me.

babu
on 2/23/15, 9:39 AM
0
babu
On 2/23/15, 7:15 AM

Hi Mansi,

        <field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}" on_change="onchange_zipcode(zip)"/>

The above field need to work in Customer Creation. Is there need to change anything.

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: 2/23/15, 6:49 AM
Seen: 502 times
Last updated: 3/16/15, 8:10 AM