diff --git a/setup/stock_picking_backorder_reason/odoo/addons/stock_picking_backorder_reason b/setup/stock_picking_backorder_reason/odoo/addons/stock_picking_backorder_reason new file mode 120000 index 000000000000..3617049206d7 --- /dev/null +++ b/setup/stock_picking_backorder_reason/odoo/addons/stock_picking_backorder_reason @@ -0,0 +1 @@ +../../../../stock_picking_backorder_reason \ No newline at end of file diff --git a/setup/stock_picking_backorder_reason/setup.py b/setup/stock_picking_backorder_reason/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_picking_backorder_reason/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_backorder_reason/README.rst b/stock_picking_backorder_reason/README.rst new file mode 100644 index 000000000000..d32fd2283f12 --- /dev/null +++ b/stock_picking_backorder_reason/README.rst @@ -0,0 +1,112 @@ +============================== +Stock Picking Backorder Reason +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0f8a117f9f235fddba6560b3452a7791aeec955054a578c8ecae4e01ec899376 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_backorder_reason + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_backorder_reason + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to help user defining a backorder reason when it is +launched on picking validation. This reason will be written on picking chatter level. + +A reason can have several backorder strategy to apply: + + * Create: Create the backorder + * Cancel: Cancel the backorder + * Use Partner Configuration: On partner level, you can define which strategy to + apply and for which flow (Sale: Create/Cancel, Purchase: Create/Cancel) + +This behaviour can be activated on picking type level. + +Moreover, on company level, you can set default reason strategy for new partners. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +#. Go to Inventory > Configuration > Operation Types +#. Select the one you want to activate the feature and check the + 'Backorder Reason' checkbox. +#. Then, select either the 'Backorder Reason' Sale or Purchase depending the flow the operation type + is concerned by. +#. Now, you can define some backorder reasons that will be selected by the warehouse user: + * Go to Inventory > Configuration > Warehouse Management > Backorder Reasons + * Fill in the name and choose an action to do (Create/Cancel/Use Partner option) + +#. Go to Inventory > Configuration > Settings > Operations + * You can change the default reason backorder strategy for new partners (for both sale/purchase flows) + * By default, it's set on 'Create' + +Known issues / Roadmap +====================== + +* For the time being, options are set on wizard level. One may want to have + the granularity on line one. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux +* Laurent Mignon +* Denis Roussel + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_backorder_reason/__init__.py b/stock_picking_backorder_reason/__init__.py new file mode 100644 index 000000000000..64face17ae84 --- /dev/null +++ b/stock_picking_backorder_reason/__init__.py @@ -0,0 +1 @@ +from . import models, wizards diff --git a/stock_picking_backorder_reason/__manifest__.py b/stock_picking_backorder_reason/__manifest__.py new file mode 100644 index 000000000000..4b5340e5c3fb --- /dev/null +++ b/stock_picking_backorder_reason/__manifest__.py @@ -0,0 +1,27 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +{ + "name": "Stock Picking Backorder Reason", + "summary": """ + Allows to add a layer on top of backorder confirmation in order to choose + a reason. That reason will contain the strategy to apply.""", + "version": "16.0.1.0.0", + "license": "LGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-workflow", + "depends": [ + "stock", + ], + "data": [ + "views/res_config_settings.xml", + "views/stock_picking_type.xml", + "views/res_partner.xml", + "security/stock_backorder_reason.xml", + "views/stock_backorder_reason.xml", + "wizards/stock_backorder_choice.xml", + ], + "demo": [ + "demo/stock_backorder_reason.xml", + ], +} diff --git a/stock_picking_backorder_reason/demo/stock_backorder_reason.xml b/stock_picking_backorder_reason/demo/stock_backorder_reason.xml new file mode 100644 index 000000000000..c0fd2bccc11e --- /dev/null +++ b/stock_picking_backorder_reason/demo/stock_backorder_reason.xml @@ -0,0 +1,19 @@ + + + + + + Missing products + use_partner_option + + + Urgent + create + + + Won't be delivered + cancel + + + diff --git a/stock_picking_backorder_reason/i18n/fr.po b/stock_picking_backorder_reason/i18n/fr.po new file mode 100644 index 000000000000..48f044f74207 --- /dev/null +++ b/stock_picking_backorder_reason/i18n/fr.po @@ -0,0 +1,386 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_backorder_reason +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-17 08:59+0000\n" +"PO-Revision-Date: 2023-07-17 08: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_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Apply" +msgstr "Appliquer" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/wizards/stock_backorder_reason_choice.py:0 +#, python-format +msgid "Back order reason: {reason}." +msgstr "Raison du reliquat: {reason}." + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Backorder" +msgstr "Raliquat" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_reason_search_view +msgid "Backorder Action" +msgstr "Action du reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__backorder_action_to_do +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__backorder_action_to_do +msgid "Backorder Action To Do" +msgstr "Action du reliquat à faire" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_picking_type_form_view +msgid "Backorder Reason" +msgstr "Raison du reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_purchase +msgid "Backorder Reason Purchase" +msgstr "Raison du reliquat (Achats)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_sale +msgid "Backorder Reason Sale" +msgstr "Raison du reliquat (Ventes)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking__backorder_reason_strategy +msgid "Backorder Reason Strategy" +msgstr "Stratégie de raison du reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.actions.act_window,name:stock_picking_backorder_reason.stock_backorder_reason_act_window +#: model:ir.ui.menu,name:stock_picking_backorder_reason.stock_backorder_reason_menu +msgid "Backorder Reasons" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__reason_id +msgid "Backorder reason" +msgstr "Raisons de reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_purchase_backorder_default_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_sale_backorder_default_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__purchase_reason_backorder_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__sale_reason_backorder_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_picking__backorder_reason_strategy__cancel +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Cancel" +msgstr "Annuler" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__cancel +msgid "Cancel backorder" +msgstr "Annuler le reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason +msgid "" +"Check this if you want people selecting a backorder reason when " +"applicable.This will trigger a backorder strategy rule defined on that " +"reason." +msgstr "" +"Cochez ceci si vous voulez que les utilisateurs sélectionnent une raison de reliquat " +"le cas échéant. Ceci va déclencher la règle de stratégie de reliquat sur cette raison." + + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_purchase +msgid "" +"Check this in order to consider pickings in this type as Purchase ones for " +"backorder reason cancellation." +msgstr "" +"Cochez ceci pour considérer les transferts de ce type comme Achats pour" +"la raison d'annulation des reliquats." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_sale +msgid "" +"Check this in order to consider pickings in this type as Sale ones for " +"backorder reason cancellation." +msgstr "Cochez ceci pour considérer les pickings de ce type comme Ventes pour " +"la raison d'annulation des reliquats." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__choice_line_ids +msgid "Choice Line" +msgstr "Ligne de choix" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/models/stock_picking.py:0 +#, python-format +msgid "Choose a reason for backorder" +msgstr "Choisissez une raison pour le reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_backorder_reason__backorder_action_to_do +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_backorder_reason_choice__backorder_action_to_do +msgid "" +"Choose here a backorder strategy to apply when this reason is selected.If " +"you don't set an action to do, the reason will be only put in " +"concernedpickings chatter." +msgstr "Choisissez ici une stratégie de reliquat à appliquer quand cette raison est sélectionnée." +"Si vous ne définissez pas d'action à effectuer, la raison sera uniquement mise dans" +"le file de discussion des transferts concernés." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_company__partner_purchase_backorder_default_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_config_settings__partner_purchase_backorder_default_strategy +msgid "" +"Choose the default strategy to set on partners for backorders on purchase " +"flows (for suppliers)." +msgstr "Choisissez la stratégie par défaut à définir sur les partenaires pour les reliquats" +"dans les flux d'achats (pour les fournisseurs)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_company__partner_sale_backorder_default_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_config_settings__partner_sale_backorder_default_strategy +msgid "" +"Choose the default strategy to set on partners for backorders on sale flows " +"(for customers)." +msgstr "Choisissez la strétégie par défaut à définir sur les partenaires pour les reliquats" +"des flux de vente (pour les clients)." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_partner__purchase_reason_backorder_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_users__purchase_reason_backorder_strategy +msgid "" +"Choose the strategy that will be applied on pickings that have backorder " +"choice enabled and depending on partner purchase strategy." +msgstr "Choisissez la strétégie qui sera appliquée sur les transferts qui ont ce " +"choix de reliquat activé et dépendant de la stratégie (Achats) du partenaire." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_partner__sale_reason_backorder_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_users__sale_reason_backorder_strategy +msgid "" +"Choose the strategy that will be applied on pickings that have backorder " +"choice enabled and depending on partner sale strategy." +msgstr "Choisissez la stratégie qui sera appliquée sur les transferts qui ont ce " +"choix de reliquat activé et dépendant de la stratégie (Ventes) du partenaire." + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de configuration" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_partner +msgid "Contact" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_purchase_backorder_default_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_sale_backorder_default_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__purchase_reason_backorder_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__sale_reason_backorder_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_picking__backorder_reason_strategy__create +msgid "Create" +msgstr "Créer" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__create +msgid "Create backorder" +msgstr "Créer le reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__create_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__create_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__create_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__create_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__create_date +msgid "Created on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__display_name +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__display_name +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_reason_search_view +msgid "Group By" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_picking_type_search_view +msgid "Has Backorder Reason" +msgstr "A une raison de reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__id +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__id +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__id +msgid "ID" +msgstr "" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/models/stock_picking_type.py:0 +#, python-format +msgid "" +"If you enable the backorder reason feature, you should choose if this is for" +" sale or purchase." +msgstr "Si vous activez la fonctionnalité de raison de reliquat, vous devriez choisir" +"si ceci est pour les ventes ou les achats." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason____last_update +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice____last_update +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__write_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__write_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__write_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__write_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_missing +msgid "Missing products" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__name +msgid "Name" +msgstr "Nom" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_company__partner_purchase_backorder_default_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_config_settings__partner_purchase_backorder_default_strategy +msgid "Partner Purchase Backorder Default Strategy" +msgstr "Stratégie de reliquat des partenaires par défaut (Achats)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_company__partner_sale_backorder_default_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_config_settings__partner_sale_backorder_default_strategy +msgid "Partner Sale Backorder Default Strategy" +msgstr "Stratégie de reliquat des partenaires par défaut (Ventes)" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.res_config_settings_view_form +msgid "Partner default backorder strategy for purchase flow (with reason)." +msgstr "Stratégie de backorder par défaut des partenaires pour le flux achats (avec raison)" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.res_config_settings_view_form +msgid "Partner default backorder strategy for sale flow (with reason)." +msgstr "Stratégie de backorder par défaut des partenaires pour le flux ventes (avec raison)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__picking_ids +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__picking_id +msgid "Picking" +msgstr "Transfert" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_picking_type +msgid "Picking Type" +msgstr "Type de transfert" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "" +"Please fill in a reason for backorder. You can see the further action that will\n" +" result in choosing that reason if filled in in reason." +msgstr "Veuillez remplir une raison pour le reliquat. Vous pouvez voir l'action qui sera déclenchée" +" en choisissant la raison (si elle y est définie)." + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_partner__purchase_reason_backorder_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_users__purchase_reason_backorder_strategy +msgid "Purchase Reason Backorder Strategy" +msgstr "Stratégie de raison de reliquat (Achats)" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_partner__sale_reason_backorder_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_users__sale_reason_backorder_strategy +msgid "Sale Reason Backorder Strategy" +msgstr "Stratégie de raison de reliquat (Ventes)" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason +msgid "Stock Backorder Reason" +msgstr "Raison de reliquat (stocks)" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason_choice +msgid "Stock Backorder Reason Choice" +msgstr "Choix de la raison de reliquat" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason_choice_line +msgid "Stock Backorder Reason Choice Line" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking__backorder_reason_strategy +msgid "" +"This is a technical field that says if a backorder is accepteddepending on " +"partner configuration accordingly with picking type one." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_picking +msgid "Transfer" +msgstr "Transfert" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_urgent +msgid "Urgent" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__use_partner_option +msgid "Use partner option" +msgstr "Utiliser l'option définie sur le partenaire" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__wizard_id +msgid "Wizard" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_never +msgid "Won't be delivered" +msgstr "Ne sera pas livré" diff --git a/stock_picking_backorder_reason/i18n/stock_picking_backorder_reason.pot b/stock_picking_backorder_reason/i18n/stock_picking_backorder_reason.pot new file mode 100644 index 000000000000..1a7996847d83 --- /dev/null +++ b/stock_picking_backorder_reason/i18n/stock_picking_backorder_reason.pot @@ -0,0 +1,372 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_backorder_reason +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-17 08:58+0000\n" +"PO-Revision-Date: 2023-07-17 08: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_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Apply" +msgstr "" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/wizards/stock_backorder_reason_choice.py:0 +#, python-format +msgid "Back order reason: {reason}." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Backorder" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_reason_search_view +msgid "Backorder Action" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__backorder_action_to_do +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__backorder_action_to_do +msgid "Backorder Action To Do" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_picking_type_form_view +msgid "Backorder Reason" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_purchase +msgid "Backorder Reason Purchase" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_sale +msgid "Backorder Reason Sale" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_picking__backorder_reason_strategy +msgid "Backorder Reason Strategy" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.actions.act_window,name:stock_picking_backorder_reason.stock_backorder_reason_act_window +#: model:ir.ui.menu,name:stock_picking_backorder_reason.stock_backorder_reason_menu +msgid "Backorder Reasons" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__reason_id +msgid "Backorder reason" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_purchase_backorder_default_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_sale_backorder_default_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__purchase_reason_backorder_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__sale_reason_backorder_strategy__cancel +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_picking__backorder_reason_strategy__cancel +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "Cancel" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__cancel +msgid "Cancel backorder" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason +msgid "" +"Check this if you want people selecting a backorder reason when " +"applicable.This will trigger a backorder strategy rule defined on that " +"reason." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_purchase +msgid "" +"Check this in order to consider pickings in this type as Purchase ones for " +"backorder reason cancellation." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking_type__backorder_reason_sale +msgid "" +"Check this in order to consider pickings in this type as Sale ones for " +"backorder reason cancellation." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__choice_line_ids +msgid "Choice Line" +msgstr "" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/models/stock_picking.py:0 +#, python-format +msgid "Choose a reason for backorder" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_backorder_reason__backorder_action_to_do +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_backorder_reason_choice__backorder_action_to_do +msgid "" +"Choose here a backorder strategy to apply when this reason is selected.If " +"you don't set an action to do, the reason will be only put in " +"concernedpickings chatter." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_company__partner_purchase_backorder_default_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_config_settings__partner_purchase_backorder_default_strategy +msgid "" +"Choose the default strategy to set on partners for backorders on purchase " +"flows (for suppliers)." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_company__partner_sale_backorder_default_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_config_settings__partner_sale_backorder_default_strategy +msgid "" +"Choose the default strategy to set on partners for backorders on sale flows " +"(for customers)." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_partner__purchase_reason_backorder_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_users__purchase_reason_backorder_strategy +msgid "" +"Choose the strategy that will be applied on pickings that have backorder " +"choice enabled and depending on partner purchase strategy." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_partner__sale_reason_backorder_strategy +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_res_users__sale_reason_backorder_strategy +msgid "" +"Choose the strategy that will be applied on pickings that have backorder " +"choice enabled and depending on partner sale strategy." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_company +msgid "Companies" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_res_partner +msgid "Contact" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_purchase_backorder_default_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_company__partner_sale_backorder_default_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__purchase_reason_backorder_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__res_partner__sale_reason_backorder_strategy__create +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_picking__backorder_reason_strategy__create +msgid "Create" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__create +msgid "Create backorder" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__create_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__create_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__create_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__create_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__create_date +msgid "Created on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__display_name +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__display_name +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_reason_search_view +msgid "Group By" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_picking_type_search_view +msgid "Has Backorder Reason" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__id +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__id +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__id +msgid "ID" +msgstr "" + +#. module: stock_picking_backorder_reason +#. odoo-python +#: code:addons/stock_picking_backorder_reason/models/stock_picking_type.py:0 +#, python-format +msgid "" +"If you enable the backorder reason feature, you should choose if this is for" +" sale or purchase." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason____last_update +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice____last_update +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__write_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__write_uid +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__write_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__write_date +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_missing +msgid "Missing products" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason__name +msgid "Name" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_company__partner_purchase_backorder_default_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_config_settings__partner_purchase_backorder_default_strategy +msgid "Partner Purchase Backorder Default Strategy" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_company__partner_sale_backorder_default_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_config_settings__partner_sale_backorder_default_strategy +msgid "Partner Sale Backorder Default Strategy" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.res_config_settings_view_form +msgid "Partner default backorder strategy for purchase flow (with reason)." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.res_config_settings_view_form +msgid "Partner default backorder strategy for sale flow (with reason)." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice__picking_ids +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__picking_id +msgid "Picking" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_picking_type +msgid "Picking Type" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model_terms:ir.ui.view,arch_db:stock_picking_backorder_reason.stock_backorder_choice_view_form +msgid "" +"Please fill in a reason for backorder. You can see the further action that will\n" +" result in choosing that reason if filled in in reason." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_partner__purchase_reason_backorder_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_users__purchase_reason_backorder_strategy +msgid "Purchase Reason Backorder Strategy" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_partner__sale_reason_backorder_strategy +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_res_users__sale_reason_backorder_strategy +msgid "Sale Reason Backorder Strategy" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason +msgid "Stock Backorder Reason" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason_choice +msgid "Stock Backorder Reason Choice" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_backorder_reason_choice_line +msgid "Stock Backorder Reason Choice Line" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,help:stock_picking_backorder_reason.field_stock_picking__backorder_reason_strategy +msgid "" +"This is a technical field that says if a backorder is accepteddepending on " +"partner configuration accordingly with picking type one." +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model,name:stock_picking_backorder_reason.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_urgent +msgid "Urgent" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields.selection,name:stock_picking_backorder_reason.selection__stock_backorder_reason__backorder_action_to_do__use_partner_option +msgid "Use partner option" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:ir.model.fields,field_description:stock_picking_backorder_reason.field_stock_backorder_reason_choice_line__wizard_id +msgid "Wizard" +msgstr "" + +#. module: stock_picking_backorder_reason +#: model:stock.backorder.reason,name:stock_picking_backorder_reason.stock_backorder_reason_never +msgid "Won't be delivered" +msgstr "" diff --git a/stock_picking_backorder_reason/models/__init__.py b/stock_picking_backorder_reason/models/__init__.py new file mode 100644 index 000000000000..dcfc168d3d81 --- /dev/null +++ b/stock_picking_backorder_reason/models/__init__.py @@ -0,0 +1,8 @@ +from . import ( + res_company, + res_config_settings, + res_partner, + stock_backorder_reason, + stock_picking, + stock_picking_type, +) diff --git a/stock_picking_backorder_reason/models/res_company.py b/stock_picking_backorder_reason/models/res_company.py new file mode 100644 index 000000000000..ceb77e476c9a --- /dev/null +++ b/stock_picking_backorder_reason/models/res_company.py @@ -0,0 +1,23 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + partner_sale_backorder_default_strategy = fields.Selection( + selection=[("create", "Create"), ("cancel", "Cancel")], + default="create", + required=True, + help="Choose the default strategy to set on partners for backorders " + "on sale flows (for customers).", + ) + partner_purchase_backorder_default_strategy = fields.Selection( + selection=[("create", "Create"), ("cancel", "Cancel")], + default="create", + required=True, + help="Choose the default strategy to set on partners for backorders " + "on purchase flows (for suppliers).", + ) diff --git a/stock_picking_backorder_reason/models/res_config_settings.py b/stock_picking_backorder_reason/models/res_config_settings.py new file mode 100644 index 000000000000..e6eb7d76e2aa --- /dev/null +++ b/stock_picking_backorder_reason/models/res_config_settings.py @@ -0,0 +1,16 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + + _inherit = "res.config.settings" + + partner_sale_backorder_default_strategy = fields.Selection( + related="company_id.partner_sale_backorder_default_strategy", + readonly=False, + ) + partner_purchase_backorder_default_strategy = fields.Selection( + related="company_id.partner_purchase_backorder_default_strategy", readonly=False + ) diff --git a/stock_picking_backorder_reason/models/res_partner.py b/stock_picking_backorder_reason/models/res_partner.py new file mode 100644 index 000000000000..ff6b64ad80c0 --- /dev/null +++ b/stock_picking_backorder_reason/models/res_partner.py @@ -0,0 +1,34 @@ +# Copyright 2017 Camptocamp SA +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl) + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + sale_reason_backorder_strategy = fields.Selection( + selection=[("create", "Create"), ("cancel", "Cancel")], + default=lambda self: self._get_default_sale_reason_backorder_strategy(), + required=True, + tracking=True, + help="Choose the strategy that will be applied on pickings that have " + "backorder choice enabled and depending on partner sale strategy.", + ) + purchase_reason_backorder_strategy = fields.Selection( + selection=[("create", "Create"), ("cancel", "Cancel")], + default=lambda self: self._get_default_purchase_reason_backorder_strategy(), + required=True, + tracking=True, + help="Choose the strategy that will be applied on pickings that have " + "backorder choice enabled and depending on partner purchase strategy.", + ) + + @api.model + def _get_default_sale_reason_backorder_strategy(self): + return self.env.company.partner_sale_backorder_default_strategy + + @api.model + def _get_default_purchase_reason_backorder_strategy(self): + return self.env.company.partner_purchase_backorder_default_strategy diff --git a/stock_picking_backorder_reason/models/stock_backorder_reason.py b/stock_picking_backorder_reason/models/stock_backorder_reason.py new file mode 100644 index 000000000000..b97ff9dcdeb5 --- /dev/null +++ b/stock_picking_backorder_reason/models/stock_backorder_reason.py @@ -0,0 +1,25 @@ +# Copyright 2017 Camptocamp SA +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class StockBackorderReason(models.Model): + + _name = "stock.backorder.reason" + _description = "Stock Backorder Reason" + + name = fields.Char(required=True, translate=True) + backorder_action_to_do = fields.Selection( + selection=[ + ("create", "Create backorder"), + ("cancel", "Cancel backorder"), + ("use_partner_option", "Use partner option"), + ], + default="create", + help="Choose here a backorder strategy to apply when this reason is selected." + "If you don't set an action to do, the reason will be only put in concerned" + "pickings chatter.", + ) diff --git a/stock_picking_backorder_reason/models/stock_picking.py b/stock_picking_backorder_reason/models/stock_picking.py new file mode 100644 index 000000000000..d6cd87493f02 --- /dev/null +++ b/stock_picking_backorder_reason/models/stock_picking.py @@ -0,0 +1,144 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import _, api, fields, models +from odoo.fields import Command + + +class StockPicking(models.Model): + + _inherit = "stock.picking" + + backorder_reason_strategy = fields.Selection( + selection=[ + ("create", "Create"), + ("cancel", "Cancel"), + ("transparent_cancel", "Transparent Cancel"), + ], + compute="_compute_backorder_reason_strategy", + help="This is a technical field that says if a backorder is accepted" + "depending on partner configuration accordingly with picking type one.", + ) + + @api.depends( + "picking_type_id.backorder_reason", + "picking_type_id.backorder_reason_sale", + "picking_type_id.backorder_reason_purchase", + "partner_id.sale_reason_backorder_strategy", + "partner_id.purchase_reason_backorder_strategy", + ) + def _compute_backorder_reason_strategy(self): + pickings_sale = self.filtered("picking_type_id.backorder_reason_sale") + for picking in pickings_sale: + picking.backorder_reason_strategy = ( + picking.partner_id.sale_reason_backorder_strategy + ) + pickings_purchase = self.filtered("picking_type_id.backorder_reason_purchase") + for picking in pickings_purchase: + picking.backorder_reason_strategy = ( + picking.partner_id.purchase_reason_backorder_strategy + ) + transparent_pickings = (pickings_sale | pickings_purchase).filtered( + lambda p: p.picking_type_id.backorder_reason_transparent_cancel + and p.backorder_reason_strategy == "cancel" + ) + transparent_pickings.update({"backorder_reason_strategy": "transparent_cancel"}) + # Remaining pickings + self.browse( + set(self.ids) + - set(pickings_sale.ids) + - set(pickings_purchase.ids) + - set(transparent_pickings.ids) + ).backorder_reason_strategy = False + + def _check_backorder_reason(self): + return self.filtered("picking_type_id.backorder_reason") + + def _action_backorder_transparent_cancel(self): + return ( + self.env["stock.backorder.reason.choice"] + .new( + { + "picking_ids": [Command.set(self.ids)], + "choice_line_ids": [ + Command.create({"picking_id": pick_id}) for pick_id in self.ids + ], + } + ) + .apply() + ) + + def _action_backorder_reason(self, show_transfers=False): + if self.backorder_reason_strategy == "transparent_cancel": + return ( + self.env["stock.backorder.reason.choice"] + .new( + { + "picking_ids": [Command.set(self.ids)], + "choice_line_ids": [ + Command.create({"picking_id": pick_id}) + for pick_id in self.ids + ], + } + ) + .apply() + ) + view = self.env.ref( + "stock_picking_backorder_reason.stock_backorder_choice_view_form" + ) + return { + "name": _("Choose a reason for backorder"), + "type": "ir.actions.act_window", + "view_mode": "form", + "res_model": "stock.backorder.reason.choice", + "views": [(view.id, "form")], + "view_id": view.id, + "target": "new", + "context": dict( + self.env.context, + default_show_transfers=show_transfers, + default_picking_ids=[(4, p.id) for p in self], + ), + } + + def _check_transparent_cancel(self): + return self.filtered( + lambda p: p.backorder_reason_strategy == "transparent_cancel" + ) + + def _pre_action_done_hook(self): + if not self.env.context.get("skip_backorder_reason"): + # Check if backorder is needed and then if reason is needed + pickings_with_backorder = self._check_backorder() + pickings_with_transparent_cancel = self._check_transparent_cancel() + if pickings_with_transparent_cancel: + return self._action_backorder_transparent_cancel() + pickings_with_reason = pickings_with_backorder._check_backorder_reason() + if pickings_with_reason: + return pickings_with_reason._action_backorder_reason( + show_transfers=self._should_show_transfers() + ) + return super()._pre_action_done_hook() + + def button_validate(self): + """ + In case of transparent cancel, we can pass to context 'picking_ids_not_to_backorder' + value to let Odoo manage that case. + """ + pickings_with_backorder = self._check_backorder() + picking_not_to_backorder = pickings_with_backorder.filtered( + lambda p: p.backorder_reason_strategy == "cancel" + )._check_transparent_cancel() + picking_ids_not_to_backorder = self.env.context.get( + "picking_ids_not_to_backorder" + ) + if picking_ids_not_to_backorder: + # Don't override an existing context value but add records to it + picking_not_to_backorder |= self.browse(picking_ids_not_to_backorder) + if picking_not_to_backorder: + new_self = self.with_context( + picking_ids_not_to_backorder=picking_not_to_backorder.ids + ) + return super(StockPicking, new_self).button_validate() + else: + return super().button_validate() diff --git a/stock_picking_backorder_reason/models/stock_picking_type.py b/stock_picking_backorder_reason/models/stock_picking_type.py new file mode 100644 index 000000000000..d217f5054600 --- /dev/null +++ b/stock_picking_backorder_reason/models/stock_picking_type.py @@ -0,0 +1,45 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockPickingType(models.Model): + + _inherit = "stock.picking.type" + + # TODO: This module should be split with the 'partner' backorder strategy + # The reason should be added on top of that + backorder_reason = fields.Boolean( + help="Check this if you want people selecting a backorder reason when applicable." + "This will trigger a backorder strategy rule defined on that reason." + ) + backorder_reason_sale = fields.Boolean( + help="Check this in order to consider pickings in this type as Sale ones for " + "backorder reason cancellation.", + ) + backorder_reason_purchase = fields.Boolean( + help="Check this in order to consider pickings in this type as " + "Purchase ones for backorder reason cancellation.", + ) + backorder_reason_transparent_cancel = fields.Boolean( + help="If this is checked and if the partner strategy is 'Cancel', " + "nothing will be shown to the user and the backorder will be cancelled." + ) + + @api.constrains( + "backorder_reason", "backorder_reason_sale", "backorder_reason_purchase" + ) + def _check_backorder_reason(self): + for picking_type in self.filtered("backorder_reason"): + if ( + not picking_type.backorder_reason_sale + and not picking_type.backorder_reason_purchase + ): + raise ValidationError( + _( + "If you enable the backorder reason feature, you should " + "choose if this is for sale or purchase." + ) + ) diff --git a/stock_picking_backorder_reason/readme/CONFIGURE.rst b/stock_picking_backorder_reason/readme/CONFIGURE.rst new file mode 100644 index 000000000000..1408ccf80984 --- /dev/null +++ b/stock_picking_backorder_reason/readme/CONFIGURE.rst @@ -0,0 +1,12 @@ +#. Go to Inventory > Configuration > Operation Types +#. Select the one you want to activate the feature and check the + 'Backorder Reason' checkbox. +#. Then, select either the 'Backorder Reason' Sale or Purchase depending the flow the operation type + is concerned by. +#. Now, you can define some backorder reasons that will be selected by the warehouse user: + * Go to Inventory > Configuration > Warehouse Management > Backorder Reasons + * Fill in the name and choose an action to do (Create/Cancel/Use Partner option) + +#. Go to Inventory > Configuration > Settings > Operations + * You can change the default reason backorder strategy for new partners (for both sale/purchase flows) + * By default, it's set on 'Create' diff --git a/stock_picking_backorder_reason/readme/CONTRIBUTORS.rst b/stock_picking_backorder_reason/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..c0c585a57574 --- /dev/null +++ b/stock_picking_backorder_reason/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Jacques-Etienne Baudoux +* Laurent Mignon +* Denis Roussel diff --git a/stock_picking_backorder_reason/readme/DESCRIPTION.rst b/stock_picking_backorder_reason/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..97ea81f286d2 --- /dev/null +++ b/stock_picking_backorder_reason/readme/DESCRIPTION.rst @@ -0,0 +1,13 @@ +This module allows to help user defining a backorder reason when it is +launched on picking validation. This reason will be written on picking chatter level. + +A reason can have several backorder strategy to apply: + + * Create: Create the backorder + * Cancel: Cancel the backorder + * Use Partner Configuration: On partner level, you can define which strategy to + apply and for which flow (Sale: Create/Cancel, Purchase: Create/Cancel) + +This behaviour can be activated on picking type level. + +Moreover, on company level, you can set default reason strategy for new partners. diff --git a/stock_picking_backorder_reason/readme/ROADMAP.rst b/stock_picking_backorder_reason/readme/ROADMAP.rst new file mode 100644 index 000000000000..89889c92da50 --- /dev/null +++ b/stock_picking_backorder_reason/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +* For the time being, options are set on wizard level. One may want to have + the granularity on line one. diff --git a/stock_picking_backorder_reason/security/stock_backorder_reason.xml b/stock_picking_backorder_reason/security/stock_backorder_reason.xml new file mode 100644 index 000000000000..b1256e09ce51 --- /dev/null +++ b/stock_picking_backorder_reason/security/stock_backorder_reason.xml @@ -0,0 +1,46 @@ + + + + + + stock.backorder.reason Manager + + + + + + + + + + stock.backorder.reason User + + + + + + + + + + stock.backorder.reason User + + + + + + + + + + stock.backorder.reason User + + + + + + + + + diff --git a/stock_picking_backorder_reason/static/description/icon.png b/stock_picking_backorder_reason/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_picking_backorder_reason/static/description/icon.png differ diff --git a/stock_picking_backorder_reason/static/description/index.html b/stock_picking_backorder_reason/static/description/index.html new file mode 100644 index 000000000000..dfefb0a7073a --- /dev/null +++ b/stock_picking_backorder_reason/static/description/index.html @@ -0,0 +1,471 @@ + + + + + +Stock Picking Backorder Reason + + + +
+

