Skip to content

[IMP] academic_sale_subscription: add payment_portal controller, and … #278

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

Closed
wants to merge 1 commit into from
Closed
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 academic_sale_subscription/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Academic Sale Subscription",
"version": "18.0.1.5.0",
"version": "18.0.1.6.0",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
Expand Down
1 change: 1 addition & 0 deletions academic_sale_subscription/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import portal_account
from . import customer_portal
from . import payment_portal
15 changes: 15 additions & 0 deletions academic_sale_subscription/controllers/payment_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo.addons.payment.controllers import portal as payment_portal


class PaymentPortal(payment_portal.PaymentPortal):
def _get_subscription_domain(self, partner):
res = super()._get_subscription_domain(partner)
for domain_tuple in res:
if len(domain_tuple) == 3 and domain_tuple[0] == "subscription_state" and domain_tuple[1] == "in":
states = list(domain_tuple[2])
if "1_draft" not in states:
states.append("1_draft")
index = res.index(domain_tuple)
res[index] = ("subscription_state", "in", states)
break
return res
14 changes: 8 additions & 6 deletions academic_sale_subscription/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ def _prepare_invoice(self):
res["student_id"] = self.partner_id.id
return res

def action_confirm(self):
for rec in self.filtered("is_academic_sale"):
rec.message_subscribe(
@api.model_create_multi
def create(self, vals_list):
orders = super().create(vals_list)
for order in orders.filtered("is_academic_sale"):
order.message_subscribe(
[
payment_responsible.id
for payment_responsible in rec.partner_invoice_id | rec.partner_invoice_ids
if payment_responsible not in rec.sudo().message_partner_ids
for payment_responsible in order.partner_invoice_id | order.partner_invoice_ids
if payment_responsible not in order.sudo().message_partner_ids
]
)
return super().action_confirm()
return orders

def _message_get_default_recipients(self):
"""Por defecto las plantillas mandan a partner_id pero para nosotros el partners es el estudiante.
Expand Down