commit
767f0048a4
|
|
@ -5,58 +5,55 @@ from odoo.exceptions import AccessError
|
||||||
class AccountPayment(models.Model):
|
class AccountPayment(models.Model):
|
||||||
_inherit = 'account.payment'
|
_inherit = 'account.payment'
|
||||||
|
|
||||||
# def _is_authorized_to_notify(self):
|
def _is_authorized_to_notify(self):
|
||||||
#
|
|
||||||
# user = self.env.user
|
user = self.env.user
|
||||||
#
|
|
||||||
# authorized_groups = [
|
authorized_groups = [
|
||||||
# 'account.group_account_manager',
|
'account.group_account_manager',
|
||||||
# 'account.group_account_invoice',
|
'account.group_account_invoice',
|
||||||
# # 'purchase.group_purchase_manager',
|
# 'purchase.group_purchase_manager',
|
||||||
# ]
|
]
|
||||||
#
|
|
||||||
# for group_xml_id in authorized_groups:
|
for group_xml_id in authorized_groups:
|
||||||
# if user.has_group(group_xml_id):
|
if user.has_group(group_xml_id):
|
||||||
# return True
|
return True
|
||||||
#
|
|
||||||
# return False
|
return False
|
||||||
#
|
|
||||||
# def action_notify_payment(self, payment):
|
def action_notify_payment(self, payment):
|
||||||
# # Check authorization before sending notification
|
# Check authorization before sending notification
|
||||||
# if not self._is_authorized_to_notify():
|
if not self._is_authorized_to_notify():
|
||||||
# return
|
return
|
||||||
#
|
|
||||||
# # Prepare notification content
|
# Prepare notification content
|
||||||
# subject = _('Payment Notification') + ' - {}'.format(payment.partner_id.name)
|
subject = _('Payment Notification') + ' - {}'.format(payment.partner_id.name)
|
||||||
# message = '{} '.format(payment.partner_id.name) + _('is successfully paid.') + '\n' + _(
|
message = '{} '.format(payment.partner_id.name) + _('is successfully paid.') + '\n' + _(
|
||||||
# 'Payment Amount: ') + '{}'.format(payment.amount) + '\n' + _('Ref: ') + '{}'.format(payment.ref) + '\n' + _(
|
'Payment Amount: ') + '{}'.format(payment.amount) + '\n' + _('Ref: ') + '{}'.format(payment.ref) + '\n' + _(
|
||||||
# 'On Date: ') + '{}'.format(payment.date)
|
'On Date: ') + '{}'.format(payment.date)
|
||||||
#
|
|
||||||
# # Get recipients from the notification group, excluding purchase managers
|
# Get recipients from the notification group only
|
||||||
# recipient_group = self.env.ref('purchase_requisition_custom.group_receive_payment_notification')
|
recipient_group = self.env.ref('purchase_requisition_custom.group_receive_payment_notification')
|
||||||
# excluded_group = self.env.ref('purchase.group_purchase_manager')
|
|
||||||
#
|
# Get all users from the notification group without any exclusions
|
||||||
# # Filter out users who belong to the excluded group
|
partner_ids = recipient_group.users.mapped('partner_id').ids
|
||||||
# partner_ids = recipient_group.users.filtered(
|
|
||||||
# lambda u: u not in excluded_group.users
|
# Send notification only to filtered recipients
|
||||||
# ).mapped('partner_id').ids
|
if partner_ids:
|
||||||
#
|
author_id = self.env.user.partner_id.id or None
|
||||||
# # Send notification only to filtered recipients
|
self.env.user.partner_id.message_post(
|
||||||
# if partner_ids:
|
type="notification",
|
||||||
# author_id = self.env.user.partner_id.id or None
|
subject=subject,
|
||||||
# self.env.user.partner_id.message_post(
|
body=message,
|
||||||
# type="notification",
|
author_id=author_id,
|
||||||
# subject=subject,
|
partner_ids=partner_ids,
|
||||||
# body=message,
|
subtype_xmlid="mail.mt_comment"
|
||||||
# author_id=author_id,
|
)
|
||||||
# partner_ids=partner_ids,
|
|
||||||
# subtype_xmlid="mail.mt_comment"
|
@api.model
|
||||||
# )
|
def create(self, vals):
|
||||||
#
|
res = super(AccountPayment, self).create(vals)
|
||||||
# @api.model
|
# print("Hi payment!", res.amount)
|
||||||
# def create(self, vals):
|
self.action_notify_payment(res)
|
||||||
# res = super(AccountPayment, self).create(vals)
|
|
||||||
# # print("Hi payment!", res.amount)
|
return res
|
||||||
# self.action_notify_payment(res)
|
|
||||||
#
|
|
||||||
# return res
|
|
||||||
|
|
|
||||||
|
|
@ -7,61 +7,58 @@ class AccountPayment(models.Model):
|
||||||
|
|
||||||
_inherit = 'account.payment'
|
_inherit = 'account.payment'
|
||||||
|
|
||||||
# def _is_authorized_to_notify(self):
|
def _is_authorized_to_notify(self):
|
||||||
# """
|
"""
|
||||||
# Check if the current user is authorized to send payment notifications.
|
Check if the current user is authorized to send payment notifications.
|
||||||
# Returns True if user belongs to authorized groups.
|
Returns True if user belongs to authorized groups.
|
||||||
# """
|
"""
|
||||||
# user = self.env.user
|
user = self.env.user
|
||||||
#
|
|
||||||
# # Define authorized groups (users who can send payment notifications)
|
# Define authorized groups (users who can send payment notifications)
|
||||||
# authorized_groups = [
|
authorized_groups = [
|
||||||
# 'account.group_account_manager', # Account Manager
|
'account.group_account_manager', # Account Manager
|
||||||
# 'account.group_account_invoice', # Billing/Invoicing
|
'account.group_account_invoice', # Billing/Invoicing
|
||||||
# # 'purchase.group_purchase_manager', # Purchase Manager - Excluded
|
# 'purchase.group_purchase_manager', # Purchase Manager - Excluded
|
||||||
# ]
|
]
|
||||||
#
|
|
||||||
# # Check if user belongs to any authorized group
|
# Check if user belongs to any authorized group
|
||||||
# for group_xml_id in authorized_groups:
|
for group_xml_id in authorized_groups:
|
||||||
# if user.has_group(group_xml_id):
|
if user.has_group(group_xml_id):
|
||||||
# return True
|
return True
|
||||||
#
|
|
||||||
# return False
|
return False
|
||||||
#
|
|
||||||
# def action_notify_payment(self, payment):
|
def action_notify_payment(self, payment):
|
||||||
# # Check authorization before sending notification
|
# Check authorization before sending notification
|
||||||
# if not self._is_authorized_to_notify():
|
if not self._is_authorized_to_notify():
|
||||||
# return
|
return
|
||||||
#
|
|
||||||
# # Prepare notification content
|
# Prepare notification content
|
||||||
# subject = _('Payment Notification') + ' - {}'.format(payment.partner_id.name)
|
subject = _('Payment Notification') + ' - {}'.format(payment.partner_id.name)
|
||||||
# message = '{} '.format(payment.partner_id.name) + _('is successfully paid.') + '\n' + _('Payment Amount: ') + '{}'.format(payment.amount) + '\n' + _('Ref: ') + '{}'.format(payment.ref) + '\n' + _('On Date: ') + '{}'.format(payment.date)
|
message = '{} '.format(payment.partner_id.name) + _('is successfully paid.') + '\n' + _('Payment Amount: ') + '{}'.format(payment.amount) + '\n' + _('Ref: ') + '{}'.format(payment.ref) + '\n' + _('On Date: ') + '{}'.format(payment.date)
|
||||||
#
|
|
||||||
# # Get recipients from the notification group, excluding purchase managers
|
# Get recipients from the notification group only
|
||||||
# recipient_group = self.env.ref('purchase_requisition_custom.group_receive_payment_notification')
|
recipient_group = self.env.ref('purchase_requisition_custom.group_receive_payment_notification')
|
||||||
# excluded_group = self.env.ref('purchase.group_purchase_manager')
|
|
||||||
#
|
# Get all users from the notification group without any exclusions
|
||||||
# # Filter out users who belong to the excluded group
|
partner_ids = recipient_group.users.mapped('partner_id').ids
|
||||||
# partner_ids = recipient_group.users.filtered(
|
|
||||||
# lambda u: u not in excluded_group.users
|
# Send notification only to filtered recipients
|
||||||
# ).mapped('partner_id').ids
|
if partner_ids:
|
||||||
#
|
author_id = self.env.user.partner_id.id or None
|
||||||
# # Send notification only to filtered recipients
|
self.env.user.partner_id.message_post(
|
||||||
# if partner_ids:
|
type="notification",
|
||||||
# author_id = self.env.user.partner_id.id or None
|
subject=subject,
|
||||||
# self.env.user.partner_id.message_post(
|
body=message,
|
||||||
# type="notification",
|
author_id=author_id,
|
||||||
# subject=subject,
|
partner_ids=partner_ids,
|
||||||
# body=message,
|
subtype_xmlid="mail.mt_comment"
|
||||||
# author_id=author_id,
|
)
|
||||||
# partner_ids=partner_ids,
|
|
||||||
# subtype_xmlid="mail.mt_comment"
|
@api.model
|
||||||
# )
|
def create(self, vals):
|
||||||
#
|
res = super(AccountPayment, self).create(vals)
|
||||||
# @api.model
|
# print("Hi payment!", res.amount)
|
||||||
# def create(self, vals):
|
self.action_notify_payment(res)
|
||||||
# res = super(AccountPayment, self).create(vals)
|
|
||||||
# # print("Hi payment!", res.amount)
|
return res
|
||||||
# self.action_notify_payment(res)
|
|
||||||
#
|
|
||||||
# return res
|
|
||||||
Loading…
Reference in New Issue