Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] sale_stock_prebook_cancel_line: Glue addon #3507

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
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
87 changes: 87 additions & 0 deletions sale_stock_prebook_cancel_line/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==============================
Sale Stock Prebook Cancel Line
==============================

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

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

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

This addon is a technical module that ensures that the computation of
the cancelled quantity on a sale order line is correct even when a
prebooking is involved. Cancelled prebooked quantities must not be taken
into account in the computation of the cancelled quantity on the sale
order line.

**Table of contents**

.. contents::
:local:

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

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

- Laurent Mignon [email protected] (https://www.acsone.eu)

Other credits
-------------

The development of this module has been financially supported by:

- ALCYON Belux

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/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_stock_prebook_cancel_line>`_ 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 sale_stock_prebook_cancel_line/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions sale_stock_prebook_cancel_line/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Stock Prebook Cancel Line",
"summary": """Takes into account prebook pickings into the computation
of cancelled qty on the sale order lines""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": [
"sale_stock_prebook",
"sale_order_line_cancel",
],
"auto_install": True,
"data": [],
"demo": [],
}
2 changes: 2 additions & 0 deletions sale_stock_prebook_cancel_line/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sale_order_line
from . import stock_move
19 changes: 19 additions & 0 deletions sale_stock_prebook_cancel_line/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo.exceptions import UserError


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _check_moves_to_cancel(self, moves):
self.ensure_one()

Check warning on line 12 in sale_stock_prebook_cancel_line/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_prebook_cancel_line/models/sale_order_line.py#L12

Added line #L12 was not covered by tests
if self.move_ids.filtered("used_for_sale_reservation"):
raise UserError(

Check warning on line 14 in sale_stock_prebook_cancel_line/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_prebook_cancel_line/models/sale_order_line.py#L14

Added line #L14 was not covered by tests
_(
"You cannot cancel a line with prebooked moves. "
"Please cancel the related prebooked moves first."
)
)
16 changes: 16 additions & 0 deletions sale_stock_prebook_cancel_line/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 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 _is_move_to_take_into_account_for_qty_canceled(self):
self.ensure_one()
return (
not self.used_for_sale_reservation
and super()._is_move_to_take_into_account_for_qty_canceled()
)
1 change: 1 addition & 0 deletions sale_stock_prebook_cancel_line/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Laurent Mignon <[email protected]> (https://www.acsone.eu)
3 changes: 3 additions & 0 deletions sale_stock_prebook_cancel_line/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

- ALCYON Belux
1 change: 1 addition & 0 deletions sale_stock_prebook_cancel_line/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This addon is a technical module that ensures that the computation of the cancelled quantity on a sale order line is correct even when a prebooking is involved. Cancelled prebooked quantities must not be taken into account in the computation of the cancelled quantity on the sale order 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