Skip to content

Conversation

@depr-odoo
Copy link
Contributor

This commit ensure that if the name argument is not provided, it will automatically generate a default value for name based on the model and id.

When we call method get_anchor_link_to_record without name, it fails with

TypeError: get_anchor_link_to_record() missing 1 required positional argument: 'name'

Updated get_anchor_link_to_record to default 'name' to None if not provided.

Also added a check to ensure 'id' is not a tuple before proceeding with its use.

@robodoo
Copy link
Contributor

robodoo commented Sep 3, 2025

Pull request status dashboard

Copy link
Contributor

@Pirols Pirols left a comment

Choose a reason for hiding this comment

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

Left a couple of comments. Still, I think that providing a list/tuple of ids is a misuse of the function. So I'd expect the error to need correcting on the user-side. Otherwise, can you refer to where you encountered a relevant issue?

def get_anchor_link_to_record(model, id, name=None, action_id=None):
_validate_model(model)
if not name:
if isinstance(id, tuple):
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want this, we should also check for lists:

Suggested change
if isinstance(id, tuple):
if isinstance(id, (tuple, list)):

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not what we want. id must be an int.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

@depr-odoo remove this please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @aj-fuentes,
it's done

@depr-odoo
Copy link
Contributor Author

Hello @Pirols,

Some changes were suggested in the PR.

Based on these updates, I’m inserting records into Table A and adding values from Table B.
I also need to include the anchor link for the records in Table B.
However, Table A can only return the ID parameter of the Table B record .

There are 2 case in method get_anchor_link_to_record

  • Name is required
  • we're generating a default name when it's null.

However, when I pass only the ID and model and call the method, a TypeError occurs because the name is required.
In this context, generating a default name doesn't seem to resolve the issue.

@KangOl
Copy link
Contributor

KangOl commented Sep 3, 2025

upgradeci retry with always only crm

@depr-odoo depr-odoo force-pushed the master-make_name_argument_optional-depr branch 2 times, most recently from eda3805 to cfc92ef Compare September 8, 2025 10:08
This [commit](odoo#215)
ensure that if the name argument is not provided, it will
automatically generate a default value for name based on the model and id.

When we call method get_anchor_link_to_record without name,it fails with

```
TypeError: get_anchor_link_to_record() missing 1 required positional argument: 'name'
```

Updated get_anchor_link_to_record to default 'name' to None if not provided.
@depr-odoo depr-odoo force-pushed the master-make_name_argument_optional-depr branch from cfc92ef to d20f366 Compare September 8, 2025 10:10
Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

LGTM

cc: @KangOl

Copy link
Contributor

@KangOl KangOl left a comment

Choose a reason for hiding this comment

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

robodoo pushed a commit that referenced this pull request Sep 8, 2025
This [commit](#215)
ensure that if the name argument is not provided, it will
automatically generate a default value for name based on the model and id.

When we call method get_anchor_link_to_record without name,it fails with

```
TypeError: get_anchor_link_to_record() missing 1 required positional argument: 'name'
```

Updated get_anchor_link_to_record to default 'name' to None if not provided.

closes #312

Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
@robodoo robodoo closed this in cc87c6d Sep 8, 2025
@robodoo robodoo added the 18.5 label Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants