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][ADD] product_variant_specific_description #306

Merged

Conversation

LoisRForgeFlow
Copy link

This module allows having different product variant internal notes than
the one of their template.

@ForgeFlow

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch 2 times, most recently from 4947830 to 79c3afd Compare September 28, 2023 13:31
@pedrobaeza
Copy link
Member

Shouldn't product_description_by_variant or product_variant_specific_description (following other existing module) would be more descriptive?

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from 79c3afd to a047f41 Compare September 28, 2023 13:33
@LoisRForgeFlow
Copy link
Author

@pedrobaeza existing modules? I saw a couple of ones doing this and the name were sale_order_line_variant_description and product_variant_name.

@pedrobaeza
Copy link
Member

I mean https://github.com/OCA/product-variant/tree/11.0/product_variant_specific_tax, that is being migrated to 16 in #302

@LoisRForgeFlow
Copy link
Author

@pedrobaeza hmmm I guess there is not a clear pattern used till now, I can rename this one. Which one do you prefer? product_<field_name>_by_variant or product_variant_specific_<field_name>?

@pedrobaeza
Copy link
Member

This is like asking which son is your favorite, hehe. No strong best option. You decide.

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from a047f41 to c9dec76 Compare September 28, 2023 13:52
@LoisRForgeFlow
Copy link
Author

Let's go for "specific" one, it has one ocurrence and this will be the second, better than start with zero 😆

@LoisRForgeFlow LoisRForgeFlow changed the title [16.0][ADD] product_variant_description [16.0][ADD] product_variant_specific_description Sep 28, 2023
@JordiMForgeFlow
Copy link

JordiMForgeFlow commented Sep 28, 2023

@LoisRForgeFlow maybe we could add the field in the product_variant_easy_edit_view view

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from c9dec76 to 4ba739a Compare September 28, 2023 14:26
@LoisRForgeFlow
Copy link
Author

@JordiMForgeFlow Thanks for the heads-up, it is done now!

Copy link

@JordiMForgeFlow JordiMForgeFlow left a comment

Choose a reason for hiding this comment

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

Code + functional review 👍🏼

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from 4ba739a to ff50236 Compare September 29, 2023 08:13
@LoisRForgeFlow
Copy link
Author

Some improvements done in order to have a better UX:

  • Template and variant descriptions are aligned while there is only one variant.
  • Template description is hidden in the view as soon as there is more than 1 variant.
  • Once any of the variants changes, the template description is cleared.
  • A new test case is added to ensure this behavior.

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from ff50236 to 9383ec3 Compare September 29, 2023 08:17
@JordiMForgeFlow
Copy link

LGTM @LoisRForgeFlow , should we also consider this new approach in the init_hook, removing the description from the template when there are multiple variants?

@LoisRForgeFlow
Copy link
Author

LGTM @LoisRForgeFlow , should we also consider this new approach in the init_hook, removing the description from the template when there are multiple variants?

The template description is only cleared when you modify the description of any of its variants, while all the variants have the same description, the template will do too. So I think the init hook is aligned with this behavior, you start with all variants with the same description as their template.

@LoisRForgeFlow
Copy link
Author

@pedrobaeza Do you have some advice/hint on how to better handle a translatable+computed+stored field? Translations are not being aligned in this case.

@LoisRForgeFlow LoisRForgeFlow force-pushed the 16.0-add-product_variant_description branch from 9383ec3 to 17c4835 Compare September 29, 2023 09:42
@LoisRForgeFlow
Copy link
Author

After some back and forth, there is no easy way to make it work correctly with translations, therefore a more pracmatic solutions has been followed:

image

This information message redirecting to the variant and the description as readonly will only be shown as soon as there is more than one language active.

Copy link

@JordiMForgeFlow JordiMForgeFlow left a comment

Choose a reason for hiding this comment

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

Tested again 👍🏼

@pedrobaeza
Copy link
Member

Now that translations are handled with JSON fields, isn't there a way to "dump" the full content of the field? If not, this one is as you say a pragmatic one.

Copy link
Member

@JordiBForgeFlow JordiBForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional tests. Works as expected.

@JordiBForgeFlow
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-306-by-JordiBForgeFlow-bump-nobump, awaiting test results.

@LoisRForgeFlow
Copy link
Author

Now that translations are handled with JSON fields, isn't there a way to "dump" the full content of the field? If not, this one is as you say a pragmatic one.

No, that would be ideal, but I guess is not supported yet. There are some helper methods to update translations (e.g. update_field_translations) but you need to call them explicitly and it gets a bit over-complicated to do it here. Let's hope they improve this in the ORM in the future.

@OCA-git-bot OCA-git-bot merged commit 40652a7 into OCA:16.0 Oct 2, 2023
5 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

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

@LoisRForgeFlow LoisRForgeFlow deleted the 16.0-add-product_variant_description branch October 2, 2023 07:42
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