Skip to content

Commit ba02670

Browse files
Merge branch 'develop' into bytes-fix
2 parents 50e014f + 8144b42 commit ba02670

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

cypress/integration/depends_on.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
context('Depends On', () => {
2+
beforeEach(() => {
3+
cy.login();
4+
cy.visit('/desk');
5+
});
26
before(() => {
37
cy.login();
48
cy.visit('/desk');
@@ -49,6 +53,7 @@ context('Depends On', () => {
4953
cy.get('.control-input [data-fieldname="dependant_field"]').should('not.be.disabled');
5054
});
5155
it('should display the field depending on other fields value', () => {
56+
cy.new_form('Test Depends On');
5257
cy.get('.control-input [data-fieldname="display_dependant_field"]').should('not.be.visible');
5358
cy.get('.control-input [data-fieldname="test_field"]').clear();
5459
cy.fill_field('test_field', 'Value');

frappe/automation/doctype/auto_repeat/auto_repeat.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from frappe.utils.jinja import validate_template
1010
from dateutil.relativedelta import relativedelta
1111
from frappe.utils.user import get_system_managers
12-
from frappe.utils import cstr, getdate, split_emails, add_days, today, get_last_day, get_first_day
12+
from frappe.utils import cstr, getdate, split_emails, add_days, today, get_last_day, get_first_day, month_diff
1313
from frappe.model.document import Document
1414
from frappe.core.doctype.communication.email import make
1515
from frappe.utils.background_jobs import get_jobs
@@ -48,7 +48,7 @@ def set_dates(self):
4848
if self.disabled:
4949
self.next_schedule_date = None
5050
else:
51-
self.next_schedule_date = get_next_schedule_date(self.start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, self.end_date)
51+
self.next_schedule_date = get_next_schedule_date(self.start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, self.end_date)
5252

5353
def unlink_if_applicable(self):
5454
if self.status == 'Completed' or self.disabled:
@@ -107,27 +107,27 @@ def get_auto_repeat_schedule(self):
107107
end_date = getdate(self.end_date)
108108

109109
if not self.end_date:
110-
start_date = get_next_schedule_date(start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day)
110+
next_date = get_next_schedule_date(start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day)
111111
row = {
112112
"reference_document": self.reference_document,
113113
"frequency": self.frequency,
114-
"next_scheduled_date": start_date
114+
"next_scheduled_date": next_date
115115
}
116116
schedule_details.append(row)
117-
start_date = get_next_schedule_date(start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day)
118117

119118
if self.end_date:
120-
start_date = get_next_schedule_date(
121-
start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, for_full_schedule=True)
122-
while (getdate(start_date) < getdate(end_date)):
119+
next_date = get_next_schedule_date(
120+
start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, for_full_schedule=True)
121+
122+
while (getdate(next_date) < getdate(end_date)):
123123
row = {
124124
"reference_document" : self.reference_document,
125125
"frequency" : self.frequency,
126-
"next_scheduled_date" : start_date
126+
"next_scheduled_date" : next_date
127127
}
128128
schedule_details.append(row)
129-
start_date = get_next_schedule_date(
130-
start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, end_date, for_full_schedule=True)
129+
next_date = get_next_schedule_date(
130+
next_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, end_date, for_full_schedule=True)
131131

132132
return schedule_details
133133

@@ -268,8 +268,12 @@ def notify_error_to_user(self, error_log):
268268
)
269269

270270

271-
def get_next_schedule_date(start_date, frequency, repeat_on_day, repeat_on_last_day=False, end_date=None, for_full_schedule=False):
272-
month_count = month_map.get(frequency)
271+
def get_next_schedule_date(schedule_date, frequency, start_date, repeat_on_day=None, repeat_on_last_day=False, end_date=None, for_full_schedule=False):
272+
if month_map.get(frequency):
273+
month_count = month_map.get(frequency) + month_diff(schedule_date, start_date) - 1
274+
else:
275+
month_count = 0
276+
273277
day_count = 0
274278
if month_count and repeat_on_last_day:
275279
next_date = get_next_date(start_date, month_count, 31)
@@ -288,7 +292,9 @@ def get_next_schedule_date(start_date, frequency, repeat_on_day, repeat_on_last_
288292
# next schedule date should be after or on current date
289293
if not for_full_schedule:
290294
while getdate(next_date) < getdate(today()):
291-
next_date = get_next_date(next_date, month_count, day_count)
295+
if month_count:
296+
month_count += month_map.get(frequency)
297+
next_date = get_next_date(start_date, month_count, day_count)
292298

293299
return next_date
294300

@@ -316,8 +322,7 @@ def create_repeated_entries(data):
316322

317323
if schedule_date == current_date and not doc.disabled:
318324
doc.create_documents()
319-
schedule_date = get_next_schedule_date(schedule_date, doc.frequency, doc.repeat_on_day, doc.repeat_on_last_day, doc.end_date)
320-
325+
schedule_date = get_next_schedule_date(schedule_date, doc.frequency, doc.start_date, doc.repeat_on_day, doc.repeat_on_last_day, doc.end_date)
321326
if schedule_date and not doc.disabled:
322327
frappe.db.set_value('Auto Repeat', doc.name, 'next_schedule_date', schedule_date)
323328

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pdfkit==0.6.1
3535
Pillow==6.2.1
3636
premailer==3.6.1
3737
psycopg2-binary==2.8.4
38-
psycopg2==2.8.4
3938
pyasn1==0.4.7
4039
Pygments==2.2.0
4140
PyJWT==1.7.1
@@ -64,4 +63,4 @@ urllib3==1.25.7
6463
watchdog==0.8.0
6564
Werkzeug==0.16.0
6665
xlrd==1.2.0
67-
zxcvbn-python==4.4.24
66+
zxcvbn-python==4.4.24

0 commit comments

Comments
 (0)