Skip to content

Commit

Permalink
[MIG] stock_picking_group_by_partner_by_carrier_by_date: Migration to…
Browse files Browse the repository at this point in the history
… 16.0
  • Loading branch information
tuantrantg committed Mar 8, 2024
1 parent 1c5b5af commit 8c323a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright 2020 Camptocamp (https://www.camptocamp.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models
from datetime import timedelta

from odoo import fields, models


class StockMove(models.Model):
Expand All @@ -25,10 +27,24 @@ def _assign_picking_group_domain_by_date(self):
domain = []
if self._skip_assign_picking_group_domain_by_date():
return domain

Check warning on line 29 in stock_picking_group_by_partner_by_carrier_by_date/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_group_by_partner_by_carrier_by_date/models/stock_move.py#L29

Added line #L29 was not covered by tests
date_planned = self.date.replace(hour=0, minute=0, second=0)
date_planned_end = date_planned.replace(hour=23, minute=59, second=59)
# Convert to partner's tz
tz = self.partner_id.tz or self.env.company.partner_id.tz or self.env.user.tz
date_tz = fields.Datetime.context_timestamp(self.with_context(tz=tz), self.date)
dt_start_tz = date_tz.replace(
hour=0,
minute=0,
second=0,
microsecond=0,
)
# Convert to UTC
dt_start = fields.Datetime.from_string(
self.env["ir.fields.converter"]
.with_context(tz=tz)
._str_to_datetime(None, None, dt_start_tz.replace(tzinfo=None))[0]
)
dt_end = dt_start + timedelta(days=1)
domain = [
("scheduled_date", "<=", date_planned_end),
("scheduled_date", ">=", date_planned),
("scheduled_date", "<", dt_end),
("scheduled_date", ">=", dt_start),
]
return domain
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from freezegun import freeze_time

from odoo.tests import SavepointCase, tagged
from odoo.tests import TransactionCase, tagged


class TestGroupByDateBase(SavepointCase):
class TestGroupByDateBase(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down

0 comments on commit 8c323a0

Please sign in to comment.