def test_reminder_1(self): """Set to send reminder today, check if a reminder can be send to the partner. """ po = Form(self.env['purchase.order']) po.partner_id = self.partner_a with po.order_line.new() as po_line: po_line.product_id = self.product_a po_line.product_qty = 1 po_line.price_unit = 100 with po.order_line.new() as po_line: po_line.product_id = self.product_b po_line.product_qty = 10 po_line.price_unit = 200 # set to send reminder today po.date_planned = fields.Datetime.now() + timedelta(days=1) po.receipt_reminder_email = True po.reminder_date_before_receipt = 1 po = po.save() po.button_confirm() # check vendor is a message recipient self.assertTrue(po.partner_id in po.message_partner_ids) old_messages = po.message_ids po._send_reminder_mail() messages_send = po.message_ids - old_messages # check reminder send self.assertTrue(messages_send) self.assertTrue(po.partner_id in messages_send.mapped('partner_ids')) # check confirm button po.confirm_reminder_mail() self.assertTrue(po.mail_reminder_confirmed)
def test_reminder_2(self): """Set to send reminder tomorrow, check if no reminder can be send. """ po = Form(self.env['purchase.order']) po.partner_id = self.vendor with po.order_line.new() as po_line: po_line.product_id = self.product_consu po_line.product_qty = 1 po_line.price_unit = 100 with po.order_line.new() as po_line: po_line.product_id = self.product_consu2 po_line.product_qty = 10 po_line.price_unit = 200 # set to send reminder tomorrow po.date_planned = fields.Datetime.now() + timedelta(days=2) po.receipt_reminder_email = True po.reminder_date_before_receipt = 1 po = po.save() po.button_confirm() # check vendor is a message recipient self.assertTrue(po.partner_id in po.message_partner_ids) old_messages = po.message_ids po._send_reminder_mail() messages_send = po.message_ids - old_messages # check no reminder send self.assertFalse(messages_send)