Skip to content

Commit

Permalink
Merge pull request #482 from frePPLe/17.0
Browse files Browse the repository at this point in the history
Syncing from upstream frePPLe/odoo (17.0)
  • Loading branch information
bt-admin authored Oct 10, 2024
2 parents 2e7a19b + 3ae50fe commit 85dde17
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions frepple/controllers/inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def run(self):
if self.mode == 1:
# Cancel previous draft purchase quotations
m = self.env["purchase.order"]
recs = m.search([("state", "=", "draft"), ("origin", "=", "frePPLe")])
recs = m.search([("state", "=", "draft"), ("origin", "=like", "frePPLe%")])
recs.write({"state": "cancel"})
recs.unlink()
msg.append("Removed %s old draft purchase orders" % len(recs))
Expand All @@ -127,7 +127,7 @@ def run(self):
"|",
("state", "=", "draft"),
("state", "=", "cancel"),
("origin", "=", "frePPLe"),
("origin", "=like", "frePPLe%"),
]
)
recs.write({"state": "cancel"})
Expand Down Expand Up @@ -280,11 +280,16 @@ def run(self):
continue

# Create purchase order
remark = elem.get("remark", None)
if remark:
remark = "frePPLe - %s" % remark
else:
remark = "frePPLe"
if supplier_id not in supplier_reference:
po_args = {
"company_id": self.company.id,
"partner_id": supplier_id,
"origin": "frePPLe",
"origin": remark,
}
try:
picking_type_id = stck_picking_type.search(
Expand Down Expand Up @@ -399,10 +404,10 @@ def run(self):
destination = elem.get("destination")

origin_id = stck_warehouse.search(
[("name", "=", origin)], limit=1
[("code", "=", origin)], limit=1
)[0]
destination_id = stck_warehouse.search(
[("name", "=", destination)], limit=1
[("code", "=", destination)], limit=1
)[0]

location_id = None
Expand Down Expand Up @@ -465,6 +470,11 @@ def run(self):
if not hasattr(self, "stock_picking_dict"):
self.stock_picking_dict = {}
if not self.stock_picking_dict.get((origin, destination)):
remark = elem.get("remark", None)
if remark:
remark = "frePPLe - %s" % remark
else:
remark = "frePPLe"
self.stock_picking_dict[(origin, destination)] = (
stck_picking.create(
{
Expand All @@ -473,7 +483,7 @@ def run(self):
"location_id": location_id["id"],
"location_dest_id": location_dest_id["id"],
"move_type": "direct",
"origin": "frePPLe",
"origin": remark,
}
)
)
Expand Down Expand Up @@ -604,6 +614,11 @@ def run(self):
)
if (elem.get("status") or "proposed") == "proposed":
# MO creation
remark = elem.get("remark", None)
if remark:
remark = "frePPLe - %s" % remark
else:
remark = "frePPLe"
mo = mfg_order.with_context(context).create(
{
"product_qty": elem.get("quantity"),
Expand All @@ -619,7 +634,7 @@ def run(self):
"qty_producing": 0.00,
# TODO no place to store the criticality
# elem.get('criticality'),
"origin": "frePPLe",
"origin": remark,
}
)
# Remember odoo name for the MO reference passed by frepple.
Expand All @@ -641,6 +656,11 @@ def run(self):
continue
if mo:
new_qty = float(elem.get("quantity"))
remark = elem.get("remark", None)
if remark:
remark = "frePPLe - %s" % remark
else:
remark = "frePPLe"
if mo.product_qty != new_qty:
cpq = change_product_qty.create(
{
Expand All @@ -653,7 +673,7 @@ def run(self):
{
"date_start": elem.get("start"),
"date_finished": elem.get("end"),
"origin": "frePPLe",
"origin": remark,
}
)
mo_references[elem.get("reference")] = mo
Expand Down

0 comments on commit 85dde17

Please sign in to comment.