55
66import logging
77
8+ import odoo
89from odoo import api , fields , models
910
1011_logger = logging .getLogger (__name__ )
@@ -23,15 +24,21 @@ class PosOrder(models.Model):
2324 @api .model
2425 def _send_order_cron (self ):
2526 _logger .info ("------------------------------------------------------" )
26- mail_template = self .env .ref ("pos_ticket_send_by_mail.email_send_pos_receipt" )
27+ mail_template = self .env .ref (
28+ "pos_ticket_send_by_mail.email_send_pos_receipt" ,
29+ raise_if_not_found = False ,
30+ )
31+ if not mail_template .exists ():
32+ _logger .warning ("No mail template found for sending ticket" )
33+ return
2734 _logger .info ("Start to send ticket" )
2835 for order in self .search ([("email_status" , "=" , "to_send" )]):
2936 mail_template .send_mail (order .id , force_send = True )
3037 order .email_status = "sent"
3138 # Make sure we commit the change to not send ticket twice
32- self .env .cr .commit ()
39+ if not odoo .tools .config ["test_enable" ]:
40+ self .env .cr .commit () # pylint: disable=E8102
3341
34- @api .multi
3542 def action_pos_order_paid (self ):
3643 # Send e-receipt for the partner.
3744 # It depends on value of the field `receipt_option`
@@ -43,8 +50,7 @@ def action_pos_order_paid(self):
4350 return res
4451
4552 def _set_order_to_send (self ):
46- icp_sudo = self .env ["ir.config_parameter" ].sudo ()
47- receipt_options = icp_sudo .get_param ("point_of_sale.receipt_options" )
53+ receipt_options = self .config_id .receipt_options
4854 receipt_options = receipt_options and int (receipt_options ) or False
4955 for order in self :
5056 if (
0 commit comments