Skip to content

Commit

Permalink
Allow export of proposed/confirmed POs to Odoo
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamlahlou committed Feb 14, 2024
1 parent cdd59e6 commit 60ca47d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions doc/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ This release is scheduled for end February 2024. You can already check out a `pr
- | 15, 16, 17: The frePPLe item name is now mapped to the Odoo product internal reference,
unless the internal reference is not unique in Odoo.

- | 15: Allow export of approved and confirmed purchase orders from frePPLe to Odoo to
update various fields of the Odoo purchase order lines (quantity, receipt date, item...).

- | The XMLRPC version of the connector is deprecated.
| It has always been only an experimental feature, which we see now as a dead end.
Expand Down
2 changes: 1 addition & 1 deletion freppledb/common/static/js/frepple.js
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ var ERPconnection = {
var r = grid.jqGrid('getRowData', sel[i]);
if (r.type === undefined)
r.type = transactiontype;
if (r.status == 'proposed')
if (['proposed', 'approved', 'confirmed'].includes(r.status))
data.push(r);
}
if (data == [])
Expand Down
18 changes: 13 additions & 5 deletions freppledb/odoo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ def Upload(request):
)
if (
not po.supplier.source
or po.status != "proposed"
or not (
po.status == "proposed"
or (
po.status in ("approved", "confirmed")
and po.source == "odoo_1"
)
)
or not po.item.source
):
continue
data_ok = True
obj.append(po)
data_odoo.append(
'<operationplan ordertype="PO" id="%s" item=%s location=%s supplier=%s start="%s" end="%s" quantity="%s" location_id=%s item_id=%s criticality="%d" batch=%s/>'
'<operationplan ordertype="PO" id="%s" item=%s location=%s supplier=%s start="%s" end="%s" quantity="%s" location_id=%s item_id=%s criticality="%d" batch=%s status=%s/>'
% (
po.reference,
quoteattr(po.item.name),
Expand All @@ -134,6 +140,7 @@ def Upload(request):
quoteattr(po.item.subcategory or ""),
int(po.criticality),
quoteattr(po.batch or ""),
quoteattr(po.status),
)
)
elif rec["type"] == "DO":
Expand Down Expand Up @@ -301,9 +308,10 @@ def Upload(request):
msg = f.read()
logger.debug("Odoo response: %s" % msg.decode("utf-8"))
for i in obj:
i.status = "approved"
i.source = "odoo_1"
i.save(using=request.database)
if i.status == "proposed":
i.status = "approved"
i.source = "odoo_1"
i.save(using=request.database)
return HttpResponse("OK")

except HTTPError as e:
Expand Down

0 comments on commit 60ca47d

Please sign in to comment.