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

[FIX] stock_no_negative: use display_name instead of name_get because it is deprecated #1862

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from

Conversation

micheledic
Copy link

name_get is deprecated the error
AttributeError: 'stock.lot' object has no attribute 'name_get'
appear

@@ -39,7 +39,7 @@ def check_negative_qty(self):
):
msg_add = ""
if quant.lot_id:
msg_add = _(" lot {}").format(quant.lot_id.name_get()[0][1])
msg_add = _(" lot {}").format(quant.lot_id.display_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove also format() method and use translation function arguments instead ?

Suggested change
msg_add = _(" lot {}").format(quant.lot_id.display_name)
msg_add = _(" lot %(name)s", name=quant.lot_id.display_name)

And add a test to avoid regression ? Thanks

Copy link
Author

Choose a reason for hiding this comment

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

Hello, i changed the format function.
How should i create the test ? Should i assert the FULL ValidationError message content ?

the msg_add is used in a dynamic string passed to a validation error

@rousseldenis rousseldenis added this to the 18.0 milestone Jan 31, 2025
@micheledic micheledic force-pushed the 18.0_fix_stock_no_negative branch from 44d9a28 to 6e7e146 Compare January 31, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants