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 product type with an onchange method

By
Juan
on 8/9/16, 4:35 AM 178 views

Hi, i'm trying to make products packs, so I made a boolean button in the product to check if the product is a pack, now i want to make an onchange to change the type of the prodcut to service if pack checkbox is true. I'm trying with this but is not working.


class product_template(models.Model):
_inherit = 'product.template'
    pack = fields.Boolean('Pack?')

api.onchange('pack')
def _onchange_pack(self):
    if self.pack:
        self.type = 'service'


1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 8/9/16, 5:14 AM

Hi,

Try to make the on change function in the product.product model. Also it will be helpful if you put the error msg and your version ...


I don't have any error, it does nothing, is in V8. I'll try to do it in the product.product and see if it works.

Juan
on 8/9/16, 5:23 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: 8/9/16, 4:35 AM
Seen: 178 times
Last updated: 8/22/16, 6:40 AM