Stock Picking Backorder Reason

+ + +

Beta License: LGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

+

This module allows to help user defining a backorder reason when it is +launched on picking validation. This reason will be written on picking chatter level.

+

A reason can have several backorder strategy to apply:

+
+
    +
  • Create: Create the backorder
  • +
  • Cancel: Cancel the backorder
  • +
  • Use Partner Configuration: On partner level, you can define which strategy to +apply and for which flow (Sale: Create/Cancel, Purchase: Create/Cancel)
  • +
+
+

This behaviour can be activated on picking type level.

+

Moreover, on company level, you can set default reason strategy for new partners.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Go to Inventory > Configuration > Operation Types
  2. +
  3. Select the one you want to activate the feature and check the +‘Backorder Reason’ checkbox.
  4. +
  5. Then, select either the ‘Backorder Reason’ Sale or Purchase depending the flow the operation type +is concerned by.
  6. +
  7. +
    Now, you can define some backorder reasons that will be selected by the warehouse user:
    +
      +
    • Go to Inventory > Configuration > Warehouse Management > Backorder Reasons
    • +
    • Fill in the name and choose an action to do (Create/Cancel/Use Partner option)
    • +
    +
    +
    +
  8. +
  9. +
    Go to Inventory > Configuration > Settings > Operations
    +
      +
    • You can change the default reason backorder strategy for new partners (for both sale/purchase flows)
    • +
    • By default, it’s set on ‘Create’
    • +
    +
    +
    +
  10. +
