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][ADD] shopfloor_reception_packaging_dimension #647

Merged
merged 7 commits into from
Nov 7, 2023
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
6 changes: 6 additions & 0 deletions setup/shopfloor_reception_packaging_dimension/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,
)
6 changes: 6 additions & 0 deletions setup/shopfloor_reception_packaging_dimension_mobile/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,
)
20 changes: 20 additions & 0 deletions shopfloor/actions/data_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,23 @@ def _product_supplierinfo_parser(self):
"product_name",
"product_code",
]

@ensure_model("product.packaging")
def packaging_detail(self, record, **kw):
return self._jsonify(
record.with_context(packaging=record.id),
self._packaging_detail_parser,
**kw
)

@property
def _packaging_detail_parser(self):
return self._packaging_parser + [
"packaging_length:length",
"width",
"height",
"max_weight",
"length_uom_name:length_uom",
"weight_uom_name:weight_uom",
"barcode:barcode",
]
6 changes: 6 additions & 0 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ def packaging_not_found_in_picking(self):
"body": _("Packaging not found in the current transfer."),
}

def packaging_dimension_updated(self, packaging):
return {
"message_type": "success",
"body": _("Packaging {} dimension updated.").format(packaging.name),
}

def expiration_date_missing(self):
return {
"message_type": "error",
Expand Down
22 changes: 14 additions & 8 deletions shopfloor/actions/schema_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ def product_supplierinfo(self):
)
return schema

# TODO
# def packaging_detail(self):
# schema = self.packaging()
# schema.update(
# {
# }
# )
# return schema
def packaging_detail(self):
schema = self.packaging()
schema.update(
{
"length": {"type": "float", "nullable": True, "required": False},
"width": {"type": "float", "nullable": True, "required": False},
"height": {"type": "float", "nullable": True, "required": False},
"max_weight": {"type": "float", "nullable": True, "required": False},
"length_uom": {"type": "string", "nullable": True, "required": False},
"weight_uom": {"type": "string", "nullable": True, "required": False},
"barcode": {"type": "string", "nullable": True, "required": False},
}
)
return schema
14 changes: 14 additions & 0 deletions shopfloor/tests/test_actions_data_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,17 @@ def _expected_product_detail(self, record, **kw):
}
)
return dict(**self._expected_product(record), **detail)

def _expected_packaging_detail(self, record, **kw):
return dict(
**self._expected_packaging(record),
**{
"length": record.packaging_length,
"width": record.width,
"height": record.height,
"max_weight": record.max_weight,
"length_uom": record.length_uom_name,
"weight_uom": record.weight_uom_name,
"barcode": record.barcode,
}
)
7 changes: 4 additions & 3 deletions shopfloor/tests/test_actions_data_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def test_data_location(self):
)

def test_data_packaging(self):
data = self.data_detail.packaging(self.packaging)
self.assert_schema(self.schema_detail.packaging(), data)
self.assertDictEqual(data, self._expected_packaging(self.packaging))
self.packaging.barcode = "barcode"
data = self.data_detail.packaging_detail(self.packaging)
self.assert_schema(self.schema_detail.packaging_detail(), data)
self.assertDictEqual(data, self._expected_packaging_detail(self.packaging))

