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

[14.0][FIX] pos_fixed_discount: fix float conversion #1275

Merged

Conversation

GSLabIt
Copy link

@GSLabIt GSLabIt commented Dec 12, 2024

No description provided.

@OCA-git-bot
Copy link
Contributor

Hi @eLBati,
some modules you are maintaining are being modified, check this out!

Copy link
Contributor

@francesco-ooops francesco-ooops left a comment

Choose a reason for hiding this comment

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

Functional ok

This solves an issue with global discount which is not taking decimals into consideration, see video

@francesco-ooops
Copy link
Contributor

@eLBati could you take a look?

Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code and function review, LGTM.

Even when trying to insert a number like 1.445 in the discount popup, it's correctly rounded to 1.45

@@ -17,8 +17,7 @@ odoo.define("pos_fixed_discount.FixedDiscountButton", function (require) {
startingValue: 0,
});
if (confirmed) {
var val = Math.round(parseFloat(payload));
this.apply_discount(val);
this.apply_discount(payload.replace(",", "."));
Copy link

@aleuffre aleuffre Dec 17, 2024

Choose a reason for hiding this comment

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

comment: Tested this, couldn't find a reason for the replace, even if I type , in the discount, I still get a . in the payload. Is it due to language settings in Odoo or the browser? Either way, this seems fine to me.

I'd perhaps keep the call to parseFloat just to be safe with Javascript?

Really what was the breaking the flow was only the call to Math.round

Copy link
Author

Choose a reason for hiding this comment

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

comment: Tested this, couldn't find a reason for the replace, even if I type , in the discount, I still get a . in the payload. Is it due to language settings in Odoo or the browser? Either way, this seems fine to me.

Probably on language settings or a combination of this one and numpad dot; btw i got "," on payload

I'd perhaps keep the call to parseFloat just to be safe with Javascript?

it is ok, will re.add; removed following other modules, like:

await self.apply_discount(payload.replace(",", "."));

Really what was the breaking the flow was only the call to Math.round

Yeah, the issue was Math.round

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@GSLabIt GSLabIt force-pushed the 14.0-fix-pos_fixed_discount-fix_decimal_values branch from ab71936 to 6623ce6 Compare December 17, 2024 16:46
@francesco-ooops
Copy link
Contributor

@eLBati good to go? thanks!

@francesco-ooops
Copy link
Contributor

@OCA/pos-maintainers can this be merged please?

@legalsylvain
Copy link
Contributor

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-1275-by-legalsylvain-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 2582381 into OCA:14.0 Dec 19, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at fd4b965. Thanks a lot for contributing to OCA. ❤️

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.

5 participants