Skip to content

Commit

Permalink
Merge pull request #452 from frePPLe/15.0
Browse files Browse the repository at this point in the history
Syncing from upstream frePPLe/odoo (15.0)
  • Loading branch information
bt-admin authored Jul 3, 2024
2 parents 892fc9b + 5384c4e commit 6882047
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions frepple/controllers/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,14 +2142,36 @@ def export_purchaseorders(self):
i["product_uom"],
self.product_product[i["product_id"][0]]["template"],
)
supplier = self.map_customers.get(j["partner_id"][0])
if not supplier:
# supplier is archived :-(
for sup in self.generator.getData(
"res.partner",
search=[
("id", "=", j["partner_id"][0]),
"|",
("active", "=", True),
("active", "=", False),
],
fields=["name", "active"],
):
supplier = "%s %s%s" % (
sup["name"],
"(archived) " if not sup["active"] else "",
sup["id"],
)
self.map_customers[sup["id"]] = supplier
break
if not supplier:
continue
yield '<operationplan reference=%s ordertype="PO" start="%s" end="%s" quantity="%f" status="confirmed">' "<item name=%s/><location name=%s/><supplier name=%s/></operationplan>\n" % (
quoteattr("%s - %s" % (j["name"], i["id"])),
start,
end,
qty,
quoteattr(item["name"]),
quoteattr(location),
quoteattr(self.map_customers.get(j["partner_id"][0])),
quoteattr(supplier),
)
yield "</operationplans>\n"

Expand Down Expand Up @@ -2224,6 +2246,28 @@ def export_purchaseorders(self):
start = self.formatDateTime(start if start < end else end)
end = self.formatDateTime(end)
qty = i["product_qty"] - i["quantity_done"]
supplier = self.map_customers.get(j["partner_id"][0])
if not supplier:
# supplier is archived :-(
for sup in self.generator.getData(
"res.partner",
search=[
("id", "=", j["partner_id"][0]),
"|",
("active", "=", True),
("active", "=", False),
],
fields=["name", "active"],
):
supplier = "%s %s%s" % (
sup["name"],
"(archived) " if not sup["active"] else "",
sup["id"],
)
self.map_customers[sup["id"]] = supplier
break
if not supplier:
continue
if qty >= 0:
yield '<operationplan reference=%s ordertype="PO" start="%s" end="%s" quantity="%f" status="confirmed">' "<item name=%s/><location name=%s/><supplier name=%s/></operationplan>\n" % (
quoteattr(po_line_reference),
Expand All @@ -2232,7 +2276,7 @@ def export_purchaseorders(self):
qty,
quoteattr(item["name"]),
quoteattr(location),
quoteattr(self.map_customers.get(j["partner_id"][0])),
quoteattr(supplier),
)
yield "</operationplans>\n"

Expand Down

0 comments on commit 6882047

Please sign in to comment.