def test_data_lot(self):
lot = self.env["stock.production.lot"].create(
Expand Down
22 changes: 11 additions & 11 deletions shopfloor_reception/docs/reception_sequence_graph.mermaid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%{init: {'theme': 'neutral' } }%%
sequenceDiagram
participant select_document
participant select_line
participant select_move
participant set_lot
participant set_quantity
participant set_destination
Expand All @@ -10,19 +10,19 @@ sequenceDiagram
note left of select_document: scan_document(barcode)
select_document ->> select_document: Error: barcode not found
select_document ->> select_document: Multiple picking matching the product / packaging barcode
select_document ->> select_line: Picking scanned, one has been found
select_document ->> select_move: Picking scanned, one has been found
select_document ->> set_lot: Packaging / Product has been scanned, single correspondance. Tracked product
select_document ->> set_quantity: Packaging / Product has been scanned, single correspondance. Not tracked product
end
rect rgb(100, 250, 170)
note left of select_line: scan_line(picking_id, barcode)
select_line ->> select_line: Error: barcode not found
select_line ->> set_lot: Packaging / Product has been scanned, single correspondance. Tracked product
select_line ->> set_quantity: Packaging / Product has been scanned, single correspondance. Not tracked product
note left of select_move: scan_line(picking_id, barcode)
select_move ->> select_move: Error: barcode not found
select_move ->> set_lot: Packaging / Product has been scanned, single correspondance. Tracked product
select_move ->> set_quantity: Packaging / Product has been scanned, single correspondance. Not tracked product
end
rect rgb(250, 220, 200)
note left of set_lot: set_lot(picking_id, select_line_ids, lot_name=None, expiration_date=None)
set_lot ->> select_line: User clicked on back
set_lot ->> select_move: User clicked on back
set_lot ->> set_lot: Barcode not found. Ask user to create one from barcode
set_lot ->> set_lot: expiration_date has been set on the selected line
set_lot ->> set_lot: lot_it has been set on the selected line
Expand All @@ -37,8 +37,8 @@ sequenceDiagram
set_quantity ->> set_quantity: Error: User tried to scan a package with a non valid location
set_quantity ->> set_quantity: Error: User tried to scan a non valid location
set_quantity ->> set_quantity: Warning: User scanned an unknown barcode. Ask to create a package
set_quantity ->> select_line: User scanned a package with a valid location
set_quantity ->> select_line: User scanned a valid location
set_quantity ->> select_move: User scanned a package with a valid location
set_quantity ->> select_move: User scanned a valid location
set_quantity ->> set_destination: User scanner a package with no location
note right of set_quantity: process_with_new_pack(picking_id, select_line_ids)
set_quantity ->> set_destination: User confirmed the creation of a new package
Expand All @@ -51,11 +51,11 @@ sequenceDiagram
note left of set_destination: set_destination(picking_id, selected_line_ids, location_id, confirmation=False)
set_destination ->> set_destination: Warning: User scanned a child location of the picking type. Ask for confirmation
set_destination ->> set_destination: Error: User tried to scan a non-valid location
set_destination ->> select_line: User scanned a child location of the move's dest location
set_destination ->> select_move: User scanned a child location of the move's dest location
end
rect rgb(250, 150, 150)
note left of select_dest_package: select_dest_package(picking_id, selected_line_ids, location_id, confirmation=False)
select_dest_package ->> select_line: User scanned a valid package
select_dest_package ->> select_move: User scanned a valid package
select_dest_package ->> select_dest_package: Warning: User scanned an unknown barcode. Confirm to create one.
select_dest_package ->> select_dest_package: Error: User scanned a non-empty package
end
8 changes: 6 additions & 2 deletions shopfloor_reception/services/reception.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _scan_line__assign_user(self, picking, line, qty_done):
self._assign_user_to_line(line)
line.qty_done += qty_done
if product.tracking not in ("lot", "serial") or (line.lot_id or line.lot_name):
return self._response_for_set_quantity(picking, line)
return self._before_state__set_quantity(picking, line)
return self._response_for_set_lot(picking, line)

def _select_line__filter_lines_by_packaging__return(self, lines, packaging):
Expand Down Expand Up @@ -782,6 +782,10 @@ def _align_product_uom_qties(self, move):
for line in lines:
line.product_uom_qty = line.qty_done + remaining_todo

def _before_state__set_quantity(self, picking, line, message=None):
# Used by inherting module see shopfloor_reception_packaging_dimension
return self._response_for_set_quantity(picking, line, message=message)

def _response_for_set_quantity(
self, picking, line, message=None, asking_confirmation=False
):
Expand Down Expand Up @@ -1043,7 +1047,7 @@ def set_lot_confirm_action(self, picking_id, selected_line_id):
message = self._check_expiry_date(selected_line)
if message:
return self._response_for_set_lot(picking, selected_line, message=message)
return self._response_for_set_quantity(picking, selected_line)
return self._before_state__set_quantity(picking, selected_line)

def _check_expiry_date(self, line):
use_expiration_date = (
Expand Down
3 changes: 3 additions & 0 deletions shopfloor_reception_packaging_dimension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .hooks import post_init_hook, uninstall_hook
from . import models
from . import services
16 changes: 16 additions & 0 deletions shopfloor_reception_packaging_dimension/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Shopfloor Reception Packaging Dimension",
"summary": "Collect Packaging Dimension from the Reception scenario",
"version": "14.0.1.0.0",
"development_status": "Beta",
"category": "Inventory",
"website": "https://github.com/OCA/wms",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["TDu"],
"license": "AGPL-3",
"installable": True,
"depends": ["shopfloor_reception"],
"data": ["views/shopfloor_menu.xml"],
"post_init_hook": "post_init_hook",
"uninstall_hook": "uninstall_hook",
}
40 changes: 40 additions & 0 deletions shopfloor_reception_packaging_dimension/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 Camptocamp SA (http://www.camptocamp.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import json
import logging

from odoo import SUPERUSER_ID, api

from odoo.addons.shopfloor_base.utils import purge_endpoints, register_new_services

from .services.reception import Reception as Service

_logger = logging.getLogger(__file__)


def post_init_hook(cr, registry):
_logger.info("Add set packaging dimension option on reception scenario")
env = api.Environment(cr, SUPERUSER_ID, {})
scenario = env.ref("shopfloor_reception.scenario_reception")
options = scenario.options
options.update({"set_packaging_dimension": True})
scenario.options_edit = json.dumps(options)
simahawk marked this conversation as resolved.
Show resolved Hide resolved
# The service imported is extending an existing component
# As it is a simple python import the odoo inheritance is not working
# So it needs to be fix
Service._usage = "reception"
Service._name = "shopfloor.reception"
register_new_services(env, Service)


def uninstall_hook(cr, registry):
_logger.info("Remove set packaging dimension option on reception scenario")
env = api.Environment(cr, SUPERUSER_ID, {})
scenario = env.ref("shopfloor_reception.scenario_reception")
options = scenario.options

Check warning on line 35 in shopfloor_reception_packaging_dimension/hooks.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_reception_packaging_dimension/hooks.py#L32-L35

Added lines #L32 - L35 were not covered by tests
if "set_packaging_dimension" in options.keys():
options.pop("set_packaging_dimension")
scenario.options_edit = json.dumps(options)
Service._usage = "reception"
purge_endpoints(env, Service._usage, endpoint="set_packaging_dimension")

Check warning on line 40 in shopfloor_reception_packaging_dimension/hooks.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_reception_packaging_dimension/hooks.py#L37-L40

Added lines #L37 - L40 were not covered by tests
1 change: 1 addition & 0 deletions shopfloor_reception_packaging_dimension/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import shopfloor_menu
24 changes: 24 additions & 0 deletions shopfloor_reception_packaging_dimension/models/shopfloor_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Camptocamp SA (http://www.camptocamp.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models


class ShopfloorMenu(models.Model):
_inherit = "shopfloor.menu"

set_packaging_dimension_is_possible = fields.Boolean(
compute="_compute_set_packaging_dimension_is_possible"
)
set_packaging_dimension = fields.Boolean(
string="Set packaging dimension",
default=False,
help="If for the product being processed, its related packaging "
"dimension are not set, ask to fill them up.",
)

@api.depends("scenario_id")
def _compute_set_packaging_dimension_is_possible(self):
for menu in self:
menu.set_packaging_dimension_is_possible = menu.scenario_id.has_option(

Check warning on line 22 in shopfloor_reception_packaging_dimension/models/shopfloor_menu.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_reception_packaging_dimension/models/shopfloor_menu.py#L22

Added line #L22 was not covered by tests
"set_packaging_dimension"
)
simahawk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Thierry Ducrest <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module adds an option to the reception scenario.
When activated. Before setting the quantity for the reception,
if there is product packaging related to the product received with
missing information, the user will be presented with a screen
(for each packaging) proposing to update the missing information.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import reception
Loading
Loading