Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ addon | version | maintainers | summary
[shopfloor_mobile](shopfloor_mobile/) | 16.0.1.4.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Mobile frontend for WMS Shopfloor app
[shopfloor_mobile_base](shopfloor_mobile_base/) | 16.0.1.1.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Mobile frontend for WMS Shopfloor app
[shopfloor_mobile_base_auth_api_key](shopfloor_mobile_base_auth_api_key/) | 16.0.1.0.0 | | Provides authentication via API key to Shopfloor base mobile app
[shopfloor_reception](shopfloor_reception/) | 16.0.1.6.5 | <a href='https://github.com/mmequignon'><img src='https://github.com/mmequignon.png' width='32' height='32' style='border-radius:50%;' alt='mmequignon'/></a> <a href='https://github.com/JuMiSanAr'><img src='https://github.com/JuMiSanAr.png' width='32' height='32' style='border-radius:50%;' alt='JuMiSanAr'/></a> | Reception scenario for shopfloor
[shopfloor_reception](shopfloor_reception/) | 16.0.1.6.6 | <a href='https://github.com/mmequignon'><img src='https://github.com/mmequignon.png' width='32' height='32' style='border-radius:50%;' alt='mmequignon'/></a> <a href='https://github.com/JuMiSanAr'><img src='https://github.com/JuMiSanAr.png' width='32' height='32' style='border-radius:50%;' alt='JuMiSanAr'/></a> | Reception scenario for shopfloor
[shopfloor_reception_mobile](shopfloor_reception_mobile/) | 16.0.1.1.2 | <a href='https://github.com/JuMiSanAr'><img src='https://github.com/JuMiSanAr.png' width='32' height='32' style='border-radius:50%;' alt='JuMiSanAr'/></a> | Scenario for receiving products
[shopfloor_reception_refund_return](shopfloor_reception_refund_return/) | 16.0.1.0.0 | <a href='https://github.com/mmequignon'><img src='https://github.com/mmequignon.png' width='32' height='32' style='border-radius:50%;' alt='mmequignon'/></a> | Mark created return as to refund
[shopfloor_rest_log](shopfloor_rest_log/) | 16.0.1.0.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Integrate rest_log into Shopfloor app
Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Shopfloor Reception
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:40ba81ab584552fe151e2a4d6021706cb34380a9bdc9ed7f08963394a45030b9
!! source digest: sha256:f8d87b75abf2f07115fe503fe887e2266295e7bc6e9e86e9818ff85ed88bff85
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Shopfloor Reception",
"summary": "Reception scenario for shopfloor",
"version": "16.0.1.6.5",
"version": "16.0.1.6.6",
"development_status": "Beta",
"category": "Inventory",
"website": "https://github.com/OCA/wms",
Expand Down
41 changes: 26 additions & 15 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


from datetime import datetime, time

import pytz
from decorator import contextmanager

Expand Down Expand Up @@ -86,31 +88,40 @@ def _move_line_by_lot(self, lot):

def _scheduled_date_today_domain(self):
domain = []
today_start, today_end = self._get_today_start_end_datetime()
today_start, today_end = self._get_today_start_end_datetime_utc()
domain.append(("scheduled_date", ">=", today_start))
domain.append(("scheduled_date", "<=", today_end))
return domain

def _get_today_start_end_datetime(self, naive=True):
def _get_today_start_end_datetime_utc(self):
"""
Returns the start and end of the current day for the warehouse/company
timezone, converted to UTC naive datetimes.
"""
# TODO: Put warehouse tz retrieval in shopfloor module?
company = self.env.company
warehouse = self.picking_types.warehouse_id
tz = (

tz_name = (
warehouse.partner_id.tz
if (len(warehouse) == 1 and warehouse.partner_id.tz)
else company.partner_id.tz or "UTC"
)
today = fields.Datetime.today()
today_start = today_start_localized = fields.Datetime.start_of(today, "day")
today_end = today_end_localized = fields.Datetime.end_of(today, "day")
if not naive:
today_start_localized = (
pytz.timezone(tz).localize(today_start).astimezone(pytz.utc)
)
today_end_localized = (
pytz.timezone(tz).localize(today_end).astimezone(pytz.utc)
)
return (today_start_localized, today_end_localized)
tz = pytz.timezone(tz_name)

now_local = pytz.utc.localize(datetime.now()).astimezone(tz)

local_start = datetime.combine(
now_local.date(), time.min, tzinfo=now_local.tzinfo
)
local_end = datetime.combine(
now_local.date(), time.max, tzinfo=now_local.tzinfo
)

utc_start = local_start.astimezone(pytz.utc).replace(tzinfo=None)
utc_end = local_end.astimezone(pytz.utc).replace(tzinfo=None)

return utc_start, utc_end

@property
def filter_today_scheduled_pickings(self):
Expand Down Expand Up @@ -384,7 +395,7 @@ def _scan_document__by_picking(self, pickings, barcode):
# could return more than one picking.
# If there's only one picking due today, we go to the next screen.
# Otherwise, we ask the user to scan a package instead.
today_start, today_end = self._get_today_start_end_datetime()
today_start, today_end = self._get_today_start_end_datetime_utc()
picking_filter_result_due_today = picking_filter_result.filtered(
lambda p: today_start <= p.scheduled_date < today_end
)
Expand Down
2 changes: 1 addition & 1 deletion shopfloor_reception/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Shopfloor Reception</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:40ba81ab584552fe151e2a4d6021706cb34380a9bdc9ed7f08963394a45030b9
!! source digest: sha256:f8d87b75abf2f07115fe503fe887e2266295e7bc6e9e86e9818ff85ed88bff85
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/wms/tree/16.0/shopfloor_reception"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/wms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Shopfloor implementation of the reception scenario.
Expand Down
19 changes: 13 additions & 6 deletions shopfloor_reception/tests/test_select_document.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
# pylint: disable=missing-return
from datetime import datetime, timedelta

from freezegun import freeze_time

from odoo import fields
Expand All @@ -9,7 +11,6 @@

_TODAY = "2022-12-07"
_TOMORROW = "2022-12-08"
_TODAY_ELEVEN = "2022-12-07 23:30:00"


class TestSelectDocument(CommonCase):
Expand Down Expand Up @@ -82,15 +83,21 @@ def test_scan_picking_origin_multiple_pickings_one_today(self):
data=self._data_for_select_move(picking_today),
)

@freeze_time(_TODAY_ELEVEN, tz_offset=0)
# Since we use "Europe/Brussels" tz and _TODAY is in winter
# the shift is UTC+1
@freeze_time(_TODAY, tz_offset=-1)
def test_scan_picking_origin_multiple_pickings_one_today_tz(self):
# freezed today is UTC time, set warehouse user to Brussels
self.wh.partner_id.sudo().tz = "Europe/Brussels"
tz_name = "Europe/Brussels"
self.wh.partner_id.sudo().tz = tz_name

# Create a picking with the UTC hour
picking_today = self._create_picking(scheduled_date=_TODAY_ELEVEN)

picking_tomorrow = self._create_picking(scheduled_date=_TOMORROW)
picking_today = self._create_picking(
scheduled_date=datetime.now() + timedelta(hours=23, minutes=30)
)
picking_tomorrow = self._create_picking(
scheduled_date=datetime.now() + timedelta(days=1),
)
pickings = picking_today | picking_tomorrow
pickings = pickings.sorted(lambda p: (p.scheduled_date, p.id), reverse=False)
pickings.write({"origin": "Somewhere together"})
Expand Down
Loading