Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have two models Parent and Child. In the Parent form I am allowing the user to adding Childs based on the One2Many relation between Parent and Child. Then I need to prevent him from adding more than X number of Childs, how to achieve
I have two models Parent and Child. In the Parent form I am allowing the user to add Childs based on the One2Many relation between Parent and Child. Then I need to prevent from adding more than X number of Childs, how to achieve this?
Right now I am able to check the number of added childs using OnChange(). and the alert message appears to the user that he acceded the limit of childs.
Assume the limit is 3 childs, how can I do the following:
After adding the 4 childs, show alert message (this already done), then delete the last added child(s) that acceds the limit
Or, once childs max limit achieved, hide the "Add an Item" link
Hi Abu Faisal,
Should you create a pythonic constrain @api.constrains('One2many') and do a check on One2many field length using len() and raise warning.
Something like this, https://github.com/odoo/odoo/blob/9.0/addons/account/models/account_invoice.py#L1236
len(self.One2many_field) would give you records number and then you can raise warning.
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 2/28/16, 10:39 AM|
|Seen: 683 times|
|Last updated: 2/29/16, 1:39 AM|