Skip to content

Commit

Permalink
T1710 Add survival sponsorship correspondent
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordack authored and ecino committed Sep 30, 2024
1 parent 72cd8eb commit 996763d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sponsorship_compassion/views/sponsorship_contract_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<field
name="correspondent_id"
options="{'create': false, 'm2o_dialog': false}"
attrs="{'invisible':[('type', 'not in', ['S','SC','SWP'])], 'required': [('type', 'in', ['S', 'SC','SWP'])]}"
attrs="{'invisible':[('type', 'not in', ['S','SC','SWP','CSP'])], 'required': [('type', 'in', ['S', 'SC','SWP','CSP'])]}"
/>
<field name="send_gifts_to" />
</field>
Expand Down
1 change: 1 addition & 0 deletions survival_sponsorship_compassion/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import res_config_settings
from . import recurring_contract_line
from . import wordpress_configuration
from . import res_partner
37 changes: 37 additions & 0 deletions survival_sponsorship_compassion/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from odoo import models


class ResPartner(models.Model):
_inherit = "res.partner"

def _compute_related_contracts(self):
super()._compute_related_contracts()
contract_obj = self.env["recurring.contract"]
for partner in self:
partner.contracts_correspondant += contract_obj.search(
[
("correspondent_id", "=", partner.id),
("type", "=", "CSP"),
("fully_managed", "=", False),
],
order="start_date desc",
)
partner.contracts_paid += contract_obj.search(
[
("partner_id", "=", partner.id),
("type", "=", "CSP"),
("fully_managed", "=", False),
],
order="start_date desc",
)
partner.contracts_fully_managed += contract_obj.search(
[
("partner_id", "=", partner.id),
("type", "=", "CSP"),
("fully_managed", "=", True),
],
order="start_date desc",
)
partner.other_contract_ids = partner.other_contract_ids.filtered(
lambda c: c.type != "CSP"
)

0 comments on commit 996763d

Please sign in to comment.