Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Inventory

Entity: stock.location

Compute Method: _compute_next_inventory_date

View 19.0 View 20.0
Inputs Method Outputs
  • company_id
  • usage
  • cyclic_inventory_frequency
  • last_inventory_date
+ today = fields.Date.context_today(self)
for location in self:
            if location.company_id and location.usage in ['internal', 'transit'] and location.cyclic_inventory_frequency > 0:
                try:
                    if location.last_inventory_date:
-                         days_until_next_inventory = location.cyclic_inventory_frequency - (fields.Date.today() - location.last_inventory_date).days
+                         days_until_next_inventory = location.cyclic_inventory_frequency - (today - location.last_inventory_date).days
                        if days_until_next_inventory <= 0:
-                             location.next_inventory_date = fields.Date.today() + timedelta(days=1)
+                             location.next_inventory_date = today + timedelta(days=1)
                        else:
                            location.next_inventory_date = location.last_inventory_date + timedelta(days=location.cyclic_inventory_frequency)
                    else:
-                         location.next_inventory_date = fields.Date.today() + timedelta(days=location.cyclic_inventory_frequency)
+                         location.next_inventory_date = today + timedelta(days=location.cyclic_inventory_frequency)
                except OverflowError:
                    raise UserError(_("The selected Inventory Frequency (Days) creates a date too far into the future."))
            else:
                location.next_inventory_date = False
  • next_inventory_date

Back to entity