Skip to content

Commit

Permalink
[FIX] purchase_request: fix datetime from request to order in other t…
Browse files Browse the repository at this point in the history
…imezone that is not UTC
  • Loading branch information
alan196 committed Jul 20, 2023
1 parent 8d1ec66 commit 0d29700
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def _prepare_purchase_order_line(self, po, item):
# Suggest the supplier min qty as it's done in Odoo core
min_qty = item.line_id._get_supplier_min_qty(product, po.partner_id)
qty = max(qty, min_qty)
date_required = item.line_id.date_required
date_required = fields.Datetime.to_datetime(item.line_id.date_required)
context_date = fields.Datetime.context_timestamp(self, date_required)
vals = {
"name": product.name,
"order_id": po.id,
Expand All @@ -186,9 +187,7 @@ def _prepare_purchase_order_line(self, po, item):
"product_qty": qty,
"account_analytic_id": item.line_id.analytic_account_id.id,
"purchase_request_lines": [(4, item.line_id.id)],
"date_planned": datetime(
date_required.year, date_required.month, date_required.day
),
"date_planned": date_required - context_date.utcoffset(),
"move_dest_ids": [(4, x.id) for x in item.line_id.move_dest_ids],
}
if item.line_id.analytic_tag_ids:
Expand Down Expand Up @@ -303,10 +302,9 @@ def make_purchase_order(self):
po_line._onchange_quantity()
# The onchange quantity is altering the scheduled date of the PO
# lines. We do not want that:
date_required = item.line_id.date_required
po_line.date_planned = datetime(
date_required.year, date_required.month, date_required.day
)
date_required = fields.Datetime.to_datetime(item.line_id.date_required)
context_date = fields.Datetime.context_timestamp(self, date_required)
po_line.date_planned = date_required - context_date.utcoffset()
res.append(purchase.id)

return {
Expand Down

0 comments on commit 0d29700

Please sign in to comment.