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

[MIG] product_pricelist_simulation_margin: Migration to 16.0 #1354

Merged

Conversation

hugo-cordoba
Copy link
Contributor

ADD new module product_pricelist_simulation_margin into version 16.0

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

partial review.

readonly=True,
)

bg_color = fields.Char(compute="_compute_bg_color")
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should remove bg_color and computation and so one. That was a try in V12, but in fact, the result is not good, and my user asked me to disable the backgrounds.

Not a blocking point. What do you think ?

@legalsylvain
Copy link
Contributor

legalsylvain commented Jun 7, 2023

Side question :
do we have to put that module in product-attribute (as it depends on module product_pricelist_simulation) or do we have to put it in margin-analysis, because it is related to margin ?
No idea on that topic. Maybe @pedrobaeza has a point of view.

@hugo-cordoba
Copy link
Contributor Author

hugo-cordoba commented Jun 7, 2023

hi @legalsylvain.

I haven't finished migrating the module yet, I stopped for lunch and left the PR uploaded so as not to lose it. That's why I hadn't pinged you yet. I'm going to add the test and fix the pre-commit bugs.

Regarding what you comment about 'bg_color', I agree with you, I don't see sense that this is still there, in my experience, I have never used it, nor do I find that it brings a great added value.

Finally, in my opinion, the module should stay in this repository.

@pedrobaeza
Copy link
Member

Yes, being such tiny extension to a module being hosted here, it would be weird to not be located in the same place.

@legalsylvain
Copy link
Contributor

I haven't finished migrating the module yet, I stopped for lunch and left the PR uploaded so as not to lose it. That's why I hadn't pinged you yet. I'm going to add the test and fix the pre-commit bugs.

sorry for the nagging! I was impatient...
Note : at the start of the PR, you can choose to set "draft PR", so it's explicit. Unfortunately, you can not put a non draft PR to draft state, once the PR is created.

Yes, being such tiny extension to a module being hosted here, it would be weird to not be located in the same place.

👍

Regarding what you comment about 'bg_color', I agree with you, I don't see sense that this is still there, in my experience, I have never used it, nor do I find that it brings a great added value.

I think you can so remove it. Less code to maintain.

@hugo-cordoba hugo-cordoba marked this pull request as draft June 7, 2023 14:40
@hugo-cordoba hugo-cordoba force-pushed the 16.0-mig-product_pricelist_simulation_margin branch 2 times, most recently from db2ca77 to 2e1a8e6 Compare June 7, 2023 15:12
@hugo-cordoba hugo-cordoba marked this pull request as ready for review June 7, 2023 15:15
@hugo-cordoba
Copy link
Contributor Author

@legalsylvain you are correct, I did not put the pr in draft. I have uploaded an update, it should be all correct. I am waiting for your feedback :)

Best regards!

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

Just tested on runboat. some things are missing. (or maybe I missed something...)

Configuration :

image

Result

image

Problem

  • The column "Price" should be hidden
  • The column "Cost" (standard_price) should be visible
  • The margin is not computed
  • The margin % is not computed

Thanks !

@hugo-cordoba
Copy link
Contributor Author

Hi @legalsylvain, I haven't forgotten about this, but this week it has been impossible for me to get busy. I'll check it tomorrow!

@legalsylvain
Copy link
Contributor

no problem ! take your time. Just ping me when you want a review.

Thanks !

@hugo-cordoba hugo-cordoba force-pushed the 16.0-mig-product_pricelist_simulation_margin branch 3 times, most recently from 15d326b to 8c8fa24 Compare June 19, 2023 10:14
@hugo-cordoba
Copy link
Contributor Author

Hi @legalsylvain, how are you?

I have made the changes you proposed, when you have time, can you check that everything works fine?

Regards!

Copy link

@aliciagaarzo aliciagaarzo left a comment

Choose a reason for hiding this comment

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

Code review LGTM!

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

functional review. LGTM ! Thanks !

Some minor propositions inline.

regards.

)
rslt.update(
{
"pricelist_id": pricelist.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to return that value, as the super function return the value. See :
https://github.com/OCA/product-attribute/blob/16.0/product_pricelist_simulation/wizards/wizard_preview_pricelist.py#L59-L67

don't you think ?

_inherit = "wizard.preview.pricelist.line"
_description = "wizard - Preview Pricelist Line"

price_vat_excl = fields.Float(string="Unit Sales Price (Excl.)", readonly=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
price_vat_excl = fields.Float(string="Unit Sales Price (Excl.)", readonly=True)
price_vat_excl = fields.Monetary(
string="Unit Sales Price (Excl.)",
readonly=True,
currency_field="currency_id",
digits="Price",
)

_description = "wizard - Preview Pricelist Line"

price_vat_excl = fields.Float(string="Unit Sales Price (Excl.)", readonly=True)
price_vat_incl = fields.Float(string="Unit Sales Price (Incl.)", readonly=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
price_vat_incl = fields.Float(string="Unit Sales Price (Incl.)", readonly=True)
price_vat_incl = fields.Monetary(
string="Unit Sales Price (Incl.)",
readonly=True,
currency_field="currency_id",
digits="Price",
)

price_vat_excl = fields.Float(string="Unit Sales Price (Excl.)", readonly=True)
price_vat_incl = fields.Float(string="Unit Sales Price (Incl.)", readonly=True)

margin = fields.Float(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
margin = fields.Float(
margin = fields.Monetary(


margin = fields.Float(
store=True,
digits=dp.get_precision("Product Price"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
digits=dp.get_precision("Product Price"),
digits="Price",
currency_field="currency_id",

margin_percent = fields.Float(
string="Margin (%)",
store=True,
digits=dp.get_precision("Product Price"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
digits=dp.get_precision("Product Price"),
digits="Price",


from odoo import fields, models

from odoo.addons import decimal_precision as dp
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from odoo.addons import decimal_precision as dp

@hugo-cordoba hugo-cordoba force-pushed the 16.0-mig-product_pricelist_simulation_margin branch from 8c8fa24 to ded4554 Compare June 20, 2023 10:32
@hugo-cordoba
Copy link
Contributor Author

Hi @legalsylvain! Thanks for the review. I have just made the changes.

I have a question, what is the difference between creating a float field and adding the monetary widget or making the field 'monetary' directly?

@legalsylvain
Copy link
Contributor

I have a question, what is the difference between creating a float field and adding the monetary widget or making the field 'monetary' directly?

Float + digits will set allways the same number of digits. Not work in multi currency context.
Monetary + currency will set the number of digits defined in the current currency. For money fields, monetary field is better.

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

Thanks for your work !

@hugo-cordoba
Copy link
Contributor Author

Understood, thanks for the explanation @legalsylvain.

@pedrobaeza can you check this pr? Thank you very much!!

@pedrobaeza
Copy link
Member

/ocabot migration product_pricelist_simulation_margin
/ocabot merge nobump

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Jun 20, 2023
@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-1354-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 890fe23 into OCA:16.0 Jun 20, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at bc0f253. 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