diff --git a/setup/stock_account_return_origin_difference/odoo/addons/stock_account_return_origin_difference b/setup/stock_account_return_origin_difference/odoo/addons/stock_account_return_origin_difference new file mode 120000 index 00000000..ba2986a7 --- /dev/null +++ b/setup/stock_account_return_origin_difference/odoo/addons/stock_account_return_origin_difference @@ -0,0 +1 @@ +../../../../stock_account_return_origin_difference \ No newline at end of file diff --git a/setup/stock_account_return_origin_difference/setup.py b/setup/stock_account_return_origin_difference/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_account_return_origin_difference/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_return_origin_difference/README.rst b/stock_account_return_origin_difference/README.rst new file mode 100644 index 00000000..dea4bf1c --- /dev/null +++ b/stock_account_return_origin_difference/README.rst @@ -0,0 +1,56 @@ +====================================== +Stock Account Return Origin Difference +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:52cb3f6e0ddac8e9dda227d5cf06e51bf04f0d442395e672035deeaf6e717fe4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-qrtl%2Faxls--custom-lightgray.png?logo=github + :target: https://github.com/qrtl/axls-custom/tree/16.0/stock_account_return_origin_difference + :alt: qrtl/axls-custom + +|badge1| |badge2| |badge3| + +This module checks if there is a unit cost difference between the stock +valuation layers (SVLs) of receipts and their returns. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Quartile + +Maintainers +----------- + +This module is part of the `qrtl/axls-custom `_ project on GitHub. + +You are welcome to contribute. diff --git a/stock_account_return_origin_difference/__init__.py b/stock_account_return_origin_difference/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_account_return_origin_difference/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_account_return_origin_difference/__manifest__.py b/stock_account_return_origin_difference/__manifest__.py new file mode 100644 index 00000000..f076675b --- /dev/null +++ b/stock_account_return_origin_difference/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2023 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Account Return Origin Difference", + "version": "16.0.1.0.0", + "author": "Quartile, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-workflow", + "category": "stock", + "license": "AGPL-3", + "depends": ["stock_account"], + "data": [ + "views/stock_move_views.xml", + ], + "installable": True, +} diff --git a/stock_account_return_origin_difference/models/__init__.py b/stock_account_return_origin_difference/models/__init__.py new file mode 100644 index 00000000..6bda2d24 --- /dev/null +++ b/stock_account_return_origin_difference/models/__init__.py @@ -0,0 +1 @@ +from . import stock_move diff --git a/stock_account_return_origin_difference/models/stock_move.py b/stock_account_return_origin_difference/models/stock_move.py new file mode 100644 index 00000000..98e3e8f9 --- /dev/null +++ b/stock_account_return_origin_difference/models/stock_move.py @@ -0,0 +1,37 @@ +# Copyright 2023 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + return_origin_svl_difference = fields.Boolean() + + def _action_done(self, cancel_backorder=False): + moves = super()._action_done(cancel_backorder) + for move in moves: + if not (move._is_out() and move.origin_returned_move_id): + continue + origin_move_svls = ( + move.origin_returned_move_id.stock_valuation_layer_ids.filtered( + lambda r: r.quantity > 0 + ) + ) + for svl in origin_move_svls: + origin_move_svls |= svl.stock_valuation_layer_ids + origin_unit_cost = 0 + return_unit_cost = 0 + if origin_move_svls: + origin_value = sum(origin_move_svls.mapped("value")) + origin_quantity = sum(origin_move_svls.mapped("quantity")) + origin_unit_cost = origin_value / origin_quantity + return_move_svls = move.stock_valuation_layer_ids + if return_move_svls: + return_value = sum(return_move_svls.mapped("value")) + return_quantity = sum(return_move_svls.mapped("quantity")) + return_unit_cost = abs(return_value / return_quantity) + if origin_unit_cost != return_unit_cost: + move.return_origin_svl_difference = True + return moves diff --git a/stock_account_return_origin_difference/readme/DESCRIPTION.md b/stock_account_return_origin_difference/readme/DESCRIPTION.md new file mode 100644 index 00000000..4f9c0401 --- /dev/null +++ b/stock_account_return_origin_difference/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module checks if there is a unit cost difference between the stock +valuation layers (SVLs) of receipts and their returns. diff --git a/stock_account_return_origin_difference/static/description/index.html b/stock_account_return_origin_difference/static/description/index.html new file mode 100644 index 00000000..cc0287e5 --- /dev/null +++ b/stock_account_return_origin_difference/static/description/index.html @@ -0,0 +1,410 @@ + + + + + + +Stock Account Return Origin Difference + + + +
+

Stock Account Return Origin Difference

+ + +

Beta License: AGPL-3 qrtl/axls-custom

+

This module checks if there is a unit cost difference between the stock +valuation layers (SVLs) of receipts and their returns.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile
  • +
+
+
+

Maintainers

+

This module is part of the qrtl/axls-custom project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/stock_account_return_origin_difference/views/stock_move_views.xml b/stock_account_return_origin_difference/views/stock_move_views.xml new file mode 100644 index 00000000..0ceb7de2 --- /dev/null +++ b/stock_account_return_origin_difference/views/stock_move_views.xml @@ -0,0 +1,30 @@ + + + + stock.move.search.inherit + stock.move + + + + + + + + + + stock.move.form.inherit + stock.move + + + + + + + + + +