Skip to content

Commit

Permalink
Merge PR #2398 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by StefanRijnhart
  • Loading branch information
OCA-git-bot committed Sep 26, 2024
2 parents 1ea5919 + 4b33d46 commit 4b77a58
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def make_purchase_order(self):
res = []
purchase_obj = self.env["purchase.order"]
po_line_obj = self.env["purchase.order.line"]
pr_line_obj = self.env["purchase.request.line"]
purchase = False

for item in self.item_ids:
Expand Down Expand Up @@ -276,18 +275,7 @@ def make_purchase_order(self):
)
all_qty = min(po_line_product_uom_qty, wizard_product_uom_qty)
self.create_allocation(po_line, line, all_qty, alloc_uom)
# TODO: Check propagate_uom compatibility:
new_qty = pr_line_obj._calc_new_qty(
line, po_line=po_line, new_pr_line=new_pr_line
)
po_line.product_qty = new_qty
# The quantity update triggers a compute method that alters the
# unit price (which is what we want, to honor graduate pricing)
# but also the scheduled date which is what we don't want.
date_required = item.line_id.date_required
po_line.date_planned = datetime(
date_required.year, date_required.month, date_required.day
)
self._post_process_po_line(item, po_line, new_pr_line)
res.append(purchase.id)

purchase_requests = self.item_ids.mapped("request_id")
Expand All @@ -302,6 +290,22 @@ def make_purchase_order(self):
"type": "ir.actions.act_window",
}

def _post_process_po_line(self, item, po_line, new_pr_line):
self.ensure_one()
line = item.line_id
# TODO: Check propagate_uom compatibility:
new_qty = self.env["purchase.request.line"]._calc_new_qty(
line, po_line=po_line, new_pr_line=new_pr_line
)
po_line.product_qty = new_qty
# The quantity update triggers a compute method that alters the
# unit price (which is what we want, to honor graduate pricing)
# but also the scheduled date which is what we don't want.
date_required = line.date_required
po_line.date_planned = datetime(
date_required.year, date_required.month, date_required.day
)


class PurchaseRequestLineMakePurchaseOrderItem(models.TransientModel):
_name = "purchase.request.line.make.purchase.order.item"
Expand Down

0 comments on commit 4b77a58

Please sign in to comment.