def METHOD_NAME(self, vals):
    # Add depreciation if it's missing while category is set
    create_deps_from_categ = False
    if vals.get("category_id") and not vals.get("depreciation_ids"):
        create_deps_from_categ = True
    if vals.get("code"):
        vals["code"] = " ".join(vals.get("code").split())
    asset = super().METHOD_NAME(vals)
    if create_deps_from_categ:
        asset.onchange_category_id()
    return asset