跳至內容
選單
此問題已被標幟
1 回覆
650 瀏覽次數

Hello, 

I want to send an email for the customer after the payment is created,

I tried to use this but not worked

class AccountPaymentRegisterInherit(models.TransientModel):
_inherit = 'account.payment.register'

def action_create_payments(self):

payment_records = super(AccountPaymentRegisterInherit, self).action_create_payments()

payments = self.env['account.payment'].search([('id', 'in', payment_records.ids)])

for payment in payments:
email_template = self.env.ref('plnx_membership.email_template_register_payment', raise_if_not_found=False)
if email_template:
email_template.send_mail(payment.id, force_send=True)

return payment_records
def write(self, vals):
result = super(AccountMove, self).write(vals)
for record in self:
if vals.get('payment_state') == 'paid' and record.payment_state == 'paid':


email_template = self.env.ref(
'plnx_membership.email_template_payment_registered')
if email_template:
email_template.send_mail(record.id, force_send=True)

return result
頭像
捨棄
最佳答案
class AccountPayment(models.Model):
_inherit = "account.payment"

def action_post(self):
res = super(AccountPayment, self).action_post()

for payment in self:

# Use email code here

return res


Hi, better to use model account.payment to send automated email instead of account.payment.register model

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
5月 25
96
0
1月 25
416
2
4月 25
237
1
2月 25
391
3
2月 25
595