Skip to content

Conversation

@mihien
Copy link

@mihien mihien commented Dec 7, 2025

No description provided.

@mihien mihien force-pushed the 16.0-fix-cooperator_website_minimal_qty branch 2 times, most recently from 5b9bbed to 99979c5 Compare December 8, 2025 08:26
Comment on lines 920 to 924
_(
"The number of shares must be more than the defined minimum "
f"quantity of this share. For {sub_req.share_product_id.short_name},"
" the minimum is"
f"{sub_req.share_product_id.product_tmpl_id.minimum_quantity}."
)
Copy link
Member

Choose a reason for hiding this comment

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

f-strings prevent localization (as they would change the source string). the substitution must be done after the translation.

Suggested change
_(
"The number of shares must be more than the defined minimum "
f"quantity of this share. For {sub_req.share_product_id.short_name},"
" the minimum is"
f"{sub_req.share_product_id.product_tmpl_id.minimum_quantity}."
)
_(
"The number of shares must be more than the defined minimum "
"quantity of this share. For {share_type}, the minimum is "
"{minimum_quantity}."
).format(
share_type=sub_req.share_product_id.short_name,
minimum_quantity=sub_req.share_product_id.product_tmpl_id.minimum_quantity
)

Comment on lines 862 to 865
_(
"Number of shares must be greater than "
f"{self.share_product_id.product_tmpl_id.minimum_quantity}"
)
Copy link
Member

Choose a reason for hiding this comment

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

same remarks about f-strings as below.

if share_product["force_min_qty"] and qty_share <= share_product["min_qty"]:
values = self.fill_values(values, is_company, logged)
values["error_msg"] = _(
"Number of share must be greater than {min_qty}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Number of share must be greater than {min_qty}"
"Number of shares must be greater than {min_qty}."

Comment on lines 344 to 348
# check subscription respect min qty of shares
share_product_id = int(kwargs.get("share_product_id"))
share_product = self.get_share_product(share_product_id)[share_product_id]
qty_share = int(kwargs.get("ordered_parts"))
if share_product["force_min_qty"] and qty_share <= share_product["min_qty"]:
Copy link
Member

Choose a reason for hiding this comment

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

this logic should be better moved to a separate method to keep this function as short as possible (even if it is already much too long) and to make it clear what is checked here. something like:

if not validate_minimum_quantity(kwargs):

Comment on lines -24 to -29
$("#ordered_parts").change();
var $share_price = $("#share_price").text();
$('input[name="total_parts"]').val(
$("#ordered_parts").val() * $share_price
);
$('input[name="total_parts"]').change();
Copy link
Member

Choose a reason for hiding this comment

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

why were there calls to .change() previously and not anymore?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not exactly sure why they were there, but I've tested with and without, and I end up with the same result. I think it might be because the use of .data() requires a call to .change() to be applied whereas .val() doesn't, but I'm not sure.

Copy link
Member

Choose a reason for hiding this comment

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

adding a small (python) test to cover these 2 cases would be nice.

@mihien mihien force-pushed the 16.0-fix-cooperator_website_minimal_qty branch from 99979c5 to 14bf8cb Compare December 8, 2025 14:18
@mihien
Copy link
Author

mihien commented Dec 8, 2025

@huguesdk thanks for the review ! I've made the suggested changes plus a fair amount more for the tests

@mihien mihien requested a review from huguesdk December 8, 2025 14:57
Copy link

@polchampion polchampion left a comment

Choose a reason for hiding this comment

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

@mihien unsuccessful test on the runboat:
screenshot-oca-cooperative-16-0-pr174-14bf8cb8ff88 runboat odoo-community org-2025 12 09-09_11_36

yet all fields are filled

perhaps a missing config in the demo data?

@mihien
Copy link
Author

mihien commented Dec 9, 2025

@polchampion The reason is probably because there is no localization module installed, in which case it will always fail because there is nothing handling the iban field of the form. Can you try again with l10n_be_cooperator installed? (Just to clarify, this is the current behaviour of cooperator, it hasn't been introduced by this PR)

@mihien mihien force-pushed the 16.0-fix-cooperator_website_minimal_qty branch from 14bf8cb to f0f43d7 Compare December 11, 2025 09:58
Copy link

@polchampion polchampion left a comment

Choose a reason for hiding this comment

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

successful functional test on runboat

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.

3 participants