Skip to content

Commit

Permalink
[10.0][IMP] stock_cycle_count: simplify fetching latest inventory date
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Mar 23, 2018
1 parent 49b666a commit 120bf42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stock_cycle_count/models/stock_cycle_count_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def _propose_cycle_count(self, date, location):
def _compute_rule_periodic(self, locs):
cycle_counts = []
for loc in locs:
last_inventories = self.env['stock.inventory'].search([
latest_inventory_date = self.env['stock.inventory'].search([
('location_id', '=', loc.id),
('state', 'in', ['confirm', 'done', 'draft'])]).mapped('date')
if last_inventories:
latest_inventory = sorted(last_inventories, reverse=True)[0]
('state', 'in', ['confirm', 'done', 'draft'])],
orderby="date desc", limit=1).date
if latest_inventory_date:
try:
period = self.periodic_count_period / \
self.periodic_qty_per_period
Expand Down

0 comments on commit 120bf42

Please sign in to comment.