8000 [17.0][FIX] base_view_inheritance_extension: multiple DepreciationWarning by vvrossem · Pull Request #3317 · OCA/server-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[17.0][FIX] base_view_inheritance_extension: multiple DepreciationWarning #3317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions base_view_inheritance_extension/models/ir_ui_view.py
< 8000 div class="data highlight js-blob-wrapper js-check-hidden-unicode " >
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@
# Copyright 2023 Tecnativa - Carlos Dauden
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import ast
import logging
import re

try:
import astor
except ImportError as err: # pragma: no cover
_logger = logging.getLogger(__name__)
_logger.debug(err)

from lxml import etree

from odoo import api, models
Expand All @@ -34,11 +27,8 @@ def ast_dict_update(source, update):
raise TypeError("`update` must be an AST dict")

def ast_key_eq(k1, k2):
# python < 3.8 uses ast.Str; python >= 3.8 uses ast.Constant
if type(k1) != type(k2):
if type(k1) is not type(k2):
return False
elif isinstance(k1, ast.Str):
return k1.s == k2.s
elif isinstance(k1, ast.Constant):
return k1.value == k2.value

Expand Down Expand Up @@ -130,11 +120,7 @@ def inheritance_handler_attributes_update(self, source, specs):
# Update node ast dict
source_ast = ast_dict_update(source_ast, update_ast)
# Dump the ast back to source
# TODO: once odoo requires python >= 3.9; use `ast.unparse` instead
node.attrib[attr_name] = astor.to_source(
source_ast,
pretty_source=lambda s: "".join(s).strip(),
)
node.attrib[attr_name] = ast.unparse(source_ast).strip()
return source

@api.model
Expand Down
0