@@ -60,7 +60,7 @@ def _pull(self, date_since, date_until):
60
60
def _ponto_pull (self , date_since , date_until ):
61
61
"""Translate information from Ponto to Odoo bank statement lines."""
62
62
self .ensure_one ()
63
- is_scheduled = self .env .context .get ("scheduled" )
63
+ is_scheduled = self .env .context .get ("scheduled" , False )
64
64
if is_scheduled :
65
65
_logger .debug (
66
66
_ (
@@ -97,12 +97,12 @@ def _ponto_retrieve_data(self, date_since, date_until):
97
97
Note: when reading data they are likely to be in descending order of
98
98
execution_date (not seen a guarantee for this in Ponto API). When using
99
99
value date, they may well be out of order. So we cannot simply stop
100
- when we have foundd a transaction date before the date_since.
100
+ when we have found a transaction date before the date_since.
101
101
102
102
We will not read transactions more then a week before before date_since.
103
103
"""
104
104
date_stop = date_since - timedelta (days = 7 )
105
- is_scheduled = self .env .context .get ("scheduled" )
105
+ is_scheduled = self .env .context .get ("scheduled" , False )
106
106
lines = []
107
107
interface_model = self .env ["ponto.interface" ]
108
108
access_data = interface_model ._login (self .username , self .password )
@@ -113,15 +113,21 @@ def _ponto_retrieve_data(self, date_since, date_until):
113
113
for line in transactions :
114
114
identifier = line .get ("id" )
115
115
transaction_datetime = self ._ponto_get_transaction_datetime (line )
116
- if (is_scheduled and identifier == self .ponto_last_identifier ) or (
117
- transaction_datetime < date_stop
118
- and (not self .ponto_last_identifier or not is_scheduled )
119
- ):
120
- return lines
121
- if not is_scheduled :
122
- if transaction_datetime < date_since :
116
+ if is_scheduled :
117
+ # Handle all stop conditions for scheduled runs.
118
+ if identifier == self .ponto_last_identifier or (
119
+ not self .ponto_last_identifier
120
+ and transaction_datetime < date_stop
121
+ ):
123
122
return lines
124
- if transaction_datetime > date_until :
123
+ else :
124
+ # Handle stop conditions for non scheduled runs.
125
+ if transaction_datetime < date_stop :
126
+ return lines
127
+ if (
128
+ transaction_datetime < date_since
129
+ or transaction_datetime > date_until
130
+ ):
125
131
continue
126
132
line ["transaction_datetime" ] = transaction_datetime
127
133
lines .append (line )
0 commit comments