From 16f5c9e95568255d89ca7e472638734a52e04793 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 13 Feb 2023 23:44:01 +0100 Subject: [PATCH] [ADD] stock_quant_package_move_wizard --- stock_quant_package_move_wizard/README.rst | 20 ++ stock_quant_package_move_wizard/__init__.py | 2 + .../__manifest__.py | 29 +++ stock_quant_package_move_wizard/i18n/fr.po | 223 ++++++++++++++++++ .../i18n/stock_quant_package_move_wizard.pot | 214 +++++++++++++++++ .../models/__init__.py | 1 + .../models/stock_quant.py | 126 ++++++++++ .../security/ir.model.access.csv | 3 + .../views/stock_quant.xml | 28 +++ .../wizards/__init__.py | 1 + .../wizards/stock_quant_move_wizard.py | 114 +++++++++ .../wizards/stock_quant_move_wizard_view.xml | 54 +++++ 12 files changed, 815 insertions(+) create mode 100644 stock_quant_package_move_wizard/README.rst create mode 100644 stock_quant_package_move_wizard/__init__.py create mode 100644 stock_quant_package_move_wizard/__manifest__.py create mode 100644 stock_quant_package_move_wizard/i18n/fr.po create mode 100644 stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot create mode 100644 stock_quant_package_move_wizard/models/__init__.py create mode 100644 stock_quant_package_move_wizard/models/stock_quant.py create mode 100644 stock_quant_package_move_wizard/security/ir.model.access.csv create mode 100644 stock_quant_package_move_wizard/views/stock_quant.xml create mode 100644 stock_quant_package_move_wizard/wizards/__init__.py create mode 100644 stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py create mode 100644 stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml diff --git a/stock_quant_package_move_wizard/README.rst b/stock_quant_package_move_wizard/README.rst new file mode 100644 index 0000000..62de10f --- /dev/null +++ b/stock_quant_package_move_wizard/README.rst @@ -0,0 +1,20 @@ +Module Stock Quant Package Moving Wizard +========================================= + +This module provides a **super fast** and **super easy** way of moving a quant to another stock location. + +Usage +===== + +1. Select one or several quants +2. Click on the *Move* button +3. Follow the instructions on the wizard: select a picking type (or a destination stock location) and, if you don't want to move the full quant, edit the quantity to move. +4. Validate the wizard + +Contributors +============ + +* Alexis de Lattre +* Oihane Crucelaegui +* Pedro M. Baeza +* Ana Juaristi diff --git a/stock_quant_package_move_wizard/__init__.py b/stock_quant_package_move_wizard/__init__.py new file mode 100644 index 0000000..aee8895 --- /dev/null +++ b/stock_quant_package_move_wizard/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/stock_quant_package_move_wizard/__manifest__.py b/stock_quant_package_move_wizard/__manifest__.py new file mode 100644 index 0000000..23b6376 --- /dev/null +++ b/stock_quant_package_move_wizard/__manifest__.py @@ -0,0 +1,29 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "Quant & Package moving wizard", + "summary": "Select a quant Move quants to another location in a few clicks", + "category": "Inventory/Inventory", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "depends": ["stock"], + "author": "AvanzOSC, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Akretion", + "maintainers": ["alexis-via"], + "website": "https://github.com/akretion/odoo-usability", + "contributors": [ + "Oihane Crucelaegui ", + "Pedro M. Baeza ", + "Ana Juaristi ", + "Alexis de Lattre ", + ], + "data": [ + # "wizards/quants_move_wizard_view.xml", + "security/ir.model.access.csv", + "wizards/stock_quant_move_wizard_view.xml", + "views/stock_quant.xml", + # "views/stock_quant_package.xml", + ], + "installable": True, +} diff --git a/stock_quant_package_move_wizard/i18n/fr.po b/stock_quant_package_move_wizard/i18n/fr.po new file mode 100644 index 0000000..2d23d3d --- /dev/null +++ b/stock_quant_package_move_wizard/i18n/fr.po @@ -0,0 +1,223 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_package_move_wizard +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-02-13 21:59+0000\n" +"PO-Revision-Date: 2023-02-13 21:59+0000\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_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Cancel" +msgstr "Annuler" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "Cannot move to '%s' which is a view location." +msgstr "Impossible de déplacer vers '%s' qui est un emplacement de type Vue." + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__company_id +msgid "Company" +msgstr "Société" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__create_uid +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__create_date +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__create_date +msgid "Created on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__src_location_id +msgid "Current Location" +msgstr "Emplacement actuel" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,help:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__uom_id +msgid "Default unit of measure used for all stock operations." +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__location_dest_id +msgid "Destination Location" +msgstr "Emplacement destination" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__display_name +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__id +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__id +msgid "ID" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard____last_update +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__write_uid +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__write_date +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__line_ids +msgid "Lines" +msgstr "Lignes" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant_move_wizard_line +msgid "Lines of the wizard to move quants" +msgstr "Lignes de l'assistant de déplacement des quants" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__lot_id +msgid "Lot/Serial Number" +msgstr "Lot/numéro de série" + +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Move" +msgstr "Déplacer" + +#. module: stock_quant_package_move_wizard +#: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action +msgid "Move to Another Location" +msgstr "Déplacer vers un autre emplacement" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_quantity +msgid "On Hand Qty" +msgstr "Qté en stock" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__picking_type_id +msgid "Picking Type" +msgstr "Type d'opération" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__product_id +msgid "Product" +msgstr "Article" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quantity +msgid "Qty to Move" +msgstr "Qté à déplacer" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_id +msgid "Quant" +msgstr "Quant" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__wizard_id +msgid "Quant Move" +msgstr "Déplacer Quant" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,help:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_quantity +msgid "" +"Quantity of products in this quant, in the default unit of measure of the " +"product" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant +msgid "Quants" +msgstr "Quants" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__origin +msgid "Source Document" +msgstr "Document source" + +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Unit" +msgstr "Unité" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__uom_id +msgid "Unit of Measure" +msgstr "Unité de mesure" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant_move_wizard +msgid "Wizard to Move Quants" +msgstr "Assistant de déplacement de quants" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s that has a quantity of %(quant_quantity)s %(uom)s." +msgstr "" +"Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " +"%(product_name)s dont la quantité est de %(quant_quantity)s %(uom)s." + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s to %(dest_location)s, but it is already on that location!" +msgstr "" +"Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " +"%(product_name)s vers %(dest_location)s, mais il est déjà sur cet emplacement !" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s, but that quant has a negative quantity (%(quant_quantity)s" +" %(uom)s)." +msgstr "" +"Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " +"%(product_name)s, mais ce quant est en quantité négative (%(quant_quantity)s" +" %(uom)s)." + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s: the quantity to move must be strictly positive." +msgstr "" +"Vous essayez de déplacer %(qty)s %(uom)s d'un quant de l'article " +"%(product_name)s : la quantité à déplacer doit être strictement positive." diff --git a/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot b/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot new file mode 100644 index 0000000..1ae8ef3 --- /dev/null +++ b/stock_quant_package_move_wizard/i18n/stock_quant_package_move_wizard.pot @@ -0,0 +1,214 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_package_move_wizard +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-02-13 21:58+0000\n" +"PO-Revision-Date: 2023-02-13 21:58+0000\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_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Cancel" +msgstr "" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "Cannot move to '%s' which is a view location." +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__company_id +msgid "Company" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__create_uid +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__create_date +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__create_date +msgid "Created on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__src_location_id +msgid "Current Location" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,help:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__uom_id +msgid "Default unit of measure used for all stock operations." +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__location_dest_id +msgid "Destination Location" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__display_name +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__id +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__id +msgid "ID" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard____last_update +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__write_uid +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__write_date +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__line_ids +msgid "Lines" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant_move_wizard_line +msgid "Lines of the wizard to move quants" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__lot_id +msgid "Lot/Serial Number" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Move" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.actions.act_window,name:stock_quant_package_move_wizard.stock_quant_move_wizard_action +msgid "Move to Another Location" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_quantity +msgid "On Hand Qty" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__picking_type_id +msgid "Picking Type" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__product_id +msgid "Product" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quantity +msgid "Qty to Move" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_id +msgid "Quant" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__wizard_id +msgid "Quant Move" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,help:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__quant_quantity +msgid "" +"Quantity of products in this quant, in the default unit of measure of the " +"product" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard__origin +msgid "Source Document" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model_terms:ir.ui.view,arch_db:stock_quant_package_move_wizard.stock_quant_move_wizard_form +msgid "Unit" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model.fields,field_description:stock_quant_package_move_wizard.field_stock_quant_move_wizard_line__uom_id +msgid "Unit of Measure" +msgstr "" + +#. module: stock_quant_package_move_wizard +#: model:ir.model,name:stock_quant_package_move_wizard.model_stock_quant_move_wizard +msgid "Wizard to Move Quants" +msgstr "" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s that has a quantity of %(quant_quantity)s %(uom)s." +msgstr "" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s to %(dest_location)s, but it is already on that location!" +msgstr "" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s, but that quant has a negative quantity (%(quant_quantity)s" +" %(uom)s)." +msgstr "" + +#. module: stock_quant_package_move_wizard +#. odoo-python +#: code:addons/stock_quant_package_move_wizard/models/stock_quant.py:0 +#, python-format +msgid "" +"You are trying to move %(qty)s %(uom)s of a quant of product " +"%(product_name)s: the quantity to move must be strictly positive." +msgstr "" diff --git a/stock_quant_package_move_wizard/models/__init__.py b/stock_quant_package_move_wizard/models/__init__.py new file mode 100644 index 0000000..70f8e6c --- /dev/null +++ b/stock_quant_package_move_wizard/models/__init__.py @@ -0,0 +1 @@ +from . import stock_quant diff --git a/stock_quant_package_move_wizard/models/stock_quant.py b/stock_quant_package_move_wizard/models/stock_quant.py new file mode 100644 index 0000000..cd3ac10 --- /dev/null +++ b/stock_quant_package_move_wizard/models/stock_quant.py @@ -0,0 +1,126 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import _, models +from odoo.exceptions import UserError +from odoo.tools import float_compare +from odoo.tools.misc import formatLang + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def _prepare_move_to_stock_move(self, qty, dest_location, picking_id, origin=False): + # qty is in the product's uom_id + self.ensure_one() + if dest_location.usage == "view": + raise UserError( + _("Cannot move to '%s' which is a view location.") + % dest_location.display_name + ) + prec = self.env["decimal.precision"].precision_get("Product Unit of Measure") + raise_dict = { + "qty": formatLang(self.env, qty, digits=prec), + "uom": self.product_id.uom_id.display_name, + "product_name": self.product_id.display_name, + "dest_location": dest_location.display_name, + "quant_quantity": formatLang(self.env, self.quantity, digits=prec), + } + if self.location_id == dest_location: + raise UserError( + _( + "You are trying to move %(qty)s %(uom)s of a quant of product " + "%(product_name)s to %(dest_location)s, but it is already on " + "that location!" + ) + % raise_dict + ) + if float_compare(qty, self.quantity, precision_digits=prec) > 0: + raise UserError( + _( + "You are trying to move %(qty)s %(uom)s of a quant of product " + "%(product_name)s that has a quantity of " + "%(quant_quantity)s %(uom)s." + ) + % raise_dict + ) + if float_compare(self.quantity, 0, precision_digits=prec) <= 0: + raise UserError( + _( + "You are trying to move %(qty)s %(uom)s of a quant of product " + "%(product_name)s, but that quant has a negative quantity " + "(%(quant_quantity)s %(uom)s)." + ) + % raise_dict + ) + if float_compare(qty, 0, precision_digits=prec) <= 0: + raise UserError( + _( + "You are trying to move %(qty)s %(uom)s of a quant of product " + "%(product_name)s: the quantity to move must be strictly positive." + ) + % raise_dict + ) + product_id = self.product_id.id + location_id = self.location_id.id + location_dest_id = dest_location.id + uom_id = self.product_id.uom_id.id + vals = { + "picking_id": picking_id, + "name": "%s: Move to %s" + % (self.product_id.display_name, dest_location.display_name), + "product_id": product_id, + "location_id": location_id, + "location_dest_id": location_dest_id, + "product_uom_qty": qty, + "product_uom": uom_id, + "origin": origin, + "move_line_ids": [ + ( + 0, + 0, + { + "product_id": product_id, + "product_uom_id": uom_id, + "qty_done": qty, + "location_id": location_id, + "location_dest_id": location_dest_id, + "lot_id": self.lot_id.id or False, + }, + ) + ], + } + return vals + + def _prepare_move_to_stock_picking(self, dest_location, picking_type, origin=False): + vals = { + "picking_type_id": picking_type.id, + "location_dest_id": dest_location.id, + "origin": origin, + } + return vals + + def move_full_quant_to(self, dest_location, picking_type=False, origin=False): + assert dest_location + picking_id = False + if picking_type: + picking_vals = self._prepare_move_to_stock_picking( + dest_location, picking_type, origin=origin + ) + picking_id = self.env["stock.picking"].create(picking_vals).id + smo = self.env["stock.move"] + stock_move_ids = [] + for quant in self: + vals = quant._prepare_move_to_stock_move( + quant.quantity, dest_location, picking_id, origin=origin + ) + new_move = smo.create(vals) + # No group has write access on stock.quant -> we need sudo() + new_move._action_done() + assert new_move.state == "done" + stock_move_ids.append(new_move.id) + return { + "picking_id": picking_id, + "stock_move_ids": stock_move_ids, + } diff --git a/stock_quant_package_move_wizard/security/ir.model.access.csv b/stock_quant_package_move_wizard/security/ir.model.access.csv new file mode 100644 index 0000000..0a94d70 --- /dev/null +++ b/stock_quant_package_move_wizard/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_stock_quant_move_wizard,Full access on stock.quant.move.wizard,model_stock_quant_move_wizard,stock.group_stock_user,1,1,1,1 +access_stock_quant_move_wizard_line,Full access on stock.quant.move.wizard.line,model_stock_quant_move_wizard_line,stock.group_stock_user,1,1,1,1 diff --git a/stock_quant_package_move_wizard/views/stock_quant.xml b/stock_quant_package_move_wizard/views/stock_quant.xml new file mode 100644 index 0000000..f1d0e15 --- /dev/null +++ b/stock_quant_package_move_wizard/views/stock_quant.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/stock_quant_package_move_wizard/wizards/__init__.py b/stock_quant_package_move_wizard/wizards/__init__.py new file mode 100644 index 0000000..db5048c --- /dev/null +++ b/stock_quant_package_move_wizard/wizards/__init__.py @@ -0,0 +1 @@ +from . import stock_quant_move_wizard diff --git a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py new file mode 100644 index 0000000..1064c82 --- /dev/null +++ b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard.py @@ -0,0 +1,114 @@ +# Copyright 2022 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class StockQuantMoveWizard(models.TransientModel): + _name = "stock.quant.move.wizard" + _description = "Wizard to Move Quants" + _check_company_auto = True + + line_ids = fields.One2many( + "stock.quant.move.wizard.line", "wizard_id", string="Lines" + ) + company_id = fields.Many2one("res.company", required=True) + location_dest_id = fields.Many2one( + "stock.location", + string="Destination Location", + domain="[('usage', '!=', 'view'), ('company_id', '=', company_id)]", + check_company=True, + required=True, + ) + picking_type_id = fields.Many2one( + "stock.picking.type", + domain="[('company_id', '=', company_id)]", + check_company=True, + ) + origin = fields.Char(string="Source Document") + # Idea : add a bool option 'move even if reserved' (= current behavior) + + @api.onchange("picking_type_id") + def picking_type_id_change(self): + if self.picking_type_id and self.picking_type_id.default_location_dest_id: + self.location_dest_id = self.picking_type_id.default_location_dest_id + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + assert self._context.get("active_model") == "stock.quant" + company_id = self.env.company.id + quants_ids = self._context.get("active_ids", []) + quants = self.env["stock.quant"].browse(quants_ids) + lines = [] + for quant in quants.filtered( + lambda q: not q.package_id and q.company_id.id == company_id + ): + lines.append((0, 0, {"quant_id": quant.id, "quantity": quant.quantity})) + picking_type = self.env["stock.picking.type"].search( + [("code", "=", "internal"), ("company_id", "=", company_id)], limit=1 + ) + res.update( + { + "line_ids": lines, + "company_id": company_id, + "picking_type_id": picking_type and picking_type.id or False, + } + ) + return res + + def run(self): + self.ensure_one() + picking_id = False + if self.picking_type_id: + picking_vals = self.env["stock.quant"]._prepare_move_to_stock_picking( + self.location_dest_id, self.picking_type_id, origin=self.origin + ) + picking_id = self.env["stock.picking"].create(picking_vals).id + smo = self.env["stock.move"] + for line in self.line_ids: + quant = line.quant_id + assert not quant.package_id + vals = quant._prepare_move_to_stock_move( + line.quantity, self.location_dest_id, picking_id, origin=self.origin + ) + new_move = smo.create(vals) + new_move._action_done() + assert new_move.state == "done" + action = {} + if picking_id and self._context.get("run_show_picking"): + action = self.env["ir.actions.actions"]._for_xml_id( + "stock.stock_picking_action_picking_type" + ) + action.update( + { + "res_id": picking_id, + "view_mode": "form,tree,pivot", + "views": False, + "view_id": False, + } + ) + return action + + +class StockQuantMoveWizardLine(models.TransientModel): + _name = "stock.quant.move.wizard.line" + _description = "Lines of the wizard to move quants" + + wizard_id = fields.Many2one( + comodel_name="stock.quant.move.wizard", string="Quant Move", ondelete="cascade" + ) + quant_id = fields.Many2one( + comodel_name="stock.quant", + string="Quant", + required=True, + ) + product_id = fields.Many2one(related="quant_id.product_id") + quant_quantity = fields.Float(related="quant_id.quantity", string="On Hand Qty") + quantity = fields.Float(string="Qty to Move", digits="Product Unit of Measure") + uom_id = fields.Many2one(related="quant_id.product_id.uom_id") + lot_id = fields.Many2one(related="quant_id.lot_id") + src_location_id = fields.Many2one( + related="quant_id.location_id", string="Current Location" + ) diff --git a/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml new file mode 100644 index 0000000..0a9eedb --- /dev/null +++ b/stock_quant_package_move_wizard/wizards/stock_quant_move_wizard_view.xml @@ -0,0 +1,54 @@ + + + + + + + stock.quant.move.wizard + +
+ + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Move to Another Location + stock.quant.move.wizard + form + new + + list + + +