33# @author: La Louve
44# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html
55
6- from odoo import models , fields , api
76import logging
7+
8+ from odoo import api , fields , models
9+
810_logger = logging .getLogger (__name__ )
911
1012
1113class PosOrder (models .Model ):
12- _inherit = ' pos.order'
14+ _inherit = " pos.order"
1315
14- email_status = fields .Selection ([
15- ('no_send' , 'Do not Send' ),
16- ('to_send' , 'To send' ),
17- ('sent' , 'Sent' )],
18- default = "no_send" , copy = False , string = "Send Status" )
16+ email_status = fields .Selection (
17+ [("no_send" , "Do not Send" ), ("to_send" , "To send" ), ("sent" , "Sent" )],
18+ default = "no_send" ,
19+ copy = False ,
20+ string = "Send Status" ,
21+ )
1922
2023 @api .model
2124 def _send_order_cron (self ):
2225 _logger .info ("------------------------------------------------------" )
23- mail_template = self .env .ref (
24- "pos_ticket_send_by_mail.email_send_pos_receipt" )
26+ mail_template = self .env .ref ("pos_ticket_send_by_mail.email_send_pos_receipt" )
2527 _logger .info ("Start to send ticket" )
26- for order in self .search ([(' email_status' , '=' , ' to_send' )]):
28+ for order in self .search ([(" email_status" , "=" , " to_send" )]):
2729 mail_template .send_mail (order .id , force_send = True )
28- order .email_status = ' sent'
30+ order .email_status = " sent"
2931 # Make sure we commit the change to not send ticket twice
3032 self .env .cr .commit ()
3133
@@ -36,15 +38,18 @@ def action_pos_order_paid(self):
3638 # that we config in pos.config.settings
3739 # receipt_option = 1: Don't send e-receipt
3840 # receipt_option = 2 or 3: Send e-receipt
39- res = super (PosOrder , self ).action_pos_order_paid ()
41+ res = super ().action_pos_order_paid ()
4042 self ._set_order_to_send ()
4143 return res
4244
4345 def _set_order_to_send (self ):
44- icp_sudo = self .env [' ir.config_parameter' ].sudo ()
45- receipt_options = icp_sudo .get_param (' point_of_sale.receipt_options' )
46+ icp_sudo = self .env [" ir.config_parameter" ].sudo ()
47+ receipt_options = icp_sudo .get_param (" point_of_sale.receipt_options" )
4648 receipt_options = receipt_options and int (receipt_options ) or False
4749 for order in self :
48- if receipt_options in [2 , 3 , 4 ] and order .partner_id .email and \
49- not order .partner_id .no_email_pos_receipt :
50- order .email_status = 'to_send'
50+ if (
51+ receipt_options in [2 , 3 , 4 ]
52+ and order .partner_id .email
53+ and not order .partner_id .no_email_pos_receipt
54+ ):
55+ order .email_status = "to_send"
0 commit comments