diff --git a/base_view_inheritance_extension/README.rst b/base_view_inheritance_extension/README.rst
index f8d02491b4f..150ef294c06 100644
--- a/base_view_inheritance_extension/README.rst
+++ b/base_view_inheritance_extension/README.rst
@@ -17,13 +17,13 @@ Extended view inheritance
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
- :target: https://github.com/OCA/server-tools/tree/17.0/base_view_inheritance_extension
+ :target: https://github.com/OCA/server-tools/tree/18.0/base_view_inheritance_extension
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-base_view_inheritance_extension
+ :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_view_inheritance_extension
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=17.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -75,7 +75,7 @@ conditional changes**
Known issues / Roadmap
======================
-- Support an ``eval`` attribute for our new node types.
+- Support an ``eval`` attribute for our new node types.
Bug Tracker
===========
@@ -83,7 +83,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -98,14 +98,19 @@ Authors
Contributors
------------
-- Holger Brunn
-- Ronald Portier
-- `Tecnativa `__:
+- Holger Brunn
+- Ronald Portier
+- `Tecnativa `__:
- - Sergio Teruel
- - Carlos Dauden
+ - Sergio Teruel
+ - Carlos Dauden
-- Iván Todorovich
+- `Trobz `__:
+
+ - Nhan Tran
+
+- Iván Todorovich
+- Frederic Grall
Maintainers
-----------
@@ -120,6 +125,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/server-tools `_ project on GitHub.
+This module is part of the `OCA/server-tools `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/base_view_inheritance_extension/__manifest__.py b/base_view_inheritance_extension/__manifest__.py
index 69b2e294899..e53e2eaa4ca 100644
--- a/base_view_inheritance_extension/__manifest__.py
+++ b/base_view_inheritance_extension/__manifest__.py
@@ -3,7 +3,7 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Extended view inheritance",
- "version": "17.0.1.0.1",
+ "version": "18.0.1.0.0",
"development_status": "Mature",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "LGPL-3",
diff --git a/base_view_inheritance_extension/models/ir_ui_view.py b/base_view_inheritance_extension/models/ir_ui_view.py
index bf10029fe6d..2593d3eff82 100644
--- a/base_view_inheritance_extension/models/ir_ui_view.py
+++ b/base_view_inheritance_extension/models/ir_ui_view.py
@@ -6,7 +6,6 @@
import ast
import re
-import astor
from lxml import etree
from odoo import api, models
@@ -29,7 +28,7 @@ def ast_dict_update(source, update):
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
@@ -83,21 +82,21 @@ def _iter_inheritance_specs(self, spec):
@api.model
def _get_inheritance_handler(self, node):
handler = super().apply_inheritance_specs
- if hasattr(self, "inheritance_handler_%s" % node.tag):
- handler = getattr(self, "inheritance_handler_%s" % node.tag)
+ if hasattr(self, f"inheritance_handler_{node.tag}"):
+ handler = getattr(self, f"inheritance_handler_{node.tag}")
return handler
@api.model
def _get_inheritance_handler_attributes(self, node):
handler = super().apply_inheritance_specs
- if hasattr(self, "inheritance_handler_attributes_%s" % node.get("operation")):
+ if hasattr(self, f"_inheritance_handler_attributes_{node.get('operation')}"):
handler = getattr(
- self, "inheritance_handler_attributes_%s" % node.get("operation")
+ self, f"_inheritance_handler_attributes_{node.get('operation')}"
)
return handler
@api.model
- def inheritance_handler_attributes_update(self, source, specs):
+ def _inheritance_handler_attributes_update(self, source, specs):
"""Implement dict `update` operation on the attribute node.
.. code-block:: xml
@@ -124,15 +123,11 @@ 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
- def inheritance_handler_attributes_text_add(self, source, specs):
+ def _inheritance_handler_attributes_text_add(self, source, specs):
"""Implement
<$node position="attributes">
@@ -149,7 +144,7 @@ def inheritance_handler_attributes_text_add(self, source, specs):
return source
@api.model
- def inheritance_handler_attributes_domain_add(self, source, specs):
+ def _inheritance_handler_attributes_domain_add(self, source, specs):
"""Implement
<$node position="attributes">
\>
- Iván Todorovich \<\>
+- Frederic Grall \<>
diff --git a/base_view_inheritance_extension/static/description/index.html b/base_view_inheritance_extension/static/description/index.html
index c7cab233ee9..2ab0fe2c573 100644
--- a/base_view_inheritance_extension/static/description/index.html
+++ b/base_view_inheritance_extension/static/description/index.html
@@ -8,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -368,7 +369,7 @@ Extended view inheritance
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:40e4b7b41dc5bf755dd39eedafb3e373b93138ec06e6e21c52c55857a4f28dd5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module was written to make it simple to add custom operators for
view inheritance.
Table of contents
@@ -425,7 +426,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
This module is maintained by the OCA.
-
+
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/server-tools project on GitHub.
+
This module is part of the OCA/server-tools project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py b/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
index b667b7b6325..eeaf22c2a73 100644
--- a/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
+++ b/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
@@ -16,7 +16,7 @@ def setUpClass(cls):
def test_base_view_inheritance_extension(self):
view_id = self.env.ref("base.view_partner_simple_form").id
- arch, view = self.env["res.partner"]._get_view(view_id=view_id)
+ arch, _ = self.env["res.partner"]._get_view(view_id=view_id)
# Verify normal attributes work
self.assertEqual(arch.xpath("//form")[0].get("string"), "Partner form")
# Verify our extra context key worked
@@ -104,120 +104,78 @@ def test_update_context_complex(self):
]
self.assertEqual(
res.xpath('//field[@name="invoice_line_ids"]')[0].attrib["context"],
- "{%s}" % ", ".join(expected_items),
+ "{%s}" % ", ".join(expected_items), # noqa: UP031
)
- def test_update_attrs_new_key(self):
- """Test that we can add new keys to an existing dict"""
+ def test_text_add_operation(self):
source = etree.fromstring(
"""
"""
)
+
specs = etree.fromstring(
"""
-
-
- {
- "required": [("state", "!=", "draft")],
- }
-
+
+ {old_value} Customer
"""
)
+
res = self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
self.assertEqual(
- res.xpath('//field[@name="ref"]')[0].attrib["attrs"],
- "{'invisible': [('state', '=', 'draft')], "
- "'required': [('state', '!=', 'draft')]}",
+ res.xpath('//field[@name="customer_id"]')[0].attrib["string"],
+ "Client Customer",
)
- def test_update_attrs_replace(self):
- """Test that we can replace an existing dict key"""
+ def test_update_operation_not_a_dict(self):
+ """We should get an error if we try to update a dict with a non-dict spec"""
source = etree.fromstring(
"""
"""
)
specs = etree.fromstring(
"""
-
- {
- "required": [('state', '!=', 'draft')],
- }
+
+ ["not", "a", "dict"]
"""
)
- res = self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
- self.assertEqual(
- res.xpath('//field[@name="ref"]')[0].attrib["attrs"],
- "{'invisible': [('state', '=', 'draft')], "
- "'required': [('state', '!=', 'draft')]}",
- )
+ with self.assertRaisesRegex(
+ TypeError, "Operation for attribute `context` is not a dict"
+ ):
+ self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
- def test_update_empty_source_dict(self):
- """Test that we can add new keys by creating the dict if it's missing"""
+ def test_domain_add_operation(self):
source = etree.fromstring(
"""
"""
)
specs = etree.fromstring(
"""
-
-
- {
- "required": [('state', '!=', 'draft')],
- }
+
+
+ [('state', '!=', 'draft')]
"""
)
res = self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
self.assertEqual(
- res.xpath('//field[@name="ref"]')[0].attrib["attrs"],
- "{'required': [('state', '!=', 'draft')]}",
- )
-
- def test_update_operation_not_a_dict(self):
- """We should get an error if we try to update a dict with a non-dict spec"""
- source = etree.fromstring(
- """
-
- """
+ res.xpath('//field[@name="child_ids"]')[0].attrib["domain"],
+ "['&', ('state', '=', 'confirm'), ('state', '!=', 'draft')]",
)
- specs = etree.fromstring(
- """
-
-
- ["not", "a", "dict"]
-
-
- """
- )
- with self.assertRaisesRegex(
- TypeError, "Operation for attribute `attrs` is not a dict"
- ):
- self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
def test_update_source_not_a_dict(self):
"""We should get an error if we try to update a non-dict attribute"""
diff --git a/requirements.txt b/requirements.txt
index 21a8995e145..fdcddc4ae29 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
# generated from manifests external_dependencies
+astor
dataclasses
mako
odoorpc
openupgradelib
-astor