Skip to content

[18.0][MIG] base_view_inheritance_extension - #3100

Closed
fredericgrall wants to merge 63 commits into
OCA:18.0from
apikcloud:18.0-mig-base_view_inheritance_extension
Closed

[18.0][MIG] base_view_inheritance_extension#3100
fredericgrall wants to merge 63 commits into
OCA:18.0from
apikcloud:18.0-mig-base_view_inheritance_extension

Conversation

@fredericgrall

Copy link
Copy Markdown
Contributor

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.
ibuioli and others added 15 commits October 29, 2024 17:11
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
42 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
self.assertEqual(
res.xpath('//field[@name="invoice_line_ids"]')[0].attrib["context"],
"{%s}" % ", ".join(expected_items),
"{%s}" % ", ".join(expected_items), # noqa: UP031

Copy link
Copy Markdown
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.

@gdgellatly gdgellatly left a comment

Copy link
Copy Markdown
Contributor

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

@gdgellatly gdgellatly left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@xaviedoanhduy xaviedoanhduy left a comment

Copy link
Copy Markdown
Contributor

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

youring commented Oct 30, 2024

Copy link
Copy Markdown

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

@gdgellatly

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
@pedrobaeza

Copy link
Copy Markdown
Member

Yes.

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.