Skip to content

Commit

Permalink
[REF] pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RLeeOSI committed Nov 28, 2023
1 parent bf5fbe2 commit 1e2096a
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 86 deletions.
3 changes: 1 addition & 2 deletions osi_fifo_serialized_fix/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Copyright (C) 2021, Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

Expand All @@ -13,6 +12,6 @@
"category": "Accounting",
"depends": ["stock_account", "mrp_account"],
"data": ["views/stock_valuation_layer.xml"],
"maintainers": ["osi-scampbell","Chanakya-OSI"],
"maintainers": ["osi-scampbell", "Chanakya-OSI"],
"installable": True,
}
26 changes: 17 additions & 9 deletions osi_fifo_serialized_fix/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools import float_is_zero, float_repr, float_round, float_compare


class StockMove(models.Model):
Expand Down Expand Up @@ -66,13 +65,20 @@ def get_ji_ids(self, move, svl_ids):
else:
move.stock_valuation_layer_ids.lot_ids = [(6, 0, svl_ids[0][2])]
svl = self.env["stock.valuation.layer"].browse(svl_ids[0][0])
linked_svl = self.env["stock.valuation.layer"].search([('stock_valuation_layer_id', '=', svl.id)])
linked_svl = self.env["stock.valuation.layer"].search(
[("stock_valuation_layer_id", "=", svl.id)]
)
unit_cost = svl.unit_cost
for link_svl in linked_svl:
unit_cost += link_svl.value
move.stock_valuation_layer_ids.unit_cost = unit_cost
move.stock_valuation_layer_ids.value = (move.stock_valuation_layer_ids.quantity * move.stock_valuation_layer_ids.unit_cost)
move.stock_valuation_layer_ids.remaining_value = move.stock_valuation_layer_ids.value
move.stock_valuation_layer_ids.value = (
move.stock_valuation_layer_ids.quantity
* move.stock_valuation_layer_ids.unit_cost
)
move.stock_valuation_layer_ids.remaining_value = (
move.stock_valuation_layer_ids.value
)
ji_ids[0].move_id.button_draft()
# The Valuation Layer has been changed,
# now we have to edit the STJ Entry
Expand All @@ -96,7 +102,11 @@ def get_svl_ids(self, move):
svl_ids = []
# We need to get all of the valuation layers associated with this product
test_vals = self.env["stock.valuation.layer"].search(
[("product_id", "=", move.product_id.id), ('stock_valuation_layer_id', '=', False)], order="id desc"
[
("product_id", "=", move.product_id.id),
("stock_valuation_layer_id", "=", False),
],
order="id desc",
)
for line_id in move.move_line_ids:
for valuation in test_vals:
Expand All @@ -116,10 +126,8 @@ def get_svl_ids(self, move):
self.increment_qty(valuation.id, svl_ids, line_id.lot_id.id)
if len(svl_ids) == 0 and self.location_id.create_je is True:
raise UserError(
_(
"Need Check Stock Valution Layer For this Product :- %s"
% (move.product_id.name)
)
_("Need Check Stock Valution Layer For this Product :- %s")
% (move.product_id.name)
)
self.get_ji_ids(move, svl_ids)

Expand Down
Loading

0 comments on commit 1e2096a

Please sign in to comment.