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

[16.0][mig] sale_last_price_info #2471

Merged
merged 42 commits into from
Dec 27, 2023

Conversation

heliaktiv
Copy link
Contributor

No description provided.

oihane and others added 30 commits April 11, 2023 16:09
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_last_price_info/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_last_price_info/es/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_last_price_info/de/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_last_price_info/zh_CN/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-13.0/sale-workflow-13.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_last_price_info/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-workflow-13.0/sale-workflow-13.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_last_price_info/zh_CN/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-workflow-13.0/sale-workflow-13.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_last_price_info/es/
Currently translated at 100.0% (11 of 11 strings)

Translation: sale-workflow-14.0/sale-workflow-14.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_last_price_info/ca/
Currently translated at 100.0% (11 of 11 strings)

Translation: sale-workflow-14.0/sale-workflow-14.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_last_price_info/nl/
Yvesldff and others added 11 commits April 11, 2023 16:09
Currently translated at 72.7% (8 of 11 strings)

Translation: sale-workflow-14.0/sale-workflow-14.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_last_price_info/fr_FR/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-workflow-14.0/sale-workflow-14.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_last_price_info/fr/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-workflow-14.0/sale-workflow-14.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_last_price_info/de/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-15.0/sale-workflow-15.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_last_price_info/
Currently translated at 100.0% (8 of 8 strings)

Translation: sale-workflow-15.0/sale-workflow-15.0-sale_last_price_info
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_last_price_info/it/
@rousseldenis
Copy link
Contributor

/ocabot migration sale_last_price_info

Copy link
Contributor

@rousseldenis rousseldenis 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

"website": "https://github.com/OCA/sale-workflow",
"category": "Sales",
"license": "AGPL-3",
"contributors": [
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a valid entry. Should be in CONTRIBUTORS.rst only.

If some of them (or you) want to adopt as maintainer, you should add a "maintainers":[<github login>, ...]instead

"""Get last sale price, last sale date and last customer"""
so_line_obj = self.env["sale.order.line"]
for product in self:
line = so_line_obj.search(
Copy link
Contributor

Choose a reason for hiding this comment

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

Something has to be done here as this will generate as many queries as products in recordset.

limit=1,
order="date_order_sale_last_price_info desc",
)
product.last_sale_date = fields.Datetime.to_string(
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
product.last_sale_date = fields.Datetime.to_string(
product.update({
"last_sale_date" : fields.Datetime.to_string(line.date_order_sale_last_price_info),
"last_sale_price": line.price_unit,
"last_customer_id": line.order_id.partner_id,
})

product.last_sale_price = line.price_unit
product.last_customer_id = line.order_id.partner_id

last_sale_price = fields.Float(compute="_compute_last_sale")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fields definitions should be on top

self.price_unit = 100.0

def test_sale_last_price_info_demo(self):
sale_line = self.sale_line_model.search(
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to rely on new records created in test. Then, don't search but rely on the record values you've just created.

Copy link
Contributor

@rousseldenis rousseldenis 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 functional review

@dreispt
Copy link
Member

dreispt commented Dec 27, 2023

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-2471-by-dreispt-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 84a9949 into OCA:16.0 Dec 27, 2023
2 checks passed
@OCA-git-bot
Copy link
Contributor

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