mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX]:pms compute impacts quota reservation line
This commit is contained in:
@@ -81,7 +81,7 @@ class PmsAvailabilityPlan(models.Model):
|
||||
)
|
||||
|
||||
@api.model
|
||||
def update_quota(self, pricelist_id, room_type_id, date, line):
|
||||
def update_quota(self, pricelist_id, room_type_id, date, impacts_quota_id=False):
|
||||
if pricelist_id and room_type_id and date:
|
||||
rule = self.env["pms.availability.plan.rule"].search(
|
||||
[
|
||||
@@ -96,19 +96,19 @@ class PmsAvailabilityPlan(models.Model):
|
||||
if rule and rule.quota != -1 and rule.quota > 0:
|
||||
|
||||
# the line has no rule item applied before
|
||||
if not line.impacts_quota:
|
||||
if not impacts_quota_id:
|
||||
rule.quota -= 1
|
||||
return rule.id
|
||||
|
||||
# the line has a rule item applied before
|
||||
elif line.impacts_quota != rule.id:
|
||||
elif impacts_quota_id != rule.id:
|
||||
|
||||
# decrement quota on current rule item
|
||||
rule.quota -= 1
|
||||
|
||||
# check old rule item
|
||||
old_rule = self.env["pms.availability.plan.rule"].search(
|
||||
[("id", "=", line.impacts_quota)]
|
||||
[("id", "=", impacts_quota_id)]
|
||||
)
|
||||
|
||||
# restore quota in old rule item
|
||||
@@ -118,9 +118,9 @@ class PmsAvailabilityPlan(models.Model):
|
||||
return rule.id
|
||||
|
||||
# in any case, check old rule item
|
||||
if line.impacts_quota:
|
||||
if impacts_quota_id:
|
||||
old_rule = self.env["pms.availability.plan.rule"].search(
|
||||
[("id", "=", line.impacts_quota)]
|
||||
[("id", "=", impacts_quota_id)]
|
||||
)
|
||||
# and restore quota in old rule item
|
||||
if old_rule:
|
||||
|
||||
Reference in New Issue
Block a user