-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] stock_account_return_origin_difference
- Loading branch information
1 parent
e6f3c42
commit c2d3f88
Showing
10 changed files
with
559 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...stock_account_return_origin_difference/odoo/addons/stock_account_return_origin_difference
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 @@ | ||
../../../../stock_account_return_origin_difference |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=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,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 <https://github.com/qrtl/axls-custom/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/qrtl/axls-custom/issues/new?body=module:%20stock_account_return_origin_difference%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 | ||
------- | ||
|
||
* Quartile | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `qrtl/axls-custom <https://github.com/qrtl/axls-custom/tree/16.0/stock_account_return_origin_difference>`_ project on GitHub. | ||
|
||
You are welcome to 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 @@ | ||
from . import models |
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,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, | ||
} |
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 @@ | ||
from . import stock_move |
37 changes: 37 additions & 0 deletions
37
stock_account_return_origin_difference/models/stock_move.py
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,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 |
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 @@ | ||
This module checks if there is a unit cost difference between the stock | ||
valuation layers (SVLs) of receipts and their returns. |
Oops, something went wrong.