From d9cbd996b008b05186920add2a8054c21edd5d12 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 16 Dec 2019 14:22:45 +0100 Subject: [PATCH] [IMP] stock_vertical_lift: black, isort --- stock_vertical_lift/__manifest__.py | 68 ++-- stock_vertical_lift/controllers/main.py | 14 +- stock_vertical_lift/data/ir_sequence.xml | 18 +- stock_vertical_lift/demo/product_demo.xml | 56 +-- .../demo/stock_inventory_demo.xml | 26 +- .../demo/stock_location_demo.xml | 172 ++++----- .../demo/stock_picking_demo.xml | 86 ++--- .../demo/vertical_lift_shuttle_demo.xml | 30 +- stock_vertical_lift/images/O-BTN.release.svg | 2 +- stock_vertical_lift/images/O-BTN.save.svg | 2 +- stock_vertical_lift/models/stock_location.py | 35 +- stock_vertical_lift/models/stock_move.py | 9 +- stock_vertical_lift/models/stock_quant.py | 11 +- .../models/vertical_lift_command.py | 26 +- .../models/vertical_lift_operation_base.py | 45 +-- .../vertical_lift_operation_inventory.py | 33 +- .../models/vertical_lift_operation_pick.py | 8 +- .../models/vertical_lift_operation_put.py | 33 +- .../models/vertical_lift_shuttle.py | 30 +- .../static/src/js/vertical_lift.js | 192 +++++----- stock_vertical_lift/tests/common.py | 135 ++++--- stock_vertical_lift/tests/test_inventory.py | 32 +- stock_vertical_lift/tests/test_location.py | 25 +- stock_vertical_lift/tests/test_pick.py | 23 +- stock_vertical_lift/tests/test_put.py | 7 +- .../views/shuttle_screen_templates.xml | 26 +- .../views/stock_vertical_lift_templates.xml | 12 +- .../vertical_lift_operation_pick_views.xml | 24 +- .../views/vertical_lift_shuttle_views.xml | 330 +++++++++--------- 29 files changed, 689 insertions(+), 821 deletions(-) diff --git a/stock_vertical_lift/__manifest__.py b/stock_vertical_lift/__manifest__.py index 04b5c5292..f08600727 100644 --- a/stock_vertical_lift/__manifest__.py +++ b/stock_vertical_lift/__manifest__.py @@ -1,41 +1,41 @@ # Copyright 2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'Vertical Lift', - 'summary': 'Provides the core for integration with Vertical Lifts', - 'version': '12.0.1.0.0', - 'category': 'Stock', - 'author': 'Camptocamp, Odoo Community Association (OCA)', - 'license': 'AGPL-3', - 'depends': [ - 'stock', - 'barcodes', - 'base_sparse_field', - 'stock_location_tray', # OCA/stock-logistics-warehouse - 'web_notify', # OCA/web - 'web_ir_actions_act_view_reload', # OCA/web + "name": "Vertical Lift", + "summary": "Provides the core for integration with Vertical Lifts", + "version": "12.0.1.0.0", + "category": "Stock", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "stock", + "barcodes", + "base_sparse_field", + "stock_location_tray", # OCA/stock-logistics-warehouse + "web_notify", # OCA/web + "web_ir_actions_act_view_reload", # OCA/web ], - 'website': 'https://github.com/OCA/stock-logistics-warehouse', - 'demo': [ - 'demo/stock_location_demo.xml', - 'demo/vertical_lift_shuttle_demo.xml', - 'demo/product_demo.xml', - 'demo/stock_inventory_demo.xml', - 'demo/stock_picking_demo.xml', + "website": "https://github.com/OCA/stock-logistics-warehouse", + "demo": [ + "demo/stock_location_demo.xml", + "demo/vertical_lift_shuttle_demo.xml", + "demo/product_demo.xml", + "demo/stock_inventory_demo.xml", + "demo/stock_picking_demo.xml", ], - 'data': [ - 'views/stock_location_views.xml', - 'views/stock_move_line_views.xml', - 'views/vertical_lift_shuttle_views.xml', - 'views/vertical_lift_operation_base_views.xml', - 'views/vertical_lift_operation_pick_views.xml', - 'views/vertical_lift_operation_put_views.xml', - 'views/vertical_lift_operation_inventory_views.xml', - 'views/stock_vertical_lift_templates.xml', - 'views/shuttle_screen_templates.xml', - 'security/ir.model.access.csv', - 'data/ir_sequence.xml', + "data": [ + "views/stock_location_views.xml", + "views/stock_move_line_views.xml", + "views/vertical_lift_shuttle_views.xml", + "views/vertical_lift_operation_base_views.xml", + "views/vertical_lift_operation_pick_views.xml", + "views/vertical_lift_operation_put_views.xml", + "views/vertical_lift_operation_inventory_views.xml", + "views/stock_vertical_lift_templates.xml", + "views/shuttle_screen_templates.xml", + "security/ir.model.access.csv", + "data/ir_sequence.xml", ], - 'installable': True, - 'development_status': 'Alpha', + "installable": True, + "development_status": "Alpha", } diff --git a/stock_vertical_lift/controllers/main.py b/stock_vertical_lift/controllers/main.py index a03af9835..9a11fb152 100644 --- a/stock_vertical_lift/controllers/main.py +++ b/stock_vertical_lift/controllers/main.py @@ -8,13 +8,15 @@ _logger = logging.getLogger(__name__) class VerticalLiftController(http.Controller): - @http.route(['/vertical-lift'], type='http', auth='public', csrf=False) + @http.route(["/vertical-lift"], type="http", auth="public", csrf=False) def vertical_lift(self, answer, secret): - if secret == os.environ.get('VERTICAL_LIFT_SECRET', ''): - rec = request.env['vertical.lift.command'].sudo().record_answer( - answer - ) + if secret == os.environ.get("VERTICAL_LIFT_SECRET", ""): + rec = request.env["vertical.lift.command"].sudo().record_answer(answer) return str(rec.id) else: - _logger.error('secret mismatch: %r != %r', secret, os.environ.get('VERTICAL_LIFT_SECRET', '')) + _logger.error( + "secret mismatch: %r != %r", + secret, + os.environ.get("VERTICAL_LIFT_SECRET", ""), + ) raise http.AuthenticationError() diff --git a/stock_vertical_lift/data/ir_sequence.xml b/stock_vertical_lift/data/ir_sequence.xml index 9b231ed34..1345e7e39 100644 --- a/stock_vertical_lift/data/ir_sequence.xml +++ b/stock_vertical_lift/data/ir_sequence.xml @@ -1,12 +1,10 @@ - - - - Vertical Lift Commands - vertical.lift.command - L - 6 - - - + + + Vertical Lift Commands + vertical.lift.command + L + 6 + + diff --git a/stock_vertical_lift/demo/product_demo.xml b/stock_vertical_lift/demo/product_demo.xml index b55184196..0f59a88a3 100644 --- a/stock_vertical_lift/demo/product_demo.xml +++ b/stock_vertical_lift/demo/product_demo.xml @@ -1,34 +1,34 @@ - - RS200 - 4491673293664 - Running Socks - product - - 30.0 - 20.0 - 1.0 - none - - - - + + RS200 + 4491673293664 + Running Socks + product + + 30.0 + 20.0 + 1.0 + none + + + + - - RS300 - 2779891103531 - Recovery Socks - product - - 30.0 - 20.0 - 1.0 - none - - - - + + RS300 + 2779891103531 + Recovery Socks + product + + 30.0 + 20.0 + 1.0 + none + + + + diff --git a/stock_vertical_lift/demo/stock_inventory_demo.xml b/stock_vertical_lift/demo/stock_inventory_demo.xml index 4b17fcdcd..719b0d5e7 100644 --- a/stock_vertical_lift/demo/stock_inventory_demo.xml +++ b/stock_vertical_lift/demo/stock_inventory_demo.xml @@ -1,20 +1,20 @@ - - Starting Vertical Lift Inventory - + + Starting Vertical Lift Inventory + - - - - - 30.0 - - + + + + + 30.0 + + - - - + + + diff --git a/stock_vertical_lift/demo/stock_location_demo.xml b/stock_vertical_lift/demo/stock_location_demo.xml index 78257a926..b66667e8e 100644 --- a/stock_vertical_lift/demo/stock_location_demo.xml +++ b/stock_vertical_lift/demo/stock_location_demo.xml @@ -14,103 +14,103 @@ - - Shuttle 1 - - internal - + + Shuttle 1 + + internal + - - Tray 1A - T1A - - - internal - + + Tray 1A + T1A + + + internal + - - Tray 1B - T1B - - - internal - + + Tray 1B + T1B + + + internal + - - Tray 1C - T1C - - - internal - + + Tray 1C + T1C + + + internal + - - Shuttle 2 - - internal - + + Shuttle 2 + + internal + - - Tray 2A - T2A - - - internal - + + Tray 2A + T2A + + + internal + - - Tray 2B - T2B - - - internal - + + Tray 2B + T2B + + + internal + - - Tray 2C - T2C - - - internal - + + Tray 2C + T2C + + + internal + - - Tray 2D - T2D - - - internal - + + Tray 2D + T2D + + + internal + - - Shuttle 3 - - internal - + + Shuttle 3 + + internal + - - Tray 3A - T3A - - - internal - + + Tray 3A + T3A + + + internal + - - Tray 3B - T3B - - - internal - + + Tray 3B + T3B + + + internal + - - - - stock_vertical_lift - + + + + stock_vertical_lift + diff --git a/stock_vertical_lift/demo/stock_picking_demo.xml b/stock_vertical_lift/demo/stock_picking_demo.xml index bff48ee18..c41583590 100644 --- a/stock_vertical_lift/demo/stock_picking_demo.xml +++ b/stock_vertical_lift/demo/stock_picking_demo.xml @@ -1,52 +1,52 @@ - - - Outgoing shipment from Vertical Lift (demo) - - - - - - + + + Outgoing shipment from Vertical Lift (demo) + + + + + + - - - + + + - - - + + + - - - Incoming shipment from Vertical Lift (demo) - - - - - - + + + Incoming shipment from Vertical Lift (demo) + + + + + + - - - + + + diff --git a/stock_vertical_lift/demo/vertical_lift_shuttle_demo.xml b/stock_vertical_lift/demo/vertical_lift_shuttle_demo.xml index 435c80f3b..13cab7bcd 100644 --- a/stock_vertical_lift/demo/vertical_lift_shuttle_demo.xml +++ b/stock_vertical_lift/demo/vertical_lift_shuttle_demo.xml @@ -1,22 +1,22 @@ - - Shuttle 1 - - pick - + + Shuttle 1 + + pick + - - Shuttle 2 - - pick - + + Shuttle 2 + + pick + - - Shuttle 3 - - pick - + + Shuttle 3 + + pick + diff --git a/stock_vertical_lift/images/O-BTN.release.svg b/stock_vertical_lift/images/O-BTN.release.svg index 42535a126..3755b9da1 100644 --- a/stock_vertical_lift/images/O-BTN.release.svg +++ b/stock_vertical_lift/images/O-BTN.release.svg @@ -52,4 +52,4 @@ -O-BTN.release \ No newline at end of file +O-BTN.release diff --git a/stock_vertical_lift/images/O-BTN.save.svg b/stock_vertical_lift/images/O-BTN.save.svg index f32e290a8..71a46a893 100644 --- a/stock_vertical_lift/images/O-BTN.save.svg +++ b/stock_vertical_lift/images/O-BTN.save.svg @@ -43,4 +43,4 @@ -O-BTN.save \ No newline at end of file +O-BTN.save diff --git a/stock_vertical_lift/models/stock_location.py b/stock_vertical_lift/models/stock_location.py index 052bb6456..3b7a394be 100644 --- a/stock_vertical_lift/models/stock_location.py +++ b/stock_vertical_lift/models/stock_location.py @@ -10,8 +10,7 @@ class StockLocation(models.Model): vertical_lift_location = fields.Boolean( "Is a Vertical Lift View Location?", default=False, - help="Check this box to use it as the view for Vertical" - " Lift Shuttles.", + help="Check this box to use it as the view for Vertical" " Lift Shuttles.", ) vertical_lift_kind = fields.Selection( selection=[ @@ -29,9 +28,7 @@ class StockLocation(models.Model): # give the unique shuttle for any location in the tree (whether it's a # shuttle, a tray or a cell) inverse_vertical_lift_shuttle_ids = fields.One2many( - comodel_name="vertical.lift.shuttle", - inverse_name="location_id", - readonly=True, + comodel_name="vertical.lift.shuttle", inverse_name="location_id", readonly=True ) # compute the unique shuttle for any shuttle, tray or cell location, by # going through the parents @@ -42,9 +39,7 @@ class StockLocation(models.Model): ) @api.depends( - "location_id", - "location_id.vertical_lift_kind", - "vertical_lift_location", + "location_id", "location_id.vertical_lift_kind", "vertical_lift_location" ) def _compute_vertical_lift_kind(self): tree = {"view": "shuttle", "shuttle": "tray", "tray": "cell"} @@ -57,8 +52,7 @@ class StockLocation(models.Model): location.vertical_lift_kind = kind @api.depends( - "inverse_vertical_lift_shuttle_ids", - "location_id.vertical_lift_shuttle_id", + "inverse_vertical_lift_shuttle_ids", "location_id.vertical_lift_shuttle_id" ) def _compute_vertical_lift_shuttle_id(self): for location in self: @@ -114,20 +108,13 @@ class StockLocation(models.Model): if self.vertical_lift_shuttle_id.hardware == "simulation": message = _("Opening tray {}.").format(self.name) if cell_location: - from_left, from_bottom = ( - cell_location.tray_cell_center_position() - ) - message += _( - "
Laser pointer on x{} y{} ({}mm, {}mm)" - ).format( - cell_location.posx, - cell_location.posy, - from_left, - from_bottom, + from_left, from_bottom = cell_location.tray_cell_center_position() + message += _("
Laser pointer on x{} y{} ({}mm, {}mm)").format( + cell_location.posx, cell_location.posy, from_left, from_bottom ) return message else: - raise NotImplemented() + raise NotImplementedError() def fetch_vertical_lift_tray(self, cell_location=None): """Send instructions to the vertical lift hardware @@ -146,8 +133,7 @@ class StockLocation(models.Model): if self.vertical_lift_kind == "cell": if cell_location: raise ValueError( - "cell_location cannot be set when the location is " - "a cell." + "cell_location cannot be set when the location is a cell." ) tray = self.location_id tray.fetch_vertical_lift_tray(cell_location=self) @@ -155,8 +141,7 @@ class StockLocation(models.Model): self._hardware_vertical_lift_tray(cell_location=cell_location) else: raise exceptions.UserError( - _("Cannot fetch a vertical lift tray on location %s") - % (self.name,) + _("Cannot fetch a vertical lift tray on location %s") % (self.name,) ) return True diff --git a/stock_vertical_lift/models/stock_move.py b/stock_vertical_lift/models/stock_move.py index 42222e716..fe0ca70e3 100644 --- a/stock_vertical_lift/models/stock_move.py +++ b/stock_vertical_lift/models/stock_move.py @@ -17,12 +17,7 @@ class StockMove(models.Model): # count of assigned move lines may change (and we track this in # stock.move, not stock.move.line, because the state of the lines # is a related to this one). - models = ( - "vertical.lift.operation.pick", - "vertical.lift.operation.put", - ) + models = ("vertical.lift.operation.pick", "vertical.lift.operation.put") for model in models: - self.env[model].invalidate_cache( - ["number_of_ops", "number_of_ops_all"] - ) + self.env[model].invalidate_cache(["number_of_ops", "number_of_ops_all"]) return result diff --git a/stock_vertical_lift/models/stock_quant.py b/stock_vertical_lift/models/stock_quant.py index 5a5ba4f86..a31ad9cde 100644 --- a/stock_vertical_lift/models/stock_quant.py +++ b/stock_vertical_lift/models/stock_quant.py @@ -5,19 +5,14 @@ from odoo import models class StockQuant(models.Model): - _inherit = 'stock.quant' + _inherit = "stock.quant" def _update_available_quantity(self, *args, **kwargs): result = super()._update_available_quantity(*args, **kwargs) # We cannot have fields to depends on to invalidate this computed # fields on vertical.lift.operation.* models. But we know that when the # quantity of quant changes, we can invalidate the field - models = ( - "vertical.lift.operation.pick", - "vertical.lift.operation.put", - ) + models = ("vertical.lift.operation.pick", "vertical.lift.operation.put") for model in models: - self.env[model].invalidate_cache( - ["tray_qty"] - ) + self.env[model].invalidate_cache(["tray_qty"]) return result diff --git a/stock_vertical_lift/models/vertical_lift_command.py b/stock_vertical_lift/models/vertical_lift_command.py index 7c25b7f1f..359ea6c22 100644 --- a/stock_vertical_lift/models/vertical_lift_command.py +++ b/stock_vertical_lift/models/vertical_lift_command.py @@ -2,49 +2,47 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import logging -from odoo import api, exceptions, fields, models +from odoo import _, api, exceptions, fields, models _logger = logging.getLogger(__name__) class VerticalLiftCommand(models.Model): - _name = 'vertical.lift.command' - _order = 'shuttle_id, name desc' + _name = "vertical.lift.command" + _order = "shuttle_id, name desc" _description = "commands sent to the shuttle" @api.model def _default_name(self): - return self.env['ir.sequence'].next_by_code('vertical.lift.command') + return self.env["ir.sequence"].next_by_code("vertical.lift.command") - name = fields.Char( - 'Name', default=_default_name, required=True, index=True - ) + name = fields.Char("Name", default=_default_name, required=True, index=True) command = fields.Char(required=True) answer = fields.Char() error = fields.Char() - shuttle_id = fields.Many2one('vertical.lift.shuttle', required=True) + shuttle_id = fields.Many2one("vertical.lift.shuttle", required=True) @api.model def record_answer(self, answer): name = self._get_key(answer) - record = self.search([('name', '=', name)], limit=1) + record = self.search([("name", "=", name)], limit=1) if not record: - _logger.error('unable to match answer to a command: %r', answer) - raise exceptions.UserError('Unknown record %s' % name) + _logger.error("unable to match answer to a command: %r", answer) + raise exceptions.UserError(_("Unknown record %s") % name) record.answer = answer record.shuttle_id._hardware_response_callback(record) return record def _get_key(self, answer): - key = answer.split('|')[1] + key = answer.split("|")[1] return key @api.model_create_multi - @api.returns('self', lambda value: value.id) + @api.returns("self", lambda value: value.id) def create(self, vals_list): for values in vals_list: if "name" not in values: - name = self._get_key(values.get('command')) + name = self._get_key(values.get("command")) if name: values["name"] = name return super().create(vals_list) diff --git a/stock_vertical_lift/models/vertical_lift_operation_base.py b/stock_vertical_lift/models/vertical_lift_operation_base.py index 6108f7418..bd2d471be 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_base.py +++ b/stock_vertical_lift/models/vertical_lift_operation_base.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models + from odoo.addons.base_sparse_field.models.fields import Serialized @@ -16,9 +17,7 @@ class VerticalLiftOperationBase(models.AbstractModel): shuttle_id = fields.Many2one( comodel_name="vertical.lift.shuttle", required=True, readonly=True ) - location_id = fields.Many2one( - related="shuttle_id.location_id", readonly=True - ) + location_id = fields.Many2one(related="shuttle_id.location_id", readonly=True) number_of_ops = fields.Integer( compute="_compute_number_of_ops", string="Number of Operations" ) @@ -27,9 +26,7 @@ class VerticalLiftOperationBase(models.AbstractModel): string="Number of Operations in all shuttles", ) mode = fields.Selection(related="shuttle_id.mode", readonly=True) - operation_descr = fields.Char( - string="Operation", default="...", readonly=True - ) + operation_descr = fields.Char(string="Operation", default="...", readonly=True) _sql_constraints = [ ( @@ -83,17 +80,12 @@ class VerticalLiftOperationBase(models.AbstractModel): for pkg in product.packaging_ids ] } - content = self.env["ir.qweb"].render( - "stock_vertical_lift.packagings", values - ) + content = self.env["ir.qweb"].render("stock_vertical_lift.packagings", values) return content def _get_tray_qty(self, product, location): quants = self.env["stock.quant"].search( - [ - ("location_id", "=", location.id), - ("product_id", "=", product.id), - ] + [("location_id", "=", location.id), ("product_id", "=", product.id)] ) return sum(quants.mapped("quantity")) @@ -112,10 +104,7 @@ class VerticalLiftOperationBase(models.AbstractModel): channel = "notify_vertical_lift_screen" bus_message = { "action": "refresh", - "params": { - "model": self._name, - "id": self.id, - } + "params": {"model": self._name, "id": self.id}, } self.env["bus.bus"].sendone(channel, bus_message) @@ -142,15 +131,11 @@ class VerticalLiftOperationTransfer(models.AbstractModel): compute="_compute_tray_data", string="Tray Type", ) - tray_type_code = fields.Char( - compute="_compute_tray_data", string="Tray Code" - ) + tray_type_code = fields.Char(compute="_compute_tray_data", string="Tray Code") tray_x = fields.Integer(string="X", compute="_compute_tray_data") tray_y = fields.Integer(string="Y", compute="_compute_tray_data") tray_matrix = Serialized(string="Cells", compute="_compute_tray_data") - tray_qty = fields.Float( - string="Stock Quantity", compute="_compute_tray_qty" - ) + tray_qty = fields.Float(string="Stock Quantity", compute="_compute_tray_qty") # current operation information picking_id = fields.Many2one( @@ -174,12 +159,8 @@ class VerticalLiftOperationTransfer(models.AbstractModel): product_packagings = fields.Html( string="Packaging", compute="_compute_product_packagings" ) - qty_done = fields.Float( - related="current_move_line_id.qty_done", readonly=True - ) - lot_id = fields.Many2one( - related="current_move_line_id.lot_id", readonly=True - ) + qty_done = fields.Float(related="current_move_line_id.qty_done", readonly=True) + lot_id = fields.Many2one(related="current_move_line_id.lot_id", readonly=True) location_dest_id = fields.Many2one( string="Destination", related="current_move_line_id.location_dest_id", @@ -217,7 +198,7 @@ class VerticalLiftOperationTransfer(models.AbstractModel): def _compute_tray_qty(self): for record in self: if not (record.tray_location_id and record.current_move_line_id): - record.tray_qty = 0. + record.tray_qty = 0.0 continue product = record.current_move_line_id.product_id location = record.tray_location_id @@ -250,9 +231,7 @@ class VerticalLiftOperationTransfer(models.AbstractModel): def count_move_lines_to_do(self): """Count move lines to process in current shuttles""" self.ensure_one() - return self.env["stock.move.line"].search_count( - self._domain_move_lines_to_do() - ) + return self.env["stock.move.line"].search_count(self._domain_move_lines_to_do()) def count_move_lines_to_do_all(self): """Count move lines to process in all shuttles""" diff --git a/stock_vertical_lift/models/vertical_lift_operation_inventory.py b/stock_vertical_lift/models/vertical_lift_operation_inventory.py index d1a6088ed..52040d974 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_inventory.py +++ b/stock_vertical_lift/models/vertical_lift_operation_inventory.py @@ -2,9 +2,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models -from odoo.addons.base_sparse_field.models.fields import Serialized from odoo.tools import float_compare +from odoo.addons.base_sparse_field.models.fields import Serialized + # TODO handle autofocus + easy way to validate for the input field @@ -24,10 +25,7 @@ class VerticalLiftOperationInventory(models.Model): state = fields.Selection( selection=[ ("quantity", "Inventory, please enter the amount"), - ( - "confirm_wrong_quantity", - "The quantity does not match, are you sure?", - ), + ("confirm_wrong_quantity", "The quantity does not match, are you sure?"), ("save", "Save"), ], default="quantity", @@ -44,15 +42,11 @@ class VerticalLiftOperationInventory(models.Model): compute="_compute_tray_data", string="Tray Type", ) - tray_type_code = fields.Char( - compute="_compute_tray_data", string="Tray Code" - ) + tray_type_code = fields.Char(compute="_compute_tray_data", string="Tray Code") tray_x = fields.Integer(string="X", compute="_compute_tray_data") tray_y = fields.Integer(string="Y", compute="_compute_tray_data") tray_matrix = Serialized(string="Cells", compute="_compute_tray_data") - tray_qty = fields.Float( - string="Stock Quantity", compute="_compute_tray_qty" - ) + tray_qty = fields.Float(string="Stock Quantity", compute="_compute_tray_qty") # current operation information inventory_id = fields.Many2one( @@ -105,10 +99,8 @@ class VerticalLiftOperationInventory(models.Model): @api.depends("tray_location_id", "current_inventory_line_id.product_id") def _compute_tray_qty(self): for record in self: - if not ( - record.tray_location_id and record.current_inventory_line_id - ): - record.tray_qty = 0. + if not (record.tray_location_id and record.current_inventory_line_id): + record.tray_qty = 0.0 continue product = record.current_inventory_line_id.product_id location = record.tray_location_id @@ -151,11 +143,7 @@ class VerticalLiftOperationInventory(models.Model): def reset(self): self.write( - { - "quantity_input": 0., - "last_quantity_input": 0., - "state": "quantity", - } + {"quantity_input": 0.0, "last_quantity_input": 0.0, "state": "quantity"} ) self.update_step_description() @@ -216,7 +204,7 @@ class VerticalLiftOperationInventory(models.Model): return True else: self.last_quantity_input = self.quantity_input - self.quantity_input = 0. + self.quantity_input = 0.0 self.step_to("confirm_wrong_quantity") return False if self.step() == "confirm_wrong_quantity": @@ -255,7 +243,6 @@ class VerticalLiftOperationInventory(models.Model): self.reset() if ( next_line - and previous_line.vertical_lift_tray_id - != next_line.vertical_lift_tray_id + and previous_line.vertical_lift_tray_id != next_line.vertical_lift_tray_id ): self.fetch_tray() diff --git a/stock_vertical_lift/models/vertical_lift_operation_pick.py b/stock_vertical_lift/models/vertical_lift_operation_pick.py index 030541c82..d793ab785 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_pick.py +++ b/stock_vertical_lift/models/vertical_lift_operation_pick.py @@ -11,9 +11,7 @@ class VerticalLiftOperationPick(models.Model): def on_barcode_scanned(self, barcode): self.ensure_one() - location = self.env["stock.location"].search( - [("barcode", "=", barcode)] - ) + location = self.env["stock.location"].search([("barcode", "=", barcode)]) if location: self.current_move_line_id.location_dest_id = location self.operation_descr = _("Save") @@ -65,9 +63,7 @@ class VerticalLiftOperationPick(models.Model): # TODO use a state machine to define next steps and # description? descr = ( - _("Scan New Destination Location") - if next_move_line - else _("No operations") + _("Scan New Destination Location") if next_move_line else _("No operations") ) self.operation_descr = descr if next_move_line: diff --git a/stock_vertical_lift/models/vertical_lift_operation_put.py b/stock_vertical_lift/models/vertical_lift_operation_put.py index 694ca30f9..7309db684 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_put.py +++ b/stock_vertical_lift/models/vertical_lift_operation_put.py @@ -109,9 +109,7 @@ class VerticalLiftOperationPut(models.Model): self.current_operation_line_id.process() def button_release(self): - self.write( - {"operation_line_ids": [(2, self.current_operation_line_id.id)]} - ) + self.write({"operation_line_ids": [(2, self.current_operation_line_id.id)]}) return super().button_release() def button_save(self): @@ -138,9 +136,7 @@ class VerticalLiftOperationPut(models.Model): def action_select_operations(self): self.ensure_one() - menu_xmlid = ( - "stock_vertical_lift." "vertical_lift_operation_put_select_view" - ) + menu_xmlid = "stock_vertical_lift." "vertical_lift_operation_put_select_view" select_model = self.env["vertical.lift.operation.put.select"] select = select_model.create( { @@ -165,13 +161,9 @@ class VerticalLiftOperationPutLine(models.Model): _description = "Vertical Lift Operation Put Line" operation_id = fields.Many2one( - comodel_name="vertical.lift.operation.put", - required=True, - readonly=True, - ) - move_line_id = fields.Many2one( - comodel_name="stock.move.line", readonly=True + comodel_name="vertical.lift.operation.put", required=True, readonly=True ) + move_line_id = fields.Many2one(comodel_name="stock.move.line", readonly=True) def process(self): line = self.move_line_id @@ -186,9 +178,7 @@ class VerticalLiftOperationPutSelect(models.TransientModel): _description = "Vertical Lift Operation Put Select" operation_id = fields.Many2one( - comodel_name="vertical.lift.operation.put", - required=True, - readonly=True, + comodel_name="vertical.lift.operation.put", required=True, readonly=True ) move_line_ids = fields.Many2many(comodel_name="stock.move.line") @@ -197,10 +187,7 @@ class VerticalLiftOperationPutSelect(models.TransientModel): operation_line_model = self.env["vertical.lift.operation.put.line"] operation_line_model.create( [ - { - "operation_id": self.operation_id.id, - "move_line_id": move_line.id, - } + {"operation_id": self.operation_id.id, "move_line_id": move_line.id} for move_line in self.move_line_ids ] ) @@ -217,9 +204,7 @@ class VerticalLiftOperationPutSelect(models.TransientModel): ] def action_add_all(self): - move_lines = self.env["stock.move.line"].search( - self._move_line_domain() - ) + move_lines = self.env["stock.move.line"].search(self._move_line_domain()) self.move_line_ids = move_lines self._sync_lines() return {"type": "ir.actions.act_window_close"} @@ -227,9 +212,7 @@ class VerticalLiftOperationPutSelect(models.TransientModel): def on_barcode_scanned(self, barcode): self.ensure_one() domain = self._move_line_domain() - domain = expression.AND( - [domain, [("product_id.barcode", "=", barcode)]] - ) + domain = expression.AND([domain, [("product_id.barcode", "=", barcode)]]) move_lines = self.env["stock.move.line"].search(domain) # note: on_barcode_scanned is called in an onchange, so 'self' # is a NewID, we can't use 'write()' on it. diff --git a/stock_vertical_lift/models/vertical_lift_shuttle.py b/stock_vertical_lift/models/vertical_lift_shuttle.py index d8b584fe1..79c70f7e6 100644 --- a/stock_vertical_lift/models/vertical_lift_shuttle.py +++ b/stock_vertical_lift/models/vertical_lift_shuttle.py @@ -39,8 +39,7 @@ class VerticalLiftShuttle(models.Model): help="set this if the server expects TLS wrapped communication" ) command_ids = fields.One2many( - 'vertical.lift.command', 'shuttle_id', - string="Hardware commands" + "vertical.lift.command", "shuttle_id", string="Hardware commands" ) _sql_constraints = [ ( @@ -65,17 +64,10 @@ class VerticalLiftShuttle(models.Model): @property def _screen_view_for_mode(self): return { - "pick": ( - "stock_vertical_lift." - "vertical_lift_operation_pick_screen_view" - ), - "put": ( - "stock_vertical_lift." - "vertical_lift_operation_put_screen_view" - ), + "pick": ("stock_vertical_lift." "vertical_lift_operation_pick_screen_view"), + "put": ("stock_vertical_lift." "vertical_lift_operation_put_screen_view"), "inventory": ( - "stock_vertical_lift." - "vertical_lift_operation_inventory_screen_view" + "stock_vertical_lift." "vertical_lift_operation_inventory_screen_view" ), } @@ -90,18 +82,12 @@ class VerticalLiftShuttle(models.Model): """ self.ensure_one() - _logger.info('send %r', payload) - command_values = { - 'shuttle_id': self.id, - 'command': payload.decode(), - } + _logger.info("send %r", payload) + command_values = {"shuttle_id": self.id, "command": payload.decode()} - self.env['vertical.lift.command'].sudo().create( - command_values - ) + self.env["vertical.lift.command"].sudo().create(command_values) if self.hardware == "simulation": - self.env.user.notify_info(message=payload, - title=_("Lift Simulation")) + self.env.user.notify_info(message=payload, title=_("Lift Simulation")) return True else: conn = self._hardware_get_server_connection() diff --git a/stock_vertical_lift/static/src/js/vertical_lift.js b/stock_vertical_lift/static/src/js/vertical_lift.js index 542a06079..1bc89e87c 100644 --- a/stock_vertical_lift/static/src/js/vertical_lift.js +++ b/stock_vertical_lift/static/src/js/vertical_lift.js @@ -1,103 +1,103 @@ odoo.define('stock_vertical_lift.vertical_lift', function (require) { -"use strict"; + "use strict"; -var core = require('web.core'); -var KanbanRecord = require('web.KanbanRecord'); -var basicFields = require('web.basic_fields'); -var field_registry = require('web.field_registry'); -var FormController = require('web.FormController'); -var FieldInteger = basicFields.FieldInteger; + var KanbanRecord = require('web.KanbanRecord'); + var basicFields = require('web.basic_fields'); + var field_registry = require('web.field_registry'); + var FormController = require('web.FormController'); + var FieldInteger = basicFields.FieldInteger; -KanbanRecord.include({ + KanbanRecord.include({ - _openRecord: function () { - if (this.modelName === 'vertical.lift.shuttle' - && this.$el.hasClass("open_shuttle_screen")) { - var self = this; - this._rpc({ - method: 'action_open_screen', - model: self.modelName, - args: [self.id], - }).then(function (action) { - self.trigger_up('do_action', {action: action}); - }); - } else { - this._super.apply(this, arguments); - } - }, - -}); - -var ExitButton = FieldInteger.extend({ - tagName: 'button', - className: 'btn btn-danger btn-block btn-lg o_shuttle_exit', - events: { - 'click': '_onClick', - }, - _render: function () { - this.$el.text(this.string); - }, - _onClick: function () { - // the only reason to have this field widget is to be able - // to inject clear_breadcrumbs in the action: - // it will revert back to a normal - non-headless - view - this.do_action('stock_vertical_lift.vertical_lift_shuttle_action', { - clear_breadcrumbs: true, - }); - }, - -}); - - -FormController.include({ - init: function (parent, model, renderer, params) { - this._super.apply(this, arguments); - if(this.modelName.startsWith('vertical.lift.operation.')) { - this.call('bus_service', 'addChannel', 'notify_vertical_lift_screen'); - this.call( - 'bus_service', 'on', 'notification', - this, this.vlift_bus_notification - ); - this.call('bus_service', 'startPolling'); - } - }, - vlift_bus_notification: function (notifications) { - var self = this; - _.each(notifications, function (notification) { - var channel = notification[0]; - var message = notification[1]; - if(channel === 'notify_vertical_lift_screen') { - switch(message['action']) { - case 'refresh': - self.vlift_bus_action_refresh(message['params']); - break; - } + _openRecord: function () { + if (this.modelName === 'vertical.lift.shuttle' && + this.$el.hasClass("open_shuttle_screen")) { + var self = this; + this._rpc({ + method: 'action_open_screen', + model: self.modelName, + args: [self.id], + }).then(function (action) { + self.trigger_up('do_action', {action: action}); + }); + } else { + this._super.apply(this, arguments); } - }); - }, - vlift_bus_action_refresh: function(params) { - var selectedIds = this.getSelectedIds(); - if(!selectedIds.length){ - return; - } - var currentId = selectedIds[0]; - if(params['id'] === currentId && params['model'] == this.modelName){ - this.reload(); - } - }, - destroy: function () { - if(this.modelName.startsWith('vertical.lift.operation.')) { - this.call('bus_service', 'deleteChannel', 'notify_vertical_lift_screen'); - } - this._super.apply(this, arguments); - } - -}); - -field_registry.add('vlift_shuttle_exit_button', ExitButton); - -return { - ExitButton: ExitButton, -}; + }, + + }); + + var ExitButton = FieldInteger.extend({ + tagName: 'button', + className: 'btn btn-danger btn-block btn-lg o_shuttle_exit', + events: { + 'click': '_onClick', + }, + _render: function () { + this.$el.text(this.string); + }, + _onClick: function () { + // The only reason to have this field widget is to be able + // to inject clear_breadcrumbs in the action: + // it will revert back to a normal - non-headless - view + this.do_action('stock_vertical_lift.vertical_lift_shuttle_action', { + clear_breadcrumbs: true, + }); + }, + + }); + + + FormController.include({ + init: function () { + this._super.apply(this, arguments); + if (this.modelName.startsWith('vertical.lift.operation.')) { + this.call('bus_service', 'addChannel', 'notify_vertical_lift_screen'); + this.call( + 'bus_service', 'on', 'notification', + this, this.vlift_bus_notification, + ); + this.call('bus_service', 'startPolling'); + } + }, + vlift_bus_notification: function (notifications) { + var self = this; + _.each(notifications, function (notification) { + var channel = notification[0]; + var message = notification[1]; + if (channel === 'notify_vertical_lift_screen') { + switch (message.action) { + case 'refresh': + self.vlift_bus_action_refresh(message.params); + break; + } + } + }); + }, + vlift_bus_action_refresh: function (params) { + var selectedIds = this.getSelectedIds(); + if (!selectedIds.length) { + return; + } + var currentId = selectedIds[0]; + if (params.id === currentId && params.model === this.modelName) { + this.reload(); + } + }, + destroy: function () { + if (this.modelName.startsWith('vertical.lift.operation.')) { + this.call('bus_service', 'deleteChannel', + 'notify_vertical_lift_screen'); + } + this._super.apply(this, arguments); + }, + + }); + + field_registry.add('vlift_shuttle_exit_button', ExitButton); + + return { + ExitButton: ExitButton, + }; }); diff --git a/stock_vertical_lift/tests/common.py b/stock_vertical_lift/tests/common.py index 0a6b613bc..29190936c 100644 --- a/stock_vertical_lift/tests/common.py +++ b/stock_vertical_lift/tests/common.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _ + from odoo.addons.stock_location_tray.tests import common @@ -10,83 +11,68 @@ class VerticalLiftCase(common.LocationTrayTypeCase): def setUpClass(cls): super().setUpClass() cls.shuttle = cls.env.ref( - 'stock_vertical_lift.stock_vertical_lift_demo_shuttle_1' - ) - cls.product_socks = cls.env.ref( - 'stock_vertical_lift.product_running_socks' - ) - cls.product_recovery = cls.env.ref( - 'stock_vertical_lift.product_recovery_socks' + "stock_vertical_lift.stock_vertical_lift_demo_shuttle_1" ) + cls.product_socks = cls.env.ref("stock_vertical_lift.product_running_socks") + cls.product_recovery = cls.env.ref("stock_vertical_lift.product_recovery_socks") cls.vertical_lift_loc = cls.env.ref( - 'stock_vertical_lift.stock_location_vertical_lift' + "stock_vertical_lift.stock_location_vertical_lift" ) cls.location_1a = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a" ) cls.location_1a_x1y1 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x1y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x1y1" ) cls.location_1a_x2y1 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x2y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x2y1" ) cls.location_1a_x3y1 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x3y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x3y1" ) cls.location_1a_x1y2 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x1y2" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x1y2" ) cls.location_1b_x1y1 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1b_x1y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1b_x1y1" ) cls.location_1b_x1y2 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1b_x1y2" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1b_x1y2" ) cls.location_2a = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_2a" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_2a" ) cls.location_2a_x1y1 = cls.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_2a_x1y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_2a_x1y1" ) def _update_qty_in_location(self, location, product, quantity): - self.env["stock.quant"]._update_available_quantity( - product, location, quantity - ) + self.env["stock.quant"]._update_available_quantity(product, location, quantity) @classmethod def _create_simple_picking_out(cls, product, quantity): - stock_loc = cls.env.ref('stock.stock_location_stock') - customer_loc = cls.env.ref('stock.stock_location_customers') - picking_type = cls.env.ref('stock.picking_type_out') - partner = cls.env.ref('base.res_partner_1') - return cls.env['stock.picking'].create( + stock_loc = cls.env.ref("stock.stock_location_stock") + customer_loc = cls.env.ref("stock.stock_location_customers") + picking_type = cls.env.ref("stock.picking_type_out") + partner = cls.env.ref("base.res_partner_1") + return cls.env["stock.picking"].create( { - 'picking_type_id': picking_type.id, - 'partner_id': partner.id, - 'location_id': stock_loc.id, - 'location_dest_id': customer_loc.id, - 'move_lines': [ + "picking_type_id": picking_type.id, + "partner_id": partner.id, + "location_id": stock_loc.id, + "location_dest_id": customer_loc.id, + "move_lines": [ ( 0, 0, { - 'name': product.name, - 'product_id': product.id, - 'product_uom': product.uom_id.id, - 'product_uom_qty': quantity, - 'picking_type_id': picking_type.id, - 'location_id': stock_loc.id, - 'location_dest_id': customer_loc.id, + "name": product.name, + "product_id": product.id, + "product_uom": product.uom_id.id, + "product_uom_qty": quantity, + "picking_type_id": picking_type.id, + "location_id": stock_loc.id, + "location_dest_id": customer_loc.id, }, ) ], @@ -95,27 +81,27 @@ class VerticalLiftCase(common.LocationTrayTypeCase): @classmethod def _create_simple_picking_in(cls, product, quantity, dest_location): - supplier_loc = cls.env.ref('stock.stock_location_suppliers') - picking_type = cls.env.ref('stock.picking_type_in') - partner = cls.env.ref('base.res_partner_1') - return cls.env['stock.picking'].create( + supplier_loc = cls.env.ref("stock.stock_location_suppliers") + picking_type = cls.env.ref("stock.picking_type_in") + partner = cls.env.ref("base.res_partner_1") + return cls.env["stock.picking"].create( { - 'picking_type_id': picking_type.id, - 'partner_id': partner.id, - 'location_id': supplier_loc.id, - 'location_dest_id': dest_location.id, - 'move_lines': [ + "picking_type_id": picking_type.id, + "partner_id": partner.id, + "location_id": supplier_loc.id, + "location_dest_id": dest_location.id, + "move_lines": [ ( 0, 0, { - 'name': product.name, - 'product_id': product.id, - 'product_uom': product.uom_id.id, - 'product_uom_qty': quantity, - 'picking_type_id': picking_type.id, - 'location_id': supplier_loc.id, - 'location_dest_id': dest_location.id, + "name": product.name, + "product_id": product.id, + "product_uom": product.uom_id.id, + "product_uom_qty": quantity, + "picking_type_id": picking_type.id, + "location_id": supplier_loc.id, + "location_dest_id": dest_location.id, }, ) ], @@ -123,21 +109,28 @@ class VerticalLiftCase(common.LocationTrayTypeCase): ) @classmethod - def _create_inventory(self, products): + def _create_inventory(cls, products): """Create a draft inventory Products is a list of tuples (bin location, product). """ values = { - 'name': 'Test Inventory', - 'filter': 'partial', - 'line_ids': [(0, 0, { - 'product_id': product.id, - 'product_uom_id': product.uom_id.id, - 'location_id': location.id - }) for location, product in products] + "name": "Test Inventory", + "filter": "partial", + "line_ids": [ + ( + 0, + 0, + { + "product_id": product.id, + "product_uom_id": product.uom_id.id, + "location_id": location.id, + }, + ) + for location, product in products + ], } - inventory = self.env['stock.inventory'].create(values) + inventory = cls.env["stock.inventory"].create(values) inventory.action_start() return inventory diff --git a/stock_vertical_lift/tests/test_inventory.py b/stock_vertical_lift/tests/test_inventory.py index 68caaf609..b911d01d2 100644 --- a/stock_vertical_lift/tests/test_inventory.py +++ b/stock_vertical_lift/tests/test_inventory.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _ + from .common import VerticalLiftCase @@ -19,27 +20,19 @@ class TestInventory(VerticalLiftCase): action = self.shuttle.action_open_screen() operation = self.shuttle._operation_for_mode() self.assertEqual(action["type"], "ir.actions.act_window") - self.assertEqual( - action["res_model"], "vertical.lift.operation.inventory" - ) + self.assertEqual(action["res_model"], "vertical.lift.operation.inventory") self.assertEqual(action["res_id"], operation.id) def test_inventory_count_ops(self): - self._update_qty_in_location( - self.location_1a_x1y1, self.product_socks, 10 - ) - self._update_qty_in_location( - self.location_1a_x2y1, self.product_recovery, 10 - ) + self._update_qty_in_location(self.location_1a_x1y1, self.product_socks, 10) + self._update_qty_in_location(self.location_1a_x2y1, self.product_recovery, 10) self._create_inventory( [ (self.location_1a_x1y1, self.product_socks), (self.location_1a_x2y1, self.product_recovery), ] ) - self._update_qty_in_location( - self.location_2a_x1y1, self.product_socks, 10 - ) + self._update_qty_in_location(self.location_2a_x1y1, self.product_socks, 10) self._create_inventory([(self.location_2a_x1y1, self.product_socks)]) self.shuttle.switch_inventory() @@ -48,17 +41,13 @@ class TestInventory(VerticalLiftCase): self.assertEqual(operation.number_of_ops_all, 3) def test_process_current_inventory(self): - self._update_qty_in_location( - self.location_1a_x1y1, self.product_socks, 10 - ) + self._update_qty_in_location(self.location_1a_x1y1, self.product_socks, 10) inventory = self._create_inventory( [(self.location_1a_x1y1, self.product_socks)] ) self.shuttle.switch_inventory() operation = self.shuttle._operation_for_mode() - self.assertEqual( - operation.current_inventory_line_id, inventory.line_ids - ) + self.assertEqual(operation.current_inventory_line_id, inventory.line_ids) # test the happy path, quantity is correct operation.quantity_input = 10.0 result = operation.button_save() @@ -79,9 +68,7 @@ class TestInventory(VerticalLiftCase): self.assertEqual(result, expected_result) def test_wrong_quantity(self): - self._update_qty_in_location( - self.location_1a_x1y1, self.product_socks, 10 - ) + self._update_qty_in_location(self.location_1a_x1y1, self.product_socks, 10) inventory = self._create_inventory( [(self.location_1a_x1y1, self.product_socks)] ) @@ -97,8 +84,7 @@ class TestInventory(VerticalLiftCase): self.assertEqual(operation.state, "confirm_wrong_quantity") self.assertEqual(operation.current_inventory_line_id, line) self.assertEqual( - operation.operation_descr, - _("The quantity does not match, are you sure?"), + operation.operation_descr, _("The quantity does not match, are you sure?") ) # entering the same quantity a second time validates diff --git a/stock_vertical_lift/tests/test_location.py b/stock_vertical_lift/tests/test_location.py index 710c9cdc0..712436d73 100644 --- a/stock_vertical_lift/tests/test_location.py +++ b/stock_vertical_lift/tests/test_location.py @@ -9,32 +9,29 @@ class TestVerticalLiftLocation(VerticalLiftCase): # this boolean is what defines a "Vertical Lift View", the upper level # of the tree (View -> Shuttles -> Trays -> Cells) self.assertTrue(self.vertical_lift_loc.vertical_lift_location) - self.assertEqual(self.vertical_lift_loc.vertical_lift_kind, 'view') + self.assertEqual(self.vertical_lift_loc.vertical_lift_kind, "view") # check types accross the hierarchy shuttles = self.vertical_lift_loc.child_ids self.assertTrue( - all( - location.vertical_lift_kind == 'shuttle' - for location in shuttles - ) + all(location.vertical_lift_kind == "shuttle" for location in shuttles) ) - trays = shuttles.mapped('child_ids') + trays = shuttles.mapped("child_ids") self.assertTrue( - all(location.vertical_lift_kind == 'tray' for location in trays) + all(location.vertical_lift_kind == "tray" for location in trays) ) - cells = trays.mapped('child_ids') + cells = trays.mapped("child_ids") self.assertTrue( - all(location.vertical_lift_kind == 'cell' for location in cells) + all(location.vertical_lift_kind == "cell" for location in cells) ) def test_create_shuttle(self): # any location created directly under the view is a shuttle - shuttle_loc = self.env['stock.location'].create( + shuttle_loc = self.env["stock.location"].create( { - 'name': 'Shuttle 42', - 'location_id': self.vertical_lift_loc.id, - 'usage': 'internal', + "name": "Shuttle 42", + "location_id": self.vertical_lift_loc.id, + "usage": "internal", } ) - self.assertEqual(shuttle_loc.vertical_lift_kind, 'shuttle') + self.assertEqual(shuttle_loc.vertical_lift_kind, "shuttle") diff --git a/stock_vertical_lift/tests/test_pick.py b/stock_vertical_lift/tests/test_pick.py index 894eb5fa6..6d17dd831 100644 --- a/stock_vertical_lift/tests/test_pick.py +++ b/stock_vertical_lift/tests/test_pick.py @@ -21,8 +21,7 @@ class TestPick(VerticalLiftCase): self.shuttle.switch_pick() self.assertEqual(self.shuttle.mode, "pick") self.assertEqual( - self.shuttle._operation_for_mode().current_move_line_id, - self.out_move_line, + self.shuttle._operation_for_mode().current_move_line_id, self.out_move_line ) def test_pick_action_open_screen(self): @@ -39,9 +38,7 @@ class TestPick(VerticalLiftCase): operation = self.shuttle._operation_for_mode() operation.select_next_move_line() self.assertEqual(operation.current_move_line_id, self.out_move_line) - self.assertEqual( - operation.operation_descr, _("Scan New Destination Location") - ) + self.assertEqual(operation.operation_descr, _("Scan New Destination Location")) def test_pick_save(self): self.shuttle.switch_pick() @@ -71,8 +68,7 @@ class TestPick(VerticalLiftCase): ml.location_id.location_id.tray_type_id, ) self.assertEqual( - operation.tray_type_code, - ml.location_id.location_id.tray_type_id.code, + operation.tray_type_code, ml.location_id.location_id.tray_type_id.code ) self.assertEqual(operation.tray_x, ml.location_id.posx) self.assertEqual(operation.tray_y, ml.location_id.posy) @@ -80,9 +76,7 @@ class TestPick(VerticalLiftCase): # Move line related fields self.assertEqual(operation.picking_id, ml.picking_id) self.assertEqual(operation.picking_origin, ml.picking_id.origin) - self.assertEqual( - operation.picking_partner_id, ml.picking_id.partner_id - ) + self.assertEqual(operation.picking_partner_id, ml.picking_id.partner_id) self.assertEqual(operation.product_id, ml.product_id) self.assertEqual(operation.product_uom_id, ml.product_uom_id) self.assertEqual(operation.product_uom_qty, ml.product_uom_qty) @@ -100,13 +94,11 @@ class TestPick(VerticalLiftCase): # ensure that we have stock in some cells, we'll put product1 # in the first Shuttle and product2 in the second cell1 = self.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x3y2" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x3y2" ) self._update_quantity_in_cell(cell1, product1, 50) cell2 = self.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_2a_x1y1" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_2a_x1y1" ) self._update_quantity_in_cell(cell2, product2, 50) @@ -203,8 +195,7 @@ class TestPick(VerticalLiftCase): def test_tray_qty(self): cell = self.env.ref( - "stock_vertical_lift." - "stock_location_vertical_lift_demo_tray_1a_x3y2" + "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_1a_x3y2" ) self.out_move_line.location_id = cell operation = self.shuttle._operation_for_mode() diff --git a/stock_vertical_lift/tests/test_put.py b/stock_vertical_lift/tests/test_put.py index d3f391100..4ddbaf863 100644 --- a/stock_vertical_lift/tests/test_put.py +++ b/stock_vertical_lift/tests/test_put.py @@ -56,13 +56,10 @@ class TestPut(VerticalLiftCase): operation = self.shuttle._operation_for_mode() select = select_model.create({"operation_id": operation.id}) select.on_barcode_scanned(self.product_socks.barcode) - self.assertRecordValues( - select, [{"move_line_ids": put1.move_line_ids.ids}] - ) + self.assertRecordValues(select, [{"move_line_ids": put1.move_line_ids.ids}]) select.on_barcode_scanned(self.product_recovery.barcode) self.assertRecordValues( - select, - [{"move_line_ids": (put1.move_line_ids | put2.move_line_ids).ids}], + select, [{"move_line_ids": (put1.move_line_ids | put2.move_line_ids).ids}] ) select.action_validate() self.assertEqual(len(operation.operation_line_ids), 2) diff --git a/stock_vertical_lift/views/shuttle_screen_templates.xml b/stock_vertical_lift/views/shuttle_screen_templates.xml index 3301f4ca7..5d017220a 100644 --- a/stock_vertical_lift/views/shuttle_screen_templates.xml +++ b/stock_vertical_lift/views/shuttle_screen_templates.xml @@ -1,17 +1,17 @@ - + diff --git a/stock_vertical_lift/views/stock_vertical_lift_templates.xml b/stock_vertical_lift/views/stock_vertical_lift_templates.xml index d1931819c..11f1a3cf5 100644 --- a/stock_vertical_lift/views/stock_vertical_lift_templates.xml +++ b/stock_vertical_lift/views/stock_vertical_lift_templates.xml @@ -1,11 +1,11 @@ - + diff --git a/stock_vertical_lift/views/vertical_lift_operation_pick_views.xml b/stock_vertical_lift/views/vertical_lift_operation_pick_views.xml index 6d538fdcb..ecc137b51 100644 --- a/stock_vertical_lift/views/vertical_lift_operation_pick_views.xml +++ b/stock_vertical_lift/views/vertical_lift_operation_pick_views.xml @@ -13,17 +13,17 @@ - - vertical.lift.operation.pick.screen.view - vertical.lift.operation.pick - - 100 - primary - -
- Pick Screen -
-
-
+ + vertical.lift.operation.pick.screen.view + vertical.lift.operation.pick + + 100 + primary + +
+ Pick Screen +
+
+
diff --git a/stock_vertical_lift/views/vertical_lift_shuttle_views.xml b/stock_vertical_lift/views/vertical_lift_shuttle_views.xml index 2f81f5d30..427196b30 100644 --- a/stock_vertical_lift/views/vertical_lift_shuttle_views.xml +++ b/stock_vertical_lift/views/vertical_lift_shuttle_views.xml @@ -1,176 +1,176 @@ - - vertical.lift.shuttle.view.form.menu - vertical.lift.shuttle - 100 - -
-
-
-
-
- -
-
-
-
-
-
- - - vertical.lift.shuttle.manual.barcode.view.form - vertical.lift.shuttle.manual.barcode - -
-
-
- -
-
-
-
-
-
-
-
- - - vertical.lift.shuttle.view.form - vertical.lift.shuttle - -
- - - - - - - - - - - - - - - -
-
-
- - - vertical.lift.shuttle.kanban - vertical.lift.shuttle - - - - - - - - -
-
- -
-
-
- - - + + vertical.lift.shuttle.view.form.menu + vertical.lift.shuttle + 100 + +
+
+
+
-
-
- Mode: +
+ +
+
+
+ + + + + + vertical.lift.shuttle.manual.barcode.view.form + vertical.lift.shuttle.manual.barcode + +
+
+
+ +
+
+
+
+
+
+
+
+ + + vertical.lift.shuttle.view.form + vertical.lift.shuttle + +
+ + + -
- - - - - - - - -
-
-
+ + + + + + + + + + + + + + - - -
-
- - - - - + + vertical.lift.shuttle.kanban + vertical.lift.shuttle + + + + + + + + +
+
- - vertical.lift.shuttle.tree - vertical.lift.shuttle - - - - - - +
+
+
+ + + +
+
+
+ Mode: + +
+ + + + + + + + +
+
+
- - Vertical Lift Shuttles - ir.actions.act_window - vertical.lift.shuttle - form - kanban,tree,form - current - [] - {} - -

- Open the Shuttle Interface. -

-
-
+ + +
+
+
+
+
+
+
- + + vertical.lift.shuttle.tree + vertical.lift.shuttle + + + + + + + + + Vertical Lift Shuttles + ir.actions.act_window + vertical.lift.shuttle + form + kanban,tree,form + current + [] + {} + +

+ Open the Shuttle Interface. +

+
+
+ +