Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/shopfloor_reception_backorder_reason/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
6 changes: 6 additions & 0 deletions setup/shopfloor_reception_backorder_reason_mobile/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
84 changes: 84 additions & 0 deletions shopfloor_reception_backorder_reason/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
====================================
Shopfloor Reception Backorder Reason
====================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:891c9573ba69156492ac5fbb376cec069446c36501b3af61225c68759a055a3f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/16.0/shopfloor_reception_backorder_reason
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_reception_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/wms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to manage backorder reasons on shopfloor level.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/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 <https://github.com/OCA/wms/issues/new?body=module:%20shopfloor_reception_backorder_reason%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Denis Roussel denis.roussel@acsone.eu

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.

.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
:target: https://github.com/rousseldenis
:alt: rousseldenis

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rousseldenis|

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/16.0/shopfloor_reception_backorder_reason>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions shopfloor_reception_backorder_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import services
from . import actions
16 changes: 16 additions & 0 deletions shopfloor_reception_backorder_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Shopfloor Reception Backorder Reason",
"summary": """This module allows to select a backorder reason if there is one""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"maintainers": ["rousseldenis"],
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/wms",
"depends": [
"shopfloor_reception",
"stock_picking_backorder_reason",
],
}
1 change: 1 addition & 0 deletions shopfloor_reception_backorder_reason/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import data
45 changes: 45 additions & 0 deletions shopfloor_reception_backorder_reason/actions/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2025 ACSONE SA/NV (https://acsone.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)


from odoo.addons.component.core import Component
from odoo.addons.shopfloor_base.utils import ensure_model


class DataAction(Component):
_inherit = "shopfloor.data.action"

@property
def _backorder_reason_parser(self, **kw):
return [
"id",
"name",
(
"backorder_action_to_do",
lambda rec, fname: {
"action": rec.backorder_action_to_do,
"label": "".join(
[
field_value[1]
for field_value in rec._fields[
"backorder_action_to_do"
]._description_selection(rec.env)
if field_value[0] == rec.backorder_action_to_do
]
),
},
),
]

def _get_backorder_reason_parser(self, record, **kw):
parser = self._backorder_reason_parser
return parser

@ensure_model("stock.backorder.reason")
def backorder_reason(self, record, **kw):
return self._jsonify(
record, self._get_backorder_reason_parser(record, **kw), **kw
)

def backorder_reasons(self, record, **kw):
return self.backorder_reason(record, multi=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <denis.roussel@acsone.eu>
1 change: 1 addition & 0 deletions shopfloor_reception_backorder_reason/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to manage backorder reasons on shopfloor level.
1 change: 1 addition & 0 deletions shopfloor_reception_backorder_reason/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import reception
131 changes: 131 additions & 0 deletions shopfloor_reception_backorder_reason/services/reception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Copyright 2025 ACSONE SA/NV (https://acsone.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)


from odoo.fields import Command

from odoo.addons.component.core import Component


class Reception(Component):

_inherit = "shopfloor.reception"

def _data_for_backorder_reasons(self, reasons):
return self.data.backorder_reasons(reasons)

def _response_for_choose_backorder_reason(self, picking, message=None):

reasons = self.env["stock.backorder.reason"].search([])
data = {
"picking": self._data_for_stock_picking(picking, with_lines=False),
"backorder_reasons": [
result for result in self._data_for_backorder_reasons(reasons)
],
}
return self._response(
next_state="choose_backorder_reason", data=data, message=message
)

def done_action(self, picking_id, confirmation=False):
"""
Override here the `done_action` to let the user decide
about the backorder reason.
"""
picking = self.env["stock.picking"].browse(picking_id)
action = picking.with_context(
button_validate_picking_ids=picking.ids
)._pre_action_done_hook()
if (
isinstance(action, dict)
and action.get("res_model") == "stock.backorder.reason.choice"
):
return self._response_for_choose_backorder_reason(picking)
if isinstance(action, bool) and action and picking.state == "done":
return self._response_for_select_document(
message=self.msg_store.transfer_done_success(picking)
)
return super().done_action(picking_id, confirmation=confirmation)

def choose_backorder_reason(self, picking_id, reason_id):
picking = self.env["stock.picking"].browse(picking_id)
message = self._check_picking_processible(picking)
if message:
return self._response_for_select_move(picking, message=message)
# Check if reason choice is still possible
action = picking._pre_action_done_hook()
if action.get("res_model") == "stock.backorder.reason.choice":
result = (
self.env["stock.backorder.reason.choice"]
.with_context(button_validate_picking_ids=picking.ids)
.new(
{
"picking_ids": [Command.set([picking_id])],
"choice_line_ids": [Command.create({"picking_id": picking_id})],
"reason_id": reason_id,
}
)
.apply()
)
if result:
return self._response_for_select_document(
message=self.msg_store.transfer_done_success(picking)
)
if picking.state == "done":
# Backorder has been transparent cancelled with no reason choice
return self._response_for_select_document(
message=self.msg_store.transfer_done_success(picking)
)
return super().done_action(picking_id, confirmation=None)


class ShopfloorReceptionValidator(Component):

_inherit = "shopfloor.reception.validator"

def choose_backorder_reason(self):
return {
"picking_id": {"required": True, "type": "integer"},
"reason_id": {"required": True, "type": "integer"},
}


class ShopfloorReceptionValidatorResponse(Component):

_inherit = "shopfloor.reception.validator.response"

# STATES

def _states(self):
states = super()._states()
states.update({"choose_backorder_reason": self._schema_choose_backorder_reason})

return states

@property
def _schema_choose_backorder_reason(self):
return {
"picking": {"type": "dict", "schema": self.schemas.picking()},
"backorder_reasons": self.schemas._schema_list_of(
self.schemas.backorder_reason(), required=True
),
}

def choose_backorder_reason(self):
return self._response_schema(next_states={"confirm_done"})

def _done_next_states(self):
next_states = super()._done_next_states()
next_states.update({"choose_backorder_reason"})
return next_states


class ShopfloorSchemaAction(Component):
_inherit = "shopfloor.schema.action"

def backorder_reason(self):
return {
"id": {"required": True, "type": "integer"},
"name": {"type": "string", "nullable": False, "required": True},
"backorder_action_to_do": {"type": "dict"},
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading