Files
stock-logistics-warehouse/stock_measuring_device_zippcube/components/zippcube_device_component.py
Alexandre Fayolle db6e0e5142 [ADD] stock_measuring_device_zippcube
support for Bosche Zippcube measuring devices
2021-09-14 21:11:55 +07:00

40 lines
1.2 KiB
Python

# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
import logging
from odoo import _
from odoo.addons.component.core import Component
_logger = logging.getLogger(__name__)
class ZippcubeDevice(Component):
_name = "device.component.zippcube"
_inherit = "measuring.device.base"
_usage = "zippcube"
def preprocess_measures(self, measures):
weight_keys = ("weight",)
measures_keys = ("length", "width", "height")
data = {}
for key in weight_keys + measures_keys:
value = measures[key]
if isinstance(value, str):
value = float(value.replace(",", "."))
if key in measures_keys:
# lengths are in cm -> convert to mm
value *= 10
data[key] = value
return {
"max_weight": data["weight"],
"lngth": data["length"],
"width": data["width"],
"height": data["height"],
}
def post_update_packaging_measures(self, measures, packaging, wizard_line):
wizard_line.wizard_id._notify(_("Please, press the REFRESH button."))
packaging._measuring_device_release()