Skip to content

Commit

Permalink
Update contracts.py (#1971)
Browse files Browse the repository at this point in the history
* Update contracts.py

avoid to generate infinitely gift/christmas invoices when there are correspondent AND send_gift is set to correspondent

* Update contracts.py
  • Loading branch information
davidwul authored Sep 30, 2024
1 parent 72cd8eb commit 9f07723
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sponsorship_compassion/models/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,11 +1099,17 @@ def _generate_gifts(self, invoicer, gift_type):
# checks if there is already a gift for this year which has been cancelled
gift_this_year = self.env["account.move.line"].search(
[
("partner_id", "=", contract.partner_id.id),
("product_id", "=", product_id),
("date", ">=", start_of_year),
("date", "<=", end_of_year),
("contract_id", "=", contract.id),
"|",
"&",
("partner_id", "=", contract.correspondent_id.id),
("contract_id.send_gifts_to", "=", "correspondent_id"),
"&",
("partner_id", "=", contract.partner_id.id),
("contract_id.send_gifts_to", "=", "partner_id"),
]
)
if gift_this_year:
Expand Down

0 comments on commit 9f07723

Please sign in to comment.