Skip to content

Commit

Permalink
Merge pull request #408 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 Feb 15, 2024
2 parents 0acf1df + 5cfc348 commit 1791f4f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
29 changes: 27 additions & 2 deletions frepple/controllers/inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def run(self):
try:
ordertype = elem.get("ordertype")
if ordertype == "PO":
# Create purchase order

supplier_id = int(elem.get("supplier").rsplit(" ", 1)[-1])
quantity = elem.get("quantity")
quantity = float(elem.get("quantity"))
date_planned = elem.get("end")
if date_planned:
date_planned = datetime.strptime(
Expand All @@ -194,6 +194,31 @@ def run(self):
date_ordered = datetime.strptime(
date_ordered, "%Y-%m-%d %H:%M:%S"
)

# Is that an update of an existing PO ?
status = elem.get("status")
if status in ("approved", "confirmed"):
po_line_id = int(elem.get("id").rsplit(" - ", 1)[-1])
po_line = proc_orderline.browse(po_line_id)
if po_line:
po_line.write(
{
"product_id": int(item_id),
"product_qty": quantity,
"product_uom": int(uom_id),
"date_planned": date_planned,
"name": elem.get("item"),
}
)
countproc += 1
else:
logger.error(
"Unable to find PO line %s in Odoo"
% (elem.get("reference"),)
)
continue

# Create purchase order
if supplier_id not in supplier_reference:
po = proc_order.create(
{
Expand Down
6 changes: 4 additions & 2 deletions frepple/controllers/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,10 +2124,12 @@ def export_purchaseorders(self):
or i["state"] in ("draft", "cancel", "done")
):
continue
po_line_reference = "%s - %s - %s" % (
j = po[po_line[i["purchase_line_id"][0]]["order_id"][0]]
po_line_reference = "%s - %s - %s - %s" % (
j["name"],
i["picking_id"][1],
i["id"],
i["purchase_line_id"][0],
)
if i["is_subcontract"]:
# PO lines on a subcontracting BOM are mapped as a MO in frepple
Expand All @@ -2144,7 +2146,7 @@ def export_purchaseorders(self):
item = self.product_product.get(i["product_id"][0], None)
if not item:
continue
j = po[po_line[i["purchase_line_id"][0]]["order_id"][0]]

# if PO status is done, we should ignore this receipt
if j["state"] == "done":
continue
Expand Down

0 comments on commit 1791f4f

Please sign in to comment.