1

I want to limit the quantity of "Order lines" to 2 products only (When 2 products are loaded, I want the "Add a Product", "Add a section" and "Add a note" buttons to disappear automatically).

I tried to use an @api.constrains but it only validates when I click Save button.

enter image description here

Itai Klapholtz
  • 196
  • 1
  • 2
  • 15
odoo newbie
  • 179
  • 10

2 Answers2

1

Solved

@api.onchange('reservation_line')
def _onchange_check_cabanias(self):
    if len(self.reservation_line) > 1:
        raise ValidationError("Only one habitation per reserve is allowed")
odoo newbie
  • 179
  • 10
0

try to add readonly = True in relation field to make it cant editable

Denny
  • 3
  • 3