Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix t1710 display correspondent field in survival sponsorship #1960

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
)
Loading