Skip to content
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

[18.0][MIG] base_view_inheritance_extension #3100

Open
wants to merge 63 commits into
base: 18.0
Choose a base branch
from

Conversation

fredericgrall
Copy link

No description provided.

hbrunn and others added 30 commits October 29, 2024 17:11
Trivial changes:

* Version in README changed
* Version in manifest changed

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex
…extension. (OCA#804)

* Add list_add operation.
* Add list_remove operation.

OCA Transbot updated translations from Transifex
expression not match the node any more. Fixes OCA#885
*  warning about dynamic context
* import for safe_eval
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-13.0/server-tools-13.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_view_inheritance_extension/
* Removed `list_add` and `list_remove`, they've been deprecated and
implemented in Odoo core since several versions ago.

* Removed `move`, as it has also already been implemented in core several
versions ago.

* Replaced `python_dict` by `update`, that performs an operation similar
to :meth:`dict.update`, but on the ast.Dict.
badbole and others added 18 commits October 29, 2024 17:11
Currently translated at 100.0% (3 of 3 strings)

Translation: server-tools-16.0/server-tools-16.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension/hr/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-16.0/server-tools-16.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-tools-16.0/server-tools-16.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension/es_AR/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-tools-16.0/server-tools-16.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension/es/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-tools-16.0/server-tools-16.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-17.0/server-tools-17.0-base_view_inheritance_extension
Translate-URL: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-base_view_inheritance_extension/
@fredericgrall fredericgrall mentioned this pull request Oct 29, 2024
21 tasks
@fredericgrall fredericgrall force-pushed the 18.0-mig-base_view_inheritance_extension branch from c57e742 to c666397 Compare October 29, 2024 19:01
@fredericgrall fredericgrall force-pushed the 18.0-mig-base_view_inheritance_extension branch from c666397 to 3251ed6 Compare October 29, 2024 19:02
@@ -104,7 +104,7 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easy enough to avoid needing and we should try as hard as possible to only have absolutely necessary linting exceptions IMO. Odoo's own CI now fails if a linting exception is used after some high profile security issues introduced. That said I am not sure the current state of f-string vs format vs printf discussions in OCA. Last I knew it was f-string bad, printf bad, use format. Maybe someone who knows better can help here as a few f-string conversions up higher.

Anyway it won't stop me installing and testing so will give it a go now.

Copy link
Contributor

@gdgellatly gdgellatly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested context update using https://github.com/odoonz/odoonz-addons/tree/18.0/stock_prodlot_qty - which has multiple upstream views with context - works as expected

Copy link
Contributor

@gdgellatly gdgellatly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make secure, also concerns around tests and applicability IRT attrs, which may explain lack of test coverage of all the main methods in module.

@api.model
def _get_inheritance_handler_attributes(self, node):
handler = super().apply_inheritance_specs
if hasattr(self, f"inheritance_handler_attributes_{node.get('operation')}"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should check/call a private method

return handler

@api.model
def inheritance_handler_attributes_update(self, source, specs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be private

@api.model
def _get_inheritance_handler_attributes(self, node):
handler = super().apply_inheritance_specs
if hasattr(self, f"inheritance_handler_attributes_{node.get('operation')}"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if hasattr(self, f"inheritance_handler_attributes_{node.get('operation')}"):
if hasattr(self, f"_inheritance_handler_attributes_{node.get('operation')}"):

handler = super().apply_inheritance_specs
if hasattr(self, f"inheritance_handler_attributes_{node.get('operation')}"):
handler = getattr(
self, f"inheritance_handler_attributes_{node.get('operation')}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self, f"inheritance_handler_attributes_{node.get('operation')}"
self, f"_inheritance_handler_attributes_{node.get('operation')}"

return handler

@api.model
def inheritance_handler_attributes_update(self, source, specs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def inheritance_handler_attributes_update(self, source, specs):
def _inheritance_handler_attributes_update(self, source, specs):

self.var2str_domain_text(old_value.strip())
)
new_domain = ast.literal_eval(
self.var2str_domain_text(attribute_node.text.strip())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.var2str_domain_text(attribute_node.text.strip())
self._var2str_domain_text(attribute_node.text.strip())

return re.sub(regex, r"'\1_is_a_var_to_replace'", domain_str)

@api.model
def str2var_domain_text(self, domain_str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def str2var_domain_text(self, domain_str):
def _str2var_domain_text(self, domain_str):

return source

@api.model
def var2str_domain_text(self, domain_str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def var2str_domain_text(self, domain_str):
def _var2str_domain_text(self, domain_str):

new_value = str(expression.OR([old_domain, new_domain]))
else:
new_value = str(expression.AND([old_domain, new_domain]))
new_value = self.str2var_domain_text(new_value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new_value = self.str2var_domain_text(new_value)
new_value = self._str2var_domain_text(new_value)

<form>
<field
name="ref"
attrs="{'invisible': [('state', '=', 'draft')]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test makes no sense? - attrs is gone in v18. Hmm, this might have big consequences for module - all these tests containing attrs I think will need changing.

Copy link

@xaviedoanhduy xaviedoanhduy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For being easily searchable and avoiding to duplicate efforts, please name the pull request following this pattern: [18.0][MIG] : Migration to 18.0.

and please check the CI

@youring
Copy link

youring commented Oct 30, 2024

Would you please consider pick these two commits for v16.0 if approprate? Thanks.
de26c37
d7484f4

@gdgellatly
Copy link
Contributor

For being easily searchable and avoiding to duplicate efforts, please name the pull request following this pattern: [18.0][MIG] : Migration to 18.0.

and please check the CI

@xaviedoanhduy Maybe you could help him? I mean I've done this a long time, and I have no idea why a set of unrelated modules caused errors like that or what I would need to do to fix

@fredericgrall
Copy link
Author

@gdgellatly,I'm going to modify to use a private method, thank you for your comments and I'm a little confused about the modifications needed for the CI.

@sebalix sebalix changed the title 18.0 mig base view inheritance extension [18.0][MIG] base_view_inheritance_extension Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.