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.

2

How to remove a validation / constraint?

By
neil mcguigan
on 6/10/13, 9:12 PM 4,408 views

There is a validation rule on BOM , such that the same product cannot be in a BOM more than once. I would like to allow this

(see question http://help.openerp.com/question/20560/bom-that-allows-for-repeating-the-same-product-or-show-the-assembly-of-the-product/ )

Is there an easy way to remove this validation / constraint? Will it screw up other things?

Thanks

0

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/10/13, 9:59 PM

Hi,

the only way to manage your case this is a comment line of Python code :

in file mrp/mrp.py line 264 :

  262.  _constraints = [
  263.   (_check_recursion, 'Error ! You cannot create recursive BoM.', ['parent_id']),
  264.  #(_check_product, 'BoM line product should not be same as BoM product.', ['product_id']),
         ]

but it is not professional, the best way is to create a new module to do that

5

Yannick Vaucher

--Yannick Vaucher--
1699
| 5 7 9
Lausanne, Switzerland
--Yannick Vaucher--
Yannick Vaucher
On 6/25/14, 6:33 AM

To redefine a python constraint, you can override it by setting the same method function name:

In a module puts:

 

    class mrp_bom(orm.Model):

        _inherit = 'mrp.bom'

 

        def _check_product(self, cr, uid, ids, context=None):

            return True

 

        _constraints = [(_check_product, 'Override of _check_product constraint', ['product_id'])]

 

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

0 follower(s)

Stats

Asked: 6/10/13, 9:12 PM
Seen: 4408 times
Last updated: 3/16/15, 8:10 AM