<commit_before># Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, fields, models


class StockLocation(models.Model):
    _inherit = "stock.location"

    last_inventory_date = fields.Datetime(
        "Last Inventory Date",
        compute="_compute_last_inventory_date",
        store=True,
        help="Indicates the last inventory date for the location (only for "
        "validated inventories). It is only computed for leaf locations.",
    )

    # This field reuses the Many2many already defined in the model
    # stock.inventory, so this definition adds little overhead, and
    # allows to create the list of depends needed by the field for the
    # Last Inventory Date.
    validated_inventory_ids = fields.Many2many(
        "stock.inventory",
        relation="stock_inventory_stock_location_rel",
        column1="stock_location_id",
        column2="stock_inventory_id",
        string="Stock Inventories",
        help="Stock inventories in state validated for this location.",
        domain="[('location_ids', 'in', id), ('state', '=', 'done')]",
    )

    @api.depends("validated_inventory_ids", "validated_inventory_ids.date")
    def _compute_last_inventory_date(self):
        """Store date of the last inventory for each leaf location"""
        for loc in self:
            if (
                loc.usage != "view"
                and not loc.child_ids
                and loc.validated_inventory_ids
            ):
                loc.last_inventory_date = loc.validated_inventory_ids.sorted(<commit_msg>[FIX] Add missing fields in the api.depends<commit_after># Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, fields, models


class StockLocation(models.Model):
    _inherit = "stock.location"

    last_inventory_date = fields.Datetime(
        "Last Inventory Date",
        compute="_compute_last_inventory_date",
        store=True,
        help="Indicates the last inventory date for the location (only for "
        "validated inventories). It is only computed for leaf locations.",
    )

    # This field reuses the Many2many already defined in the model
    # stock.inventory, so this definition adds little overhead, and
    # allows to create the list of depends needed by the field for the
    # Last Inventory Date.
    validated_inventory_ids = fields.Many2many(
        "stock.inventory",
        relation="stock_inventory_stock_location_rel",
        column1="stock_location_id",
        column2="stock_inventory_id",
        string="Stock Inventories",
        help="Stock inventories in state validated for this location.",
        domain="[('location_ids', 'in', id), ('state', '=', 'done')]",
    )

    @api.depends(
        "validated_inventory_ids",
        "validated_inventory_ids.date",
        "validated_inventory_ids.usage",
        "validated_inventory_ids.child_ids",
    )
    def _compute_last_inventory_date(self):
        """Store date of the last inventory for each leaf location"""
        for loc in self:
            if (
                loc.usage != "view"
                and not loc.child_ids
                and loc.validated_inventory_ids
            ):
                loc.last_inventory_date = loc.validated_inventory_ids.sorted(
{'fraction_non_alphanumeric': 0.09164420485175202, 'fraction_numerical': 0.005989817310572028, 'mean_word_length': 2.7612612612612613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978952', 'n_tokens_mistral': 962, 'n_tokens_neox': 923, 'n_words': 266}