Skip to content

Commit

Permalink
connector now sets the current date + black + use 2030/12/31 instead …
Browse files Browse the repository at this point in the history
…of 2030/01/01
  • Loading branch information
jdetaeye committed Jan 12, 2024
1 parent 20036fa commit 335d3c8
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions frepple/controllers/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def run(self):
yield '<plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" source="odoo_%s">\n' % self.mode
yield "<description>Generated by odoo %s</description>\n" % odoo.release.version

self.currentdate = datetime.now()
yield "<current>%s</current>" % self.currentdate.strftime("%Y-%m-%dT%H:%M:%S")

# Synchronize users
yield from self.export_users()

Expand Down Expand Up @@ -458,7 +461,7 @@ def export_calendar(self):
resource.calendar.name -> calendar.name (default value is 0)
resource.calendar.attendance.date_from -> calendar bucket start date (or 2020-01-01 if unspecified)
resource.calendar.attendance.date_to -> calendar bucket end date (or 2030-01-01 if unspecified)
resource.calendar.attendance.date_to -> calendar bucket end date (or 2030-12-31 if unspecified)
resource.calendar.attendance.hour_from -> calendar bucket start time
resource.calendar.attendance.hour_to -> calendar bucket end time
resource.calendar.attendance.dayofweek -> calendar bucket day
Expand Down Expand Up @@ -641,12 +644,12 @@ def export_calendar(self):
else (
j["date_to"].strftime("%Y-%m-%dT00:00:00")
if j["date_to"]
else "2030-01-01T00:00:00"
else "2030-12-31T00:00:00"
),
"1" if j["attendance"] else "0",
(2 ** ((int(j["dayofweek"]) + 1) % 7))
if "dayofweek" in j
else (2 ** 7) - 1,
else (2**7) - 1,
priority_attendance if j["attendance"] else priority_leave,
# In odoo, monday = 0. In frePPLe, sunday = 0.
("PT%dM" % round(j["hour_from"] * 60))
Expand All @@ -663,7 +666,7 @@ def export_calendar(self):
else:
# TWO-WEEKS CALENDAR
start = j["date_from"] or datetime(2020, 1, 1)
end = j["date_to"] or datetime(2030, 1, 1)
end = j["date_to"] or datetime(2030, 12, 31)

t = start
while t < end:
Expand All @@ -679,7 +682,7 @@ def export_calendar(self):
"1",
(2 ** ((int(j["dayofweek"]) + 1) % 7))
if "dayofweek" in j
else (2 ** 7) - 1,
else (2**7) - 1,
priority_attendance,
# In odoo, monday = 0. In frePPLe, sunday = 0.
("PT%dM" % round(j["hour_from"] * 60))
Expand Down Expand Up @@ -1547,24 +1550,29 @@ def export_boms(self):
not in self.map_workcenters
):
continue
secondary_workcenter_str += '<load quantity="%f" search=%s><resource name=%s/>%s</load>' % (
1
if not secondary_workcenter["duration"]
or step["time_cycle"] == 0
else secondary_workcenter["duration"]
/ step["time_cycle"],
quoteattr(secondary_workcenter["search_mode"]),
quoteattr(
self.map_workcenters[
secondary_workcenter["workcenter_id"][0]
]
),
(
"<skill name=%s/>"
% quoteattr(secondary_workcenter["skill"][1])
secondary_workcenter_str += (
'<load quantity="%f" search=%s><resource name=%s/>%s</load>'
% (
1
if not secondary_workcenter["duration"]
or step["time_cycle"] == 0
else secondary_workcenter["duration"]
/ step["time_cycle"],
quoteattr(secondary_workcenter["search_mode"]),
quoteattr(
self.map_workcenters[
secondary_workcenter["workcenter_id"][0]
]
),
(
"<skill name=%s/>"
% quoteattr(
secondary_workcenter["skill"][1]
)
)
if secondary_workcenter["skill"]
else "",
)
if secondary_workcenter["skill"]
else "",
)

yield "<suboperation>" '<operation name=%s %spriority="%s" duration_per="%s" xsi:type="operation_time_per">\n' "<location name=%s/>\n" '<loads><load quantity="%f" search=%s><resource name=%s/>%s</load>%s</loads>\n' % (
Expand Down Expand Up @@ -2498,21 +2506,23 @@ def export_orderpoints(self):
if i["product_min_qty"]:
yield """
<calendar name=%s default="0"><buckets>
<bucket start="2000-01-01T00:00:00" end="2030-12-31T00:00:00" value="%s" days="127" priority="998" starttime="PT0M" endtime="PT1440M"/>
<bucket start="%s" end="2030-12-31T00:00:00" value="%s" days="127" priority="998" starttime="PT0M" endtime="PT1440M"/>
</buckets>
</calendar>\n
""" % (
(quoteattr("SS for %s" % (name,))),
self.currentdate.strftime("%Y-%m-%dT%H:%M:%S"),
(i["product_min_qty"] * uom_factor),
)
if i["product_max_qty"] - i["product_min_qty"] > 0:
yield """
<calendar name=%s default="0"><buckets>
<bucket start="2000-01-01T00:00:00" end="2030-12-31T00:00:00" value="%s" days="127" priority="998" starttime="PT0M" endtime="PT1440M"/>
<bucket start="%s" end="2030-12-31T00:00:00" value="%s" days="127" priority="998" starttime="PT0M" endtime="PT1440M"/>
</buckets>
</calendar>\n
""" % (
(quoteattr("ROQ for %s" % (name,))),
self.currentdate.strftime("%Y-%m-%dT%H:%M:%S"),
((i["product_max_qty"] - i["product_min_qty"]) * uom_factor),
)
if not first:
Expand Down

0 comments on commit 335d3c8

Please sign in to comment.