Skip to content

Commit

Permalink
Merge commit 'refs/pull/1863/head' of https://github.com/oca/purchase…
Browse files Browse the repository at this point in the history
…-workflow into 16.0-2630
  • Loading branch information
docker-odoo committed Jun 7, 2023
2 parents 019f03a + 5b4d427 commit a90e588
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -2,6 +2,8 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
from datetime import datetime

import pytz

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools import get_lang
Expand Down Expand Up @@ -219,6 +221,7 @@ def make_purchase_order(self):
purchase_obj = self.env["purchase.order"]
po_line_obj = self.env["purchase.order.line"]
pr_line_obj = self.env["purchase.request.line"]
user_tz = pytz.timezone(self.env.user.tz or "UTC")
purchase = False

for item in self.item_ids:
Expand Down Expand Up @@ -283,8 +286,16 @@ def make_purchase_order(self):
# 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
# we enforce to save the datetime value in the current tz of the user
po_line.date_planned = (
datetime(
date_required.year,
date_required.month,
date_required.day,
tzinfo=user_tz,
)
.astimezone(pytz.UTC)
.replace(tzinfo=None)
)
res.append(purchase.id)

Expand Down

0 comments on commit a90e588

Please sign in to comment.