Skip to content

Commit

Permalink
Merge PR OCA#1861 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by JordiBForgeFlow

(cherry picked from commit d5e1861)
  • Loading branch information
OCA-git-bot authored and agyamuta committed Feb 28, 2024
1 parent 5a39266 commit c84a3a2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stock_inventory/models/stock_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InventoryAdjustmentsGroup(models.Model):
)

count_stock_quants = fields.Integer(
compute="_compute_count_stock_quants", string="Adjustments"
compute="_compute_count_stock_quants", string="# Adjustments"
)

count_stock_quants_string = fields.Char(
Expand Down
13 changes: 11 additions & 2 deletions stock_inventory/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import _, fields, models


class StockQuant(models.Model):
Expand All @@ -22,15 +22,24 @@ def _apply_inventory(self):
[
("product_id", "=", rec.product_id.id),
("lot_id", "=", rec.lot_id.id),
("company_id", "=", rec.company_id.id),
"|",
("location_id", "=", rec.location_id.id),
("location_dest_id", "=", rec.location_id.id),
],
order="create_date asc",
).filtered(
lambda x: not x.company_id.id
or not rec.company_id.id
or rec.company_id.id == x.company_id.id
)
if len(moves) == 0:
raise ValueError(_("No move lines have been created"))
move = moves[len(moves) - 1]
adjustment.stock_move_ids |= move
move.inventory_adjustment_id = adjustment
rec.to_do = False
return res

def _get_inventory_fields_write(self):
return super()._get_inventory_fields_write() + ["to_do"]

2 changes: 2 additions & 0 deletions stock_inventory/tests/test_stock_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ def test_05_category_selection(self):
}
)
inventory1.action_state_to_in_progress()
# Remove company_id from stock-quant to test it works as expected
inventory1.stock_quant_ids.write({"company_id": False})
self.assertEqual(inventory1.stock_quant_ids.ids, [self.quant4.id])
inventory1.action_state_to_draft()
self.assertEqual(inventory1.stock_quant_ids.ids, [])
Expand Down

0 comments on commit c84a3a2

Please sign in to comment.