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
111 changes: 111 additions & 0 deletions pos_order_return_scrap/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
=========================
Point of Sale Order Scrap
=========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/18.0/pos_order_return_scrap
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_order_return_scrap
: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/pos&target_branch=18.0
:alt: Try me on Runboat

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

This module extends the capabilities of the OCA module pos_order_return
by adding finer control over stock for returned items. A new option "Is
Scrap?" is introduced in the POS Partial Return Wizard. When checked,
the system automatically creates a scrap order for the returned
quantities of that product, improving warehouse accuracy for damaged or
non-sellable goods.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Usage
=====

- Go to Point of Sale and locate an existing POS Order

- Click "Partial Return"

- A popup will open |image1|

- For any product being returned as damaged or unusable:

- Enable the checkbox "Is Scrap?"

- Confirm the return

Once validated:

- Standard return processing occurs
- A Scrap Order is automatically created for each scrap-marked product
line

.. |image1| image:: https://raw.githubusercontent.com/OCA/pos/18.0/pos_order_return_scrap/static/description/partial_return_scrap_form.png

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

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

* Trobz

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

- Trobz <https://www.trobz.com>

- Nguyen Minh Chien <chien@trobz.com>

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/pos <https://github.com/OCA/pos/tree/18.0/pos_order_return_scrap>`_ 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 pos_order_return_scrap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
18 changes: 18 additions & 0 deletions pos_order_return_scrap/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Point of Sale Order Scrap",
"version": "18.0.1.0.0",
"category": "Point Of Sale",
"author": "Trobz, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/pos",
"development_status": "Alpha",
"depends": [
"pos_order_return",
],
"data": [
"wizard/pos_partial_return_wizard_view.xml",
],
"installable": True,
}
37 changes: 37 additions & 0 deletions pos_order_return_scrap/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_order_return_scrap
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-01-26 03:05+0000\n"
"PO-Revision-Date: 2026-01-26 03:05+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: pos_order_return_scrap
#: model:ir.model.fields,field_description:pos_order_return_scrap.field_pos_order_line__is_scrap
#: model:ir.model.fields,field_description:pos_order_return_scrap.field_pos_partial_return_wizard_line__is_scrap
msgid "Is Scrap?"
msgstr "Mettre au rebut ?"

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_pos_partial_return_wizard_line
msgid "Partial Return Wizard Line"
msgstr "Assistant de retour partiel"

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_pos_order_line
msgid "Point of Sale Order Lines"
msgstr "Lignes des commandes du point de vente"

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_stock_picking
msgid "Transfer"
msgstr "Transfert"
37 changes: 37 additions & 0 deletions pos_order_return_scrap/i18n/pos_order_return_scrap.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_order_return_scrap
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-01-26 03:03+0000\n"
"PO-Revision-Date: 2026-01-26 03:03+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: pos_order_return_scrap
#: model:ir.model.fields,field_description:pos_order_return_scrap.field_pos_order_line__is_scrap
#: model:ir.model.fields,field_description:pos_order_return_scrap.field_pos_partial_return_wizard_line__is_scrap
msgid "Is Scrap?"
msgstr ""

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_pos_partial_return_wizard_line
msgid "Partial Return Wizard Line"
msgstr ""

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_pos_order_line
msgid "Point of Sale Order Lines"
msgstr ""

#. module: pos_order_return_scrap
#: model:ir.model,name:pos_order_return_scrap.model_stock_picking
msgid "Transfer"
msgstr ""
2 changes: 2 additions & 0 deletions pos_order_return_scrap/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import pos_order_line
from . import stock_picking
13 changes: 13 additions & 0 deletions pos_order_return_scrap/models/pos_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class PosOrderLine(models.Model):
_inherit = "pos.order.line"

is_scrap = fields.Boolean(string="Is Scrap?", copy=False)

def _prepare_refund_data_partial_line(self, data, wizard_line):
data = super()._prepare_refund_data_partial_line(data, wizard_line)
data["is_scrap"] = wizard_line["is_scrap"]
return data
73 changes: 73 additions & 0 deletions pos_order_return_scrap/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models


class StockPicking(models.Model):
_inherit = "stock.picking"

@api.model
def _create_picking_from_pos_order_lines(
self, location_dest_id, lines, picking_type, partner=False
):
"""
Override this method to create scrap orders for lines which is_scrap = True
"""
pickings = super()._create_picking_from_pos_order_lines(
location_dest_id, lines, picking_type, partner
)
if not pickings:
return pickings

# Scrap the negative lines (returned lines) only
to_scrap_lines = lines.filtered(
lambda _l: _l.product_id.type == "consu" and _l.qty < 0 and _l.is_scrap
)
if to_scrap_lines:
self._create_scraps_from_pos_order_lines(to_scrap_lines, pickings)
return pickings

@api.model
def _create_scraps_from_pos_order_lines(self, order_lines, pickings):
"""
Create scrap orders for pos lines in both cases of stock qty updating: at real
time and at session closing
"""
scraps = self.env["stock.scrap"]
move_lines = pickings.mapped("move_line_ids").filtered(
lambda m: m.state == "done" and m.move_id._is_incoming()
)
if not move_lines:
return scraps
# Sum return qty by product
to_scrap = {}
for order_line in order_lines:
to_scrap.setdefault(order_line.product_id, 0)
to_scrap[order_line.product_id] += abs(order_line.qty)

StockScrap = self.env["stock.scrap"].sudo()
for product, qty in to_scrap.items():
for move_line in move_lines:
if qty <= 0:
break
if product != move_line.product_id:
continue
scrap_qty = min(move_line.quantity_product_uom, qty)
qty -= scrap_qty
vals = StockScrap.default_get(StockScrap._fields.keys())
vals.update(
{
"product_id": product.id,
"picking_id": move_line.picking_id.id,
"scrap_qty": scrap_qty,
}
)
new_record = StockScrap.new(vals)
# To trigger the onchange _onchange_serial_number if possible
if move_line.lot_id:
new_record.lot_id = move_line.lot_id
vals = StockScrap._convert_to_write(new_record._cache)
scrap = StockScrap.create(vals)
# Validate the scrap order if enough stock
scrap.action_validate()
scraps |= scrap
return scraps
3 changes: 3 additions & 0 deletions pos_order_return_scrap/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions pos_order_return_scrap/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Trobz \<<https://www.trobz.com>\>
- Nguyen Minh Chien \<<chien@trobz.com>\>
2 changes: 2 additions & 0 deletions pos_order_return_scrap/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the capabilities of the OCA module pos_order_return by adding finer control over stock for returned items.
A new option "Is Scrap?" is introduced in the POS Partial Return Wizard. When checked, the system automatically creates a scrap order for the returned quantities of that product, improving warehouse accuracy for damaged or non-sellable goods.
12 changes: 12 additions & 0 deletions pos_order_return_scrap/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- Go to Point of Sale and locate an existing POS Order
- Click "Partial Return"
- A popup will open
![image1](../static/description/partial_return_scrap_form.png)

- For any product being returned as damaged or unusable:
- Enable the checkbox "Is Scrap?"
- Confirm the return

Once validated:
- Standard return processing occurs
- A Scrap Order is automatically created for each scrap-marked product line
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading