Skip to content

Commit fdddfb7

Browse files
[ADD] stock_account_fifo_return_origin
1 parent 4046654 commit fdddfb7

File tree

13 files changed

+666
-0
lines changed

13 files changed

+666
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_account_fifo_return_origin
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
================================
2+
Stock Account FIFO Return Origin
3+
================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:f365b070c877cb49d483654699911d0f9d351de248cfca5a6cdf11258d8a7017
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_account_fifo_return_origin
21+
:alt: OCA/stock-logistics-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_account_fifo_return_origin
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module makes adjustment to the standard behavior with regards to candidate SVLs
32+
that are used in purchase returns; if the SVL linked to the origin move (receipt) has
33+
remaining quantity, that SVL should be consumed first.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Bug Tracker
41+
===========
42+
43+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
44+
In case of trouble, please check there if your issue has already been reported.
45+
If you spotted it first, help us to smash it by providing a detailed and welcomed
46+
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_account_fifo_return_origin%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
47+
48+
Do not contact contributors directly about support or help with technical issues.
49+
50+
Credits
51+
=======
52+
53+
Authors
54+
~~~~~~~
55+
56+
* Quartile
57+
58+
Maintainers
59+
~~~~~~~~~~~
60+
61+
This module is maintained by the OCA.
62+
63+
.. image:: https://odoo-community.org/logo.png
64+
:alt: Odoo Community Association
65+
:target: https://odoo-community.org
66+
67+
OCA, or the Odoo Community Association, is a nonprofit organization whose
68+
mission is to support the collaborative development of Odoo features and
69+
promote its widespread use.
70+
71+
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_account_fifo_return_origin>`_ project on GitHub.
72+
73+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Stock Account FIFO Return Origin",
6+
"version": "16.0.1.0.0",
7+
"license": "AGPL-3",
8+
"author": "Quartile, Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/stock-logistics-workflow",
10+
"depends": ["stock_account"],
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import product
2+
from . import stock_move
3+
from . import stock_move_line
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class Product(models.Model):
8+
_inherit = "product.product"
9+
10+
def _get_fifo_candidates(self, company):
11+
candidates = super()._get_fifo_candidates(company)
12+
origin_move = self.env.context.get("origin_returned_move")
13+
if not origin_move:
14+
return candidates
15+
origin_svl = origin_move.stock_valuation_layer_ids.filtered(
16+
lambda x: x.remaining_qty > 0.00
17+
)
18+
return origin_svl | candidates
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class StockMove(models.Model):
8+
_inherit = "stock.move"
9+
10+
def _create_out_svl(self, forced_quantity=None):
11+
return_moves = self.filtered(lambda m: m.origin_returned_move_id)
12+
other_moves = self - return_moves
13+
res = self.env["stock.valuation.layer"].sudo()
14+
if other_moves:
15+
res |= super(StockMove, other_moves)._create_out_svl(forced_quantity)
16+
for move in return_moves:
17+
res |= super(
18+
StockMove,
19+
move.with_context(origin_returned_move=move.origin_returned_move_id),
20+
)._create_out_svl(forced_quantity)
21+
return res
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, models
5+
6+
7+
class StockMoveLine(models.Model):
8+
_inherit = "stock.move.line"
9+
10+
@api.model
11+
def _create_correction_svl(self, move, diff):
12+
if move._is_in() and diff < 0:
13+
move = move.with_context(origin_returned_move=move)
14+
return super()._create_correction_svl(move, diff)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module makes adjustment to the standard behavior with regards to candidate SVLs
2+
that are used in purchase returns; if the SVL linked to the origin move (receipt) has
3+
remaining quantity, that SVL should be consumed first.

0 commit comments

Comments
 (0)