Skip to content

Commit

Permalink
Merge pull request #428 from frePPLe/16.0
Browse files Browse the repository at this point in the history
Syncing from upstream frePPLe/odoo (16.0)
  • Loading branch information
bt-admin authored Mar 9, 2024
2 parents 7b4d721 + 34a1973 commit 146a21e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
33 changes: 11 additions & 22 deletions frepple/controllers/inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, req, database=None, company=None, mode=1):
try:
usr = self.env["res.users"].browse(ids=[req.uid]).read(["tz"])[0]
self.timezone = timezone(usr["tz"] or "UTC")
except Exception as e:
except Exception:
self.timezone = timezone("UTC")

# User to be set as responsible on new objects in incremental exports
Expand Down Expand Up @@ -156,6 +156,12 @@ def run(self):
# Workcenters of a workorder to update
resources = []

context = (
dict(self.env["res.users"].with_user(self.actual_user).context_get())
if self.actual_user
else dict(self.env.context)
)

for event, elem in iterparse(self.datafile, events=("start", "end")):
if (
elem.tag == "operationplan"
Expand Down Expand Up @@ -501,7 +507,7 @@ def run(self):
]
)
for wo in wo_list:
if wo["display_name"] != elem.get("operation"):
if wo["display_name"] != elem.get("reference"):
# Can't filter on the computed display_name field in the search...
continue
if wo:
Expand Down Expand Up @@ -556,7 +562,7 @@ def run(self):
wo.write(data)
break
else:
# Create manufacturing order
# Create or update a manufacturing order
warehouse = int(elem.get("location_id"))
picking = stck_picking_type.search(
[
Expand All @@ -570,15 +576,6 @@ def run(self):
# update the context with the default picking type
# to set correct src/dest locations
# Also do not create secondary work center records
context = (
dict(
self.env["res.users"]
.with_user(self.actual_user)
.context_get()
)
if self.actual_user
else dict(self.env.context)
)
context.update(
{
"default_picking_type_id": picking.id,
Expand Down Expand Up @@ -652,23 +649,15 @@ def run(self):
# the manufacturing order.
# Here we are already updating it earlier
if "start" in rec:
wo.date_planned_start = (
self.timezone.localize(rec["start"])
.astimezone(UTC)
.replace(tzinfo=None)
)
wo.date_planned_start = rec["start"]
if not create:
wo.write(
{
"date_planned_start": wo.date_planned_start
}
)
if "end" in rec:
wo.date_planned_finished = (
self.timezone.localize(rec["end"])
.astimezone(UTC)
.replace(tzinfo=None)
)
wo.date_planned_finished = rec["end"]
if not create:
wo.write(
{
Expand Down
6 changes: 1 addition & 5 deletions frepple/controllers/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,11 +2411,7 @@ def export_manufacturingorders(self):
time_left = wo["duration_expected"] - wo["duration_unit"]
if wo["is_user_working"] and wo["time_ids"]:
# The WO is currently being worked on
for tm in self.generator.getData(
"mrp.workcenter.productivity",
ids=wo["time_ids"],
fields=["date_start", "date_end"],
):
for tm in wo["time_ids"]:
if tm["date_start"] and not tm["date_end"]:
time_left -= round(
(now - tm["date_start"]).total_seconds() / 60
Expand Down

0 comments on commit 146a21e

Please sign in to comment.