+
+
+

Known issues / Roadmap

+
    +
  • For the time being, options are set on wizard level. One may want to have +the granularity on line one.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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

+

This module is part of the OCA/stock-logistics-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_picking_backorder_reason/tests/__init__.py b/stock_picking_backorder_reason/tests/__init__.py new file mode 100644 index 000000000000..9dd2e791848e --- /dev/null +++ b/stock_picking_backorder_reason/tests/__init__.py @@ -0,0 +1,5 @@ +from . import ( + test_backorder_reason, + test_purchase_backorder_reason, + test_sale_backorder_reason, +) diff --git a/stock_picking_backorder_reason/tests/common.py b/stock_picking_backorder_reason/tests/common.py new file mode 100644 index 000000000000..10c5ed5b0ba6 --- /dev/null +++ b/stock_picking_backorder_reason/tests/common.py @@ -0,0 +1,196 @@ +# Copyright 2017 Camptocamp SA +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) + + +class TestPickingBackorder: + + _flow = None # This will mention the actual flow (purchase, sale) + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.product_model = cls.env["product.product"] + cls.partner_model = cls.env["res.partner"] + cls.location_model = cls.env["stock.location"] + cls.stock_picking_model = cls.env["stock.picking"] + cls.stock_picking_type_model = cls.env["stock.picking.type"] + cls.backorder_reason_model = cls.env["stock.backorder.reason"] + cls.backorder_choice_model = cls.env["stock.backorder.reason.choice"] + cls.backorder_confirmation_model = cls.env["stock.backorder.confirmation"] + + cls.product = cls.product_model.create( + { + "name": "Unittest P1", + "uom_id": cls.env.ref("uom.product_uom_unit").id, + "type": "product", + } + ) + + cls.partner = cls.partner_model.create( + { + "name": "Unittest supplier", + "sale_reason_backorder_strategy": "cancel", + "ref": "123321", + } + ) + + cls.supplier_location = cls.env.ref("stock.stock_location_suppliers") + cls.customer_location = cls.env.ref("stock.stock_location_customers") + cls.stock_location = cls.env.ref("stock.stock_location_stock") + cls.output_location = cls.env.ref("stock.stock_location_output") + cls.picking_type_in = cls.env.ref("stock.picking_type_in") + cls.picking_type_out = cls.env.ref("stock.picking_type_out") + + cls.picking_type_in.write( + { + "backorder_reason": True, + "backorder_reason_purchase": True, + } + ) + + cls.picking_type_out.write( + { + "backorder_reason": True, + "backorder_reason_sale": True, + } + ) + + cls.env["stock.quant"].with_context(inventory_mode=True).create( + { + "product_id": cls.product.id, + "inventory_quantity": 10.0, + "location_id": cls.stock_location.id, + } + )._apply_inventory() + + # Define behaviour global variables + cls.backorder_action = "create" + cls.purchase_backorder = "create" + cls.sale_backorder = "create" + + cls._create_backorder_reason() + + @classmethod + def _create_picking(cls): + if cls._flow == "purchase": + picking_type = cls.picking_type_in.id + location_id = cls.supplier_location.id + location_dest_id = cls.stock_location.id + elif cls._flow == "sale": + picking_type = cls.picking_type_out.id + location_id = cls.stock_location.id + location_dest_id = cls.customer_location.id + else: + return + + # Create IN picking + cls.picking = cls.stock_picking_model.create( + { + "picking_type_id": picking_type, + "location_id": location_id, + "location_dest_id": location_dest_id, + "partner_id": cls.partner.id, + "move_ids": [ + ( + 0, + 0, + { + "name": "a move", + "product_id": cls.product.id, + "product_uom_qty": 10, + "product_uom": cls.product.uom_id.id, + "location_id": location_id, + "location_dest_id": location_dest_id, + }, + ) + ], + } + ) + + # Transfer picking partially + cls.picking.action_confirm() + cls.picking.action_assign() + move_lines = cls.picking.move_line_ids + move_lines.write({"qty_done": 3}) + + @classmethod + def _create_backorder_reason(cls): + # Define backorder reason + cls.backorder_reason = cls.backorder_reason_model.create( + { + "name": "Unittest backorder", + "backorder_action_to_do": cls.backorder_action, + } + ) + + def _check_backorder_behavior(self): + # Here we define the behaviors for the different strategies and check + # if everything is done in the expected way + + # Define the backorder behavior on partner + self.partner.purchase_reason_backorder_strategy = self.purchase_backorder + self.partner.sale_reason_backorder_strategy = self.sale_backorder + + # Change the behaviour depending on unit test + self.backorder_reason.write({"backorder_action_to_do": self.backorder_action}) + + result = self.picking.button_validate() + + # Check that the transfer action return the good wizard + self.assertEqual(result["res_model"], "stock.backorder.reason.choice") + + # Create backorder choice wizard and execute it + wizard = self.backorder_choice_model.with_context(**result["context"]).create( + {"reason_id": self.backorder_reason.id} + ) + result = wizard.apply() + + if not self.backorder_action: + # We are in the case the action should come from the picking type + # and let the core feature happen + self.assertTrue(result) + self.assertEqual("stock.backorder.confirmation", result.get("res_model")) + return + + # Search created backorder + self.backorder = self.stock_picking_model.search( + [("backorder_id", "=", self.picking.id)] + ) + + partner_option_create = ( + self.purchase_backorder == "create" + if self._flow == "purchase" + else self.sale_backorder == "create" + ) + + keep_backorder = self.backorder_action == "create" or ( + self.backorder_action == "use_partner_option" and partner_option_create + ) + + # Check picking chatter has the backorder reason + message = self.picking.message_ids.filtered( + lambda message: self.backorder_reason.name in message.body + ) + self.assertTrue(message) + + # Check picking values + if keep_backorder: + self.assertEqual(len(self.picking.move_ids), 1) + self.assertEqual(self.picking.move_ids.product_id, self.product) + self.assertEqual(self.picking.move_ids.product_uom_qty, 3) + self.assertEqual(self.picking.move_ids.state, "done") + self.assertEqual(self.picking.state, "done") + # Check backorder values + self.assertEqual(len(self.backorder), 1) + self.assertEqual(self.backorder.move_ids.product_uom_qty, 7) + else: + self.assertEqual(len(self.picking.move_ids), 2) + cancel_moves = self.picking.move_ids.filtered( + lambda move: move.state == "cancel" + ) + self.assertEqual(len(cancel_moves), 1) + moves = self.picking.move_ids - cancel_moves + self.assertEqual(len(moves), 1) + self.assertFalse(self.backorder) diff --git a/stock_picking_backorder_reason/tests/test_backorder_reason.py b/stock_picking_backorder_reason/tests/test_backorder_reason.py new file mode 100644 index 000000000000..7921467df502 --- /dev/null +++ b/stock_picking_backorder_reason/tests/test_backorder_reason.py @@ -0,0 +1,76 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + +from .common import TestPickingBackorder + + +class TestPickingBackorder(TestPickingBackorder, TransactionCase): + def test_picking_type_constraint(self): + msg = ( + "If you enable the backorder reason feature, you should choose " + "if this is for sale or purchase" + ) + with self.assertRaises(ValidationError, msg=msg): + self.picking_type_in.backorder_reason_purchase = False + with self.assertRaises(ValidationError, msg=msg): + self.picking_type_out.backorder_reason_sale = False + # Try to deactivate the reason flow + self.picking_type_out.backorder_reason = False + + def test_company_defaults(self): + # Default behavior for sales + partner = self.partner_model.create({"name": "Test Sale Create"}) + self.assertEqual("create", partner.sale_reason_backorder_strategy) + # Change to cancel for sale flows + self.env.company.partner_sale_backorder_default_strategy = "cancel" + partner = self.partner_model.create({"name": "Test Sale Cancel"}) + self.assertEqual("cancel", partner.sale_reason_backorder_strategy) + + # Default behavior for purchase + partner = self.partner_model.create({"name": "Test Purchase Create"}) + self.assertEqual("create", partner.purchase_reason_backorder_strategy) + # Change to cancel for purchase flows + self.env.company.partner_purchase_backorder_default_strategy = "cancel" + partner = self.partner_model.create({"name": "Test Cancel"}) + self.assertEqual("cancel", partner.purchase_reason_backorder_strategy) + + def test_no_backorder(self): + """ + Create a stock picking + Validate the whole lines + Try to validate the picking. + The result should be True (and not the backorder wizard) + """ + + self.picking = self.stock_picking_model.create( + { + "picking_type_id": self.picking_type_in.id, + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "partner_id": self.partner.id, + "move_ids": [ + ( + 0, + 0, + { + "name": "a move", + "product_id": self.product.id, + "product_uom_qty": 10, + "product_uom": self.product.uom_id.id, + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + }, + ) + ], + } + ) + + self.picking.action_confirm() + self.picking.action_assign() + self.picking.move_line_ids.write({"qty_done": 10.0}) + + result = self.picking.button_validate() + self.assertTrue(isinstance(result, bool) and result) diff --git a/stock_picking_backorder_reason/tests/test_purchase_backorder_reason.py b/stock_picking_backorder_reason/tests/test_purchase_backorder_reason.py new file mode 100644 index 000000000000..ecbc2b18ec31 --- /dev/null +++ b/stock_picking_backorder_reason/tests/test_purchase_backorder_reason.py @@ -0,0 +1,69 @@ +# Copyright 2017 Camptocamp SA +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl) + +from odoo.tests.common import TransactionCase + +from .common import TestPickingBackorder + + +class TestPickingBackorder(TestPickingBackorder, TransactionCase): + + _flow = "purchase" + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls._create_picking() + + def test_picking_backorder_strategy(self): + # Default one one partner is "create" for purchase + # Check picking partner backorder strategy + self.assertEqual("create", self.picking.backorder_reason_strategy) + self.partner.purchase_reason_backorder_strategy = "cancel" + self.assertEqual("cancel", self.picking.backorder_reason_strategy) + self.picking.picking_type_id.backorder_reason = False + + def test_picking_backorder_no_strategy(self): + # Change the reason and remove the action to do + # The result should be the normal backorder confirmation + self.backorder_action = False + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_cancel(self): + self.backorder_action = "create" + self.purchase_backorder = "cancel" + + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_create(self): + self.backorder_action = "create" + self.purchase_backorder = "create" + + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_action_cancel(self): + self.backorder_action = "cancel" + self.purchase_backorder = "cancel" + + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_action_cancel_purchase_create( + self, + ): + self.backorder_action = "cancel" + self.purchase_backorder = "create" + + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_partner_cancel(self): + self.backorder_action = "use_partner_option" + self.purchase_backorder = "cancel" + + self._check_backorder_behavior() + + def test_purchase_picking_backorder_create_backorder_partner_create(self): + self.backorder_action = "use_partner_option" + self.purchase_backorder = "create" + + self._check_backorder_behavior() diff --git a/stock_picking_backorder_reason/tests/test_sale_backorder_reason.py b/stock_picking_backorder_reason/tests/test_sale_backorder_reason.py new file mode 100644 index 000000000000..d59a35ebb90d --- /dev/null +++ b/stock_picking_backorder_reason/tests/test_sale_backorder_reason.py @@ -0,0 +1,71 @@ +# Copyright 2023 ACSONE SA/NV +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo.tests.common import TransactionCase + +from .common import TestPickingBackorder + + +class TestSalePickingBackorder(TestPickingBackorder, TransactionCase): + + _flow = "sale" + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls._create_picking() + + def test_picking_backorder_strategy(self): + # Check picking partner backorder strategy + self.assertEqual("cancel", self.picking.backorder_reason_strategy) + self.partner.sale_reason_backorder_strategy = "create" + self.assertEqual("create", self.picking.backorder_reason_strategy) + self.picking.picking_type_id.backorder_reason = False + + def test_sale_picking_backorder_create_backorder_cancel(self): + self.backorder_action = "create" + self.sale_backorder = "cancel" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_create_backorder_create(self): + self.backorder_action = "create" + self.sale_backorder = "create" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_create_backorder_action_cancel(self): + self.backorder_action = "cancel" + self.sale_backorder = "cancel" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_create_backorder_action_cancel_sale_create(self): + self.backorder_action = "cancel" + self.sale_backorder = "create" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_create_backorder_partner_cancel(self): + self.backorder_action = "use_partner_option" + self.sale_backorder = "cancel" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_create_backorder_partner_create(self): + self.backorder_action = "use_partner_option" + self.sale_backorder = "create" + + self._check_backorder_behavior() + + def test_sale_picking_backorder_partner_cancel_transparent(self): + """ + In this case, we test a partner that has his backorder policy + set to 'Cancel', the picking type activated for backorder reason + and the transparent action in case of cancel activated too. + """ + self.picking.picking_type_id.backorder_reason_transparent_cancel = True + self.partner.sale_reason_backorder_strategy = "cancel" + result = self.picking.button_validate() + self.assertTrue(result is True) + self.assertFalse(self.picking.backorder_ids) diff --git a/stock_picking_backorder_reason/views/res_config_settings.xml b/stock_picking_backorder_reason/views/res_config_settings.xml new file mode 100644 index 000000000000..75af3bf800d3 --- /dev/null +++ b/stock_picking_backorder_reason/views/res_config_settings.xml @@ -0,0 +1,36 @@ + + + + + res.config.settings.view.form (in stock_picking_backorder_reason) + res.config.settings + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/stock_picking_backorder_reason/views/res_partner.xml b/stock_picking_backorder_reason/views/res_partner.xml new file mode 100644 index 000000000000..41ec9ea56fbd --- /dev/null +++ b/stock_picking_backorder_reason/views/res_partner.xml @@ -0,0 +1,18 @@ + + + + + res.partner.form + res.partner + + + + + + + + + + + diff --git a/stock_picking_backorder_reason/views/stock_backorder_reason.xml b/stock_picking_backorder_reason/views/stock_backorder_reason.xml new file mode 100644 index 000000000000..083c3d7663fa --- /dev/null +++ b/stock_picking_backorder_reason/views/stock_backorder_reason.xml @@ -0,0 +1,76 @@ + + + + + + stock.backorder.reason.form (in stock_picking_backorder_reason) + stock.backorder.reason + +
+
+ + + + + + +