Lot Expiration is checked when life state is set to None
Configuration
- Create product. Select "Shelf Life Time State" to optional.
- Create a lot and select a date in the past (before today) in "Shelf Life Expiration Date" field.
- Create a shipment, production... and select in the moves, product and lot.
Scenario A
- When do a move, a validation raise in check_expiration_dates() because to_check_expiration() method return True [1]. It's ok.
Scenario B
- Go to the product, and change "Shelf Life Time State" to "none".
- Refresh lot form view. "Shelf Life Expiration Date" is now invisible.
- In case try do the move, continue raise the error from Scenario A.
Proposal
Check value option in shelf_life_state product in to_check_expiration() method.
@property
def to_check_expiration(self):
if (self.lot
+ and self.product.shelf_life_state != 'none'
and self.lot.shelf_life_expiration_date
and self.effective_date > self.lot.shelf_life_expiration_date):
return True
return False