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
140 changes: 140 additions & 0 deletions repair_stock_consumption_step/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
=============================
Repair Stock Consumption Step
=============================

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

.. |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%2Frepair-lightgray.png?logo=github
:target: https://github.com/OCA/repair/tree/16.0/repair_stock_consumption_step
:alt: OCA/repair
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_stock_consumption_step
: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/repair&target_branch=16.0
:alt: Try me on Runboat

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

This module introduces an optional intermediate step:

- When enabled at warehouse level, repair consumption moves are grouped
into a stock picking.
- The repair order is set to a new **Consumption** state until the
picking is validated.
- Users can process the picking manually, assign lots/serials, and only
then complete the repair.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

In the base repair module, consumption moves for spare parts are created
and immediately validated when the repair order is marked as done. This
prevents user interaction such as choosing lot/serial numbers.

Configuration
=============

1. Go to **Inventory / Configuration / Warehouses**.

2. Open the warehouse you want to use for repairs.

3.

2. In **Technical info** :

- Enable **Repair Consumption Step**.
- Select the **Repair Consumption Picking Type** (an internal
transfer type from the repair location to a production/virtual
location).

Usage
=====

1. Create a repair order with spare part lines.
2. Confirm the repair order.
3. Click **End Repair**:

- If the warehouse setting is disabled:

- Consumption moves are validated immediately, repair goes
directly to **Done**.

- If the setting is enabled:

- The repair order moves to the **Consumption** state.
- A stock picking is created for the spare part moves.

4. Open the **Consumption Picking** from the repair order.
5. Process the picking:

- Assign quantities and lots/serials.
- Validate the picking.

6. Once the picking is validated, the repair order automatically moves
to **Done**.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/repair/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/repair/issues/new?body=module:%20repair_stock_consumption_step%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
------------

- Souheil Bejaoui [email protected]

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-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
:target: https://github.com/sbejaoui
:alt: sbejaoui

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

|maintainer-sbejaoui|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions repair_stock_consumption_step/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions repair_stock_consumption_step/__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": "Repair Stock Consumption Step",
"summary": """Adds a warehouse-configurable step to process repair consumption
moves in a picking""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/repair",
"maintainers": ["sbejaoui"],
"depends": ["repair"],
"data": ["views/repair_order.xml", "views/stock_warehouse.xml"],
"demo": [],
}
4 changes: 4 additions & 0 deletions repair_stock_consumption_step/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import stock_warehouse
from . import repair_order
from . import stock_move
from . import stock_picking
73 changes: 73 additions & 0 deletions repair_stock_consumption_step/models/repair_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class RepairOrder(models.Model):

_inherit = "repair.order"

consumption_picking_id = fields.Many2one(
"stock.picking", string="Consumption Picking", readonly=True, copy=False
)
warehouse_id = fields.Many2one(
"stock.warehouse", related="location_id.warehouse_id"
)
repair_consumption_step = fields.Boolean(
related="warehouse_id.repair_consumption_step"
)
state = fields.Selection(
selection_add=[("consumption", "Waiting Consumption")],
ondelete={"consumption": "set done"},
)

def action_view_consumption_picking(self):
self.ensure_one()
return {
"name": "Repair Consumption Picking",
"type": "ir.actions.act_window",
"res_model": "stock.picking",
"view_mode": "form",
"res_id": self.consumption_picking_id.id,
}

def action_repair_done(self):
need_consumption_step = self.filtered("repair_consumption_step")
res = super(RepairOrder, self - need_consumption_step).action_repair_done()
for rec in need_consumption_step:
rec_res = super(
RepairOrder, rec.with_context(dont_validate_repair_move=True)
).action_repair_done()
res.update(rec_res)
moves = self.env["stock.move"].search([("repair_id", "=", rec.id)])
if not moves:
continue
picking = self.env["stock.picking"].create(
{
"picking_type_id": rec.warehouse_id.repair_consumption_picking_type_id.id,
"origin": rec.name,
"location_id": moves[0].location_id.id,
"location_dest_id": moves[0].location_dest_id.id,
}
)
moves.picking_id = picking.id
moves._action_confirm()
moves._action_assign()
moves.move_line_ids.picking_id = picking.id
rec.consumption_picking_id = picking
rec.state = "consumption"
return res

def action_repair_end(self):
super().action_repair_end()
need_consumption_step = self.filtered("consumption_picking_id")
need_consumption_step.state = "consumption"
return True

def _action_consumption_done(self):
for rec in self:
state = "done"
if not rec.invoice_id and rec.invoice_method == "after_repair":
state = "2binvoiced"
rec.state = state
18 changes: 18 additions & 0 deletions repair_stock_consumption_step/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockMove(models.Model):

_inherit = "stock.move"

def _action_done(self, cancel_backorder=False):
repair_moves = self.browse()
if self.env.context.get("dont_validate_repair_move"):
repair_moves = self.filtered("repair_id")

return super(StockMove, self - repair_moves)._action_done(
cancel_backorder=cancel_backorder
)
21 changes: 21 additions & 0 deletions repair_stock_consumption_step/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockPicking(models.Model):

_inherit = "stock.picking"

def _action_done(self):
res = super()._action_done()
done_pickings = self.filtered(lambda p: p.state == "done")
repair_orders = self.env["repair.order"].search(
[
("state", "=", "consumption"),
("consumption_picking_id", "in", done_pickings.ids),
]
)
repair_orders._action_consumption_done()
return res
21 changes: 21 additions & 0 deletions repair_stock_consumption_step/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockWarehouse(models.Model):

_inherit = "stock.warehouse"

repair_consumption_step = fields.Boolean(
string="Enable Repair Consumption Step",
help="If enabled, consumption moves from repairs will be grouped "
"in a picking instead of being directly validated.",
)
repair_consumption_picking_type_id = fields.Many2one(
"stock.picking.type",
string="Repair Consumption Picking Type",
domain="[('code','=','internal'), ('warehouse_id','=', id)]",
help="Picking type used for repair consumption moves when the extra step is enabled.",
)
5 changes: 5 additions & 0 deletions repair_stock_consumption_step/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1. Go to **Inventory / Configuration / Warehouses**.
2. Open the warehouse you want to use for repairs.
3. 2. In **Technical info** :
- Enable **Repair Consumption Step**.
- Select the **Repair Consumption Picking Type** (an internal transfer type from the repair location to a production/virtual location).
3 changes: 3 additions & 0 deletions repair_stock_consumption_step/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In the base repair module, consumption moves for spare parts are
created and immediately validated when the repair order is marked as done.
This prevents user interaction such as choosing lot/serial numbers.
1 change: 1 addition & 0 deletions repair_stock_consumption_step/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Souheil Bejaoui <[email protected]>
8 changes: 8 additions & 0 deletions repair_stock_consumption_step/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module introduces an optional intermediate step:

- When enabled at warehouse level, repair consumption moves are grouped
into a stock picking.
- The repair order is set to a new **Consumption** state until the picking
is validated.
- Users can process the picking manually, assign lots/serials, and only
then complete the repair.
13 changes: 13 additions & 0 deletions repair_stock_consumption_step/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1. Create a repair order with spare part lines.
2. Confirm the repair order.
3. Click **End Repair**:
- If the warehouse setting is disabled:
- Consumption moves are validated immediately, repair goes directly to **Done**.
- If the setting is enabled:
- The repair order moves to the **Consumption** state.
- A stock picking is created for the spare part moves.
4. Open the **Consumption Picking** from the repair order.
5. Process the picking:
- Assign quantities and lots/serials.
- Validate the picking.
6. Once the picking is validated, the repair order automatically moves to **Done**.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading