Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] stock_reception_screen_measuring_device: Migration to 14.0 #306

6 changes: 6 additions & 0 deletions setup/stock_reception_screen_measuring_device/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
106 changes: 106 additions & 0 deletions stock_reception_screen_measuring_device/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
==========================================
Stock Measuring Device on Reception Screen
==========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/14.0/stock_reception_screen_measuring_device
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-stock_reception_screen_measuring_device
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/285/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module builds on the Reception Screen module (in OCA/wms) and the Stock
Measuring Device module (in OCA/stock-logistics-warehouse) to allow the
operator to measure and weigh a package directly from the reception screen.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Usage
=====

In the reception screen, click on the "Measure Current Packaging" button
(visible if the packaging of the reception is set and has not
weight/dimensions), and use the measuring device. The values should be directly
updated on the packaging.

Known limitation: this only works on the measuring device flagges as default.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20stock_reception_screen_measuring_device%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Carlos Serra Toro <carlos.serra@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Khoi Vo <khoivha@trobz.com>

Other credits
~~~~~~~~~~~~~

The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-gurneyalex| image:: https://github.com/gurneyalex.png?size=40px
:target: https://github.com/gurneyalex
:alt: gurneyalex

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-gurneyalex|

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/14.0/stock_reception_screen_measuring_device>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions stock_reception_screen_measuring_device/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from . import models
21 changes: 21 additions & 0 deletions stock_reception_screen_measuring_device/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{
"name": "Stock Measuring Device on Reception Screen",
"summary": "Allow to use a measuring device from a reception screen."
"for packaging measurement",
"version": "14.0.1.0.0",
"category": "Warehouse",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["stock_reception_screen", "stock_measuring_device"],
"data": [
"views/stock_reception_screen_view.xml",
"views/measuring_device_view.xml",
],
"website": "https://github.com/OCA/wms",
"installable": True,
"auto_install": True,
"development_status": "Alpha",
"maintainers": ["gurneyalex"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_reception_screen_measuring_device
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,help:stock_reception_screen_measuring_device.field_stock_reception_screen__scan_requested
msgid "A scan from the measuring device was requested"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model_terms:ir.ui.view,arch_db:stock_reception_screen_measuring_device.stock_reception_screen_view_form
msgid "Cancel Measure"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,field_description:stock_reception_screen_measuring_device.field_measuring_device__is_default
msgid "Default"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,field_description:stock_reception_screen_measuring_device.field_stock_reception_screen__display_package_dimensions
msgid "Dimensions (lxhxw)"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,help:stock_reception_screen_measuring_device.field_stock_reception_screen__display_package_dimensions
msgid "Dimensions of the package in mm (length x height x width)"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,help:stock_reception_screen_measuring_device.field_stock_reception_screen__package_has_missing_dimensions
msgid "Indicates if the package have any measurement missing."
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model_terms:ir.ui.view,arch_db:stock_reception_screen_measuring_device.stock_reception_screen_view_form
msgid "Measure Current Packaging"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: code:addons/stock_reception_screen_measuring_device/models/stock_reception_screen.py:0
#, python-format
msgid "Measurement machine already in use."
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model,name:stock_reception_screen_measuring_device.model_measuring_device
msgid "Measuring and Weighing Device"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: code:addons/stock_reception_screen_measuring_device/models/stock_reception_screen.py:0
#, python-format
msgid "No default device set, please configure one."
msgstr ""

#. module: stock_reception_screen_measuring_device
#: code:addons/stock_reception_screen_measuring_device/models/measuring_device.py:0
#, python-format
msgid "Only one measuring device can be the default one."
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,field_description:stock_reception_screen_measuring_device.field_stock_reception_screen__package_has_missing_dimensions
msgid "Package Requires Measures?"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model_terms:ir.ui.view,arch_db:stock_reception_screen_measuring_device.stock_reception_screen_view_form
msgid "Refresh"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,field_description:stock_reception_screen_measuring_device.field_stock_reception_screen__scan_requested
msgid "Scan Requested"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model,name:stock_reception_screen_measuring_device.model_stock_reception_screen
msgid "Stock Reception Screen"
msgstr ""

#. module: stock_reception_screen_measuring_device
#: model:ir.model.fields,help:stock_reception_screen_measuring_device.field_measuring_device__is_default
msgid ""
"The device set as the default one will be the one used in the reception "
"screen."
msgstr ""
4 changes: 4 additions & 0 deletions stock_reception_screen_measuring_device/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from . import stock_reception_screen
from . import measuring_device
23 changes: 23 additions & 0 deletions stock_reception_screen_measuring_device/models/measuring_device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class MeasuringDevice(models.Model):
_inherit = "measuring.device"

is_default = fields.Boolean(
"Default",
default=False,
help="The device set as the default one will be "
"the one used in the reception screen.",
)

@api.constrains("is_default")
def _check_is_default(self):
self.ensure_one()
if self.search_count([("is_default", "=", True)]) > 1:
raise ValidationError(
_("Only one measuring device can be the default one.")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

import logging

from odoo import _, api, fields, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)


class StockReceptionScreen(models.Model):
_inherit = "stock.reception.screen"

package_has_missing_dimensions = fields.Boolean(
"Package Requires Measures?",
compute="_compute_package_has_missing_dimensions",
store=True,
help="Indicates if the package have any measurement missing.",
)
display_package_dimensions = fields.Char(
string="Dimensions (lxhxw)",
compute="_compute_package_dimensions",
help="Dimensions of the package in mm (length x height x width)",
)
scan_requested = fields.Boolean(
help="A scan from the measuring device was requested",
default=False,
compute="_compute_scan_requested",
store=True,
)

@api.depends("product_packaging_id", "product_packaging_id.measuring_device_id")
def _compute_scan_requested(self):
for record in self:
record.scan_requested = (
record.product_packaging_id
and record.product_packaging_id.measuring_device_id
)

@api.depends(
"product_packaging_id.packaging_length",
"product_packaging_id.width",
"product_packaging_id.height",
)
def _compute_package_dimensions(self):
for record in self:
pack = record.product_packaging_id
dimension_values = [pack.packaging_length, pack.height, pack.width]
if all(dimension_values):
record.display_package_dimensions = " x ".join(
[f"{str(val)}mm" for val in dimension_values]
)
else:
record.display_package_dimensions = False

@api.depends(
"product_packaging_id.max_weight",
"product_packaging_id.packaging_length",
"product_packaging_id.width",
"product_packaging_id.height",
)
def _compute_package_has_missing_dimensions(self):
for record in self:
pack = record.product_packaging_id
if pack:
record.package_has_missing_dimensions = not pack.type_is_pallet and (
not (pack.packaging_length and pack.width and pack.height)
or not pack.max_weight
)
else:
record.package_has_missing_dimensions = False

def measure_current_packaging(self):
self.ensure_one()
device = self.env["measuring.device"].search(
[("is_default", "=", True)], limit=1
)
if not device:
error_msg = _("No default device set, please configure one.")
_logger.error(error_msg)
self._notify(error_msg)
return UserError(error_msg)
if device._is_being_used():
error_msg = _("Measurement machine already in use.")
_logger.error(error_msg)
self._notify(error_msg)
return UserError(error_msg)

self.product_packaging_id._measuring_device_assign(device)
return True

def cancel_measure_current_packaging(self):
self.ensure_one()
self.product_packaging_id._measuring_device_release()
return True

def _notify(self, message):
"""Show a gentle notification on the wizard"""
self.ensure_one()
self.create_uid.with_user(self.create_uid.id).notify_warning(message=message)

def reload(self):
self.cancel_measure_current_packaging()
return {
"type": "ir.actions.act_view_reload",
}

def button_reset(self):
self.cancel_measure_current_packaging()
return super().button_reset()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Carlos Serra Toro <carlos.serra@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Khoi Vo <khoivha@trobz.com>
1 change: 1 addition & 0 deletions stock_reception_screen_measuring_device/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module builds on the Reception Screen module (in OCA/wms) and the Stock
Measuring Device module (in OCA/stock-logistics-warehouse) to allow the
operator to measure and weigh a package directly from the reception screen.
Loading