Skip to content

Commit

Permalink
Merge pull request #412 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 Feb 16, 2024
2 parents a557827 + 5840240 commit 966df59
Showing 1 changed file with 53 additions and 24 deletions.
77 changes: 53 additions & 24 deletions frepple/controllers/inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def run(self):
stck_move = self.env["stock.move"].with_user(self.actual_user)
stck_warehouse = self.env["stock.warehouse"].with_user(self.actual_user)
stck_location = self.env["stock.location"].with_user(self.actual_user)
change_product_qty = self.env["change.production.qty"].with_user(
self.actual_user
)
else:
proc_order = self.env["purchase.order"]
proc_orderline = self.env["purchase.order.line"]
Expand All @@ -101,6 +104,7 @@ def run(self):
stck_move = self.env["stock.move"]
stck_warehouse = self.env["stock.warehouse"]
stck_location = self.env["stock.location"]
change_product_qty = self.env["change.production.qty"]
if self.mode == 1:
# Cancel previous draft purchase quotations
m = self.env["purchase.order"]
Expand Down Expand Up @@ -527,31 +531,56 @@ def run(self):
"ignore_secondary_workcenters": True,
}
)
if (elem.get("status") or "proposed") == "proposed":
# MO creation
mo = mfg_order.with_context(context).create(
{
"product_qty": elem.get("quantity"),
"date_planned_start": elem.get("start"),
"date_planned_finished": elem.get("end"),
"product_id": int(item_id),
"company_id": self.company.id,
"product_uom_id": int(uom_id),
"picking_type_id": picking.id,
"bom_id": int(
elem.get("operation").rsplit(" ", 1)[1]
),
"qty_producing": 0.00,
# TODO no place to store the criticality
# elem.get('criticality'),
"origin": "frePPLe",
}
)
mo_references[elem.get("reference")] = mo
mo._onchange_product_qty()
mo._onchange_workorder_ids()
mo._onchange_move_raw()
mo._create_update_move_finished()
else:
# MO update
mo = mfg_order.with_context(context).search(
[("name", "=", elem.get("reference"))]
)[0]
if mo:
new_qty = float(elem.get("quantity"))
if mo.product_qty != new_qty:
cpq = change_product_qty.create(
{
"mo_id": mo.id,
"product_qty": new_qty,
}
)
cpq.change_prod_qty()
mo.write(
{
"date_planned_start": elem.get("start"),
"date_planned_finished": elem.get("end"),
"origin": "frePPLe",
}
)
mo_references[elem.get("reference")] = mo

mo = mfg_order.with_context(context).create(
{
"product_qty": elem.get("quantity"),
"date_planned_start": elem.get("start"),
"date_planned_finished": elem.get("end"),
"product_id": int(item_id),
"company_id": self.company.id,
"product_uom_id": int(uom_id),
"picking_type_id": picking.id,
"bom_id": int(elem.get("operation").rsplit(" ", 1)[1]),
"qty_producing": 0.00,
# TODO no place to store the criticality
# elem.get('criticality'),
"origin": "frePPLe",
}
)
# Remember odoo name for the MO reference passed by frepple.
# This mapping is later used when importing WO.
mo_references[elem.get("reference")] = mo
mo._compute_workorder_ids()
# mo.action_confirm() # confirm MO
# mo._plan_workorders() # plan MO
# mo.action_assign() # reserve material


# Process the workorder information we received
if wo_data:
for wo in mo.workorder_ids:
Expand Down

0 comments on commit 966df59

Please sign in to comment.