Python Inheritance ->Exercise
Add business logic to the CRUD methods.
- Prevent deletion of a property if its state is not ‘New’ or ‘Cancelled’
Tip: create a new method with the example)
any help of what self do
vals : data send from form
self : ?????
it's a way to query the data from the data base .
or
it 's have the context send from ui and if it's the context how can i debug or print this object to navigate throw it's member
@api.model_create_multi
def create(self, vals):
for val in vals:
# get estate_property
estate_property = self.env["estate.property"].browse(val["property_id"])
estate_property.state = "offer_Received"
# get list of estate_property_offers from estate_property
estate_property_offers = estate_property.offer_ids
new_val = val["price"]
max_all_value_before_save = max(estate_property_offers.mapped("price"), default=0.0)
if new_val < max_all_value_before_save:
raise UserError("Price must bigger than the highest offers")
return super().create(vals)
thank u Chathura , your answer help me lot