Skip to content

[18.0][MIG] sell_only_by_packaging: Migration to 18.0#10

Closed
trisdoan wants to merge 12 commits into18.0from
18.0-mig-sell_only_by_packaging
Closed

[18.0][MIG] sell_only_by_packaging: Migration to 18.0#10
trisdoan wants to merge 12 commits into18.0from
18.0-mig-sell_only_by_packaging

Conversation

@trisdoan
Copy link
Copy Markdown
Owner

@trisdoan trisdoan commented Nov 30, 2024

@trisdoan trisdoan force-pushed the 18.0-mig-sell_only_by_packaging branch 4 times, most recently from b651d4a to aa3479a Compare December 4, 2024 04:09
duongtq and others added 10 commits December 5, 2024 09:56
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Translation: sale-workflow-16.0/sale-workflow-16.0-sell_only_by_packaging
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sell_only_by_packaging/es/
This test was relying on the fact that it was being tested along with `sale_packaging_default`. But there's no direct dependency between these modules.

Besides, that assertion was never executed, so I removed it.

@moduon MT-3930
Currently translated at 100.0% (15 of 15 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sell_only_by_packaging
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sell_only_by_packaging/it/
templates._check_sell_only_by_packaging_can_be_sold_packaging_ids()
except exceptions.ValidationError as e:
raise exceptions.ValidationError(
_(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
_(
self.env._(

You can replace the call to translate a string (_) with self.env._ for getting some performance improvement in some cases. See odoo/odoo#174844.

'Packaging level "{}" must stay with "Can be sold",'
' at least one product configured as "sell only'
' by packaging" is using it.'
).format(record.display_name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please also get rid of the .format, see https://github.com/OCA/odoo-module-migrator/pull/114
(here and in other locations; also impact translations)

def _compute_template_min_sellable_qty(self):
for record in self:
record.min_sellable_qty = 0.0
if len(record.product_variant_ids) == 1:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if len(record.product_variant_ids) == 1:
if record.product_variant_count == 1:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

What would we gain from triggering a compute method?

for product in self:
if product.sell_only_by_packaging and not product.sale_ok:
raise ValidationError(
_(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
_(
self.env._(

same with all _( above code

Comment on lines +57 to +60
len(product.product_variant_ids) == 1
and not any(pack.sales for pack in product.packaging_ids)
# Product variants condition
or len(product.product_variant_ids) > 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
len(product.product_variant_ids) == 1
and not any(pack.sales for pack in product.packaging_ids)
# Product variants condition
or len(product.product_variant_ids) > 1
product.product_variant_count == 1
and not any(pack.sales for pack in product.packaging_ids)
# Product variants condition
or product.product_variant_count > 1

Copy link
Copy Markdown

@xaviedoanhduy xaviedoanhduy Dec 6, 2024

Choose a reason for hiding this comment

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

The code here seems to be mostly duplicated with the product_packaging_level_salable module, right?
https://github.com/trisdoan/product-attribute/blob/18.0-mig-product_packaging_level_salable/product_packaging_level_salable/tests/common.py

@trisdoan trisdoan force-pushed the 18.0-mig-sell_only_by_packaging branch 2 times, most recently from 8c8e6b3 to b52008d Compare December 9, 2024 07:31
@trisdoan trisdoan marked this pull request as draft December 9, 2024 07:34
@trisdoan trisdoan force-pushed the 18.0-mig-sell_only_by_packaging branch from b52008d to 3ccc34a Compare December 9, 2024 07:37
@trisdoan trisdoan marked this pull request as ready for review December 9, 2024 07:39
@trisdoan trisdoan closed this Dec 10, 2024
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.

7 participants