-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
870 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
===================== | ||
Sale Cancel Remaining | ||
===================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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_cancel_remaining | ||
: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_cancel_remaining | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-workflow&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows you to cancel the remaining quantity on sale order by adding | ||
a dedicated action to sale lines. It also add two new fields to track canceled | ||
and returned quantities. | ||
|
||
**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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_cancel_remaining%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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
* ACSONE SA/NV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sylvain Van Hoof <[email protected]> | ||
* Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
* 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. | ||
|
||
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_cancel_remaining>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# © 2016 Sylvain Van Hoof | ||
# Copyright 2023 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Sale Cancel Remaining", | ||
"version": "16.0.1.0.0", | ||
"author": "Camptocamp, ACSONE SA/NV, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"category": "Sales", | ||
"summary": """Sale Cancel Remaining""", | ||
"depends": ["sale_stock", "stock_move_propagate_first_move"], | ||
"data": [ | ||
"security/cancel_remaining_wizard.xml", | ||
"wizards/cancel_remaining_wizard.xml", | ||
"views/sale_order.xml", | ||
"views/sale_order_line.xml", | ||
], | ||
"website": "https://github.com/OCA/sale-workflow", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import sale_order_line | ||
from . import stock_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2018 Okia SPRL | ||
# Copyright 2020 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
DIGITS = "Product Unit of Measure" | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
product_qty_canceled = fields.Float( | ||
"Qty canceled", readonly=True, copy=False, digits=DIGITS | ||
) | ||
product_qty_returned = fields.Float( | ||
"Qty returned", readonly=True, copy=False, digits=DIGITS | ||
) | ||
product_qty_remains_to_deliver = fields.Float( | ||
string="Remains to deliver", | ||
digits=DIGITS, | ||
compute="_compute_product_qty_remains_to_deliver", | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"product_uom_qty", | ||
"qty_delivered", | ||
"product_qty_canceled", | ||
"product_qty_returned", | ||
) | ||
def _compute_product_qty_remains_to_deliver(self): | ||
for line in self: | ||
remaining_to_deliver = ( | ||
line.product_uom_qty | ||
- line.qty_delivered | ||
- line.product_qty_canceled | ||
- line.product_qty_returned | ||
) | ||
line.product_qty_remains_to_deliver = remaining_to_deliver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2019 Camptocamp S.A. | ||
# Copyright 2023 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
def _action_done(self, cancel_backorder=False): | ||
result = super()._action_done(cancel_backorder=cancel_backorder) | ||
for move in self: | ||
if not move.origin_returned_move_id: | ||
continue | ||
line = move.sale_line_id | ||
if not move._include_move_into_return_quantity(): | ||
continue | ||
if move.location_dest_id.usage != "customer": | ||
line.product_qty_returned += move.product_uom_qty | ||
else: | ||
line.product_qty_returned -= move.product_uom_qty | ||
return result | ||
|
||
def _include_move_into_return_quantity(self): | ||
self.ensure_one() | ||
line = self.sale_line_id | ||
if self.product_id.expense_policy != "no" or not line: | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Sylvain Van Hoof <[email protected]> | ||
* Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
* Souheil Bejaoui <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This module allows you to cancel the remaining quantity on sale order by adding | ||
a dedicated action to sale lines. It also add two new fields to track canceled | ||
and returned quantities. |
14 changes: 14 additions & 0 deletions
14
sale_cancel_remaining/security/cancel_remaining_wizard.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 ACSONE SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record model="ir.model.access" id="cancel_remaining_wizard_access"> | ||
<field name="name">cancel.remaining.wizard access</field> | ||
<field name="model_id" ref="model_cancel_remaining_wizard" /> | ||
<field name="group_id" ref="sales_team.group_sale_manager" /> | ||
<field name="perm_read" eval="1" /> | ||
<field name="perm_create" eval="1" /> | ||
<field name="perm_write" eval="1" /> | ||
<field name="perm_unlink" eval="1" /> | ||
</record> | ||
</odoo> |
Oops, something went wrong.