Skip to content

[19.0][MIG] website_sale_secondary_unit: Migration to 19.0 - #1298

Open
CarlosRoca13 wants to merge 44 commits into
OCA:19.0from
Tecnativa:19.0-MIG-website_sale_secondary_unit
Open

[19.0][MIG] website_sale_secondary_unit: Migration to 19.0#1298
CarlosRoca13 wants to merge 44 commits into
OCA:19.0from
Tecnativa:19.0-MIG-website_sale_secondary_unit

Conversation

@CarlosRoca13

@CarlosRoca13 CarlosRoca13 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

@OCA-git-bot OCA-git-bot added series:19.0 mod:website_sale_secondary_unit Module website_sale_secondary_unit labels Aug 20, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration website_sale_secondary_unit

For being testable, I think you should include the temporary reference.

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Aug 20, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Aug 20, 2026
35 tasks

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. I left a comment and hope it can be implemented.

Before V19, the Add to Cart button in the shop was not enabled by default and could be enabled through the Customize options.

Image

But in V19, I noticed that it is enabled by default, and there is no option to hide it.

Image

With this option enabled, when a product has variants, a modal is displayed to select the variant. In this context, no secondary units are displayed. It would be great if we could select the secondary units here as well.

Imagine that in my product, I set Allow to Sell in Unit of Measure to False and use only secondary units. In this case, the first secondary unit is currently selected, but it does not check whether it is published or not. If the first secondary unit is unpublished, I think this is incorrect behavior.

For me, the expected behavior would be to select the first published secondary unit.

Image Image Image

product = self.env["product.product"].browse(product_id)
if not product.allow_uom_sell:
secondary_uom = (
product.sale_secondary_uom_id or product.secondary_uom_ids[:1]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’m not sure if this should be done in this part of the code or somewhere else, but I think you should filter to only include published records. I noticed that you have the _get_website_secondary_uoms function, which performs this filtering. Could this function be used in all places?

Suggested change
product.sale_secondary_uom_id or product.secondary_uom_ids[:1]
product.sale_secondary_uom_id or product._get_website_secondary_uoms()[:1]

@@ -0,0 +1,3 @@
To define the secondary units, you should activate *Units of Measure* in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
To define the secondary units, you should activate *Units of Measure* in
To define the secondary units, you should activate *Units of Measure & Packagings* in

<field name="domain_force">[('website_published', '=', True)]</field>
<field
name="groups"
eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"
eval="[Command.link(ref('base.group_public')), Command.link(ref('base.group_portal'))]"

admin = cls.env.ref("base.user_admin")
admin.group_ids |= cls.env.ref("uom.group_uom")
# Force VAT to avoid error in the module that makes it required.
admin.partner_id.vat = "TEST12345678"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be better to set a valid VAT number to prevent errors similar to #1285

@pilarvargas-tecnativa

Copy link
Copy Markdown
Contributor

Perhaps the simplest solution to what @carlos-lopez-tecnativa mentions, to address something that no one has requested over the course of several versions, is to bring back the option to hide the shopping cart button.

@CarlosRoca13

Copy link
Copy Markdown
Contributor Author

Perhaps the simplest solution to what @carlos-lopez-tecnativa mentions, to address something that no one has requested over the course of several versions, is to bring back the option to hide the shopping cart button.

But I think it should be an extra module

@pedrobaeza

Copy link
Copy Markdown
Member

Isn't possible to add the secondary units to that screen that is also included in the main website_sale module? Or is it too complicated?

@CarlosRoca13

Copy link
Copy Markdown
Contributor Author

I'm working on adding it

@pedrobaeza

Copy link
Copy Markdown
Member

Please add in the main PR comment on which PR it depends as reference.

@CarlosRoca13
CarlosRoca13 force-pushed the 19.0-MIG-website_sale_secondary_unit branch from fa75be5 to a170f80 Compare August 26, 2026 10:56

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

Just a side note, to avoid going out of scope for the migration, but I think this issue could also be handled in this module because the feature is added by website_sale.

When I finish a sale order with a line that has a secondary unit, then go to My Account and reorder the same order, the quantities are changed. I suspect that, in this flow, the backend uses the default secondary unit or the first secondary unit. However, I would expect it to use the same secondary unit as the original order.

Could you add this to the ROADMAP? Or do you think this behavior could be fixed in this PR?

Image Image

In the backend:
Original order
Image

New order
Image

sergio-teruel and others added 17 commits August 27, 2026 06:04
As the product.secondary.unit view has been isolated, we have to
inherit from that one.
Before this changes, the change in the value of the secondary unit input field
didn't launch the execution of the onchanges of the real input field.

Adding this changes, we achieve to capture the event of the new input field
to launch the onchanges of the real input field.

cc @Tecnativa TT29708
For mobile users adding an extra column in the cart summary makes that
the others content won't fit very well, specially for products with long
names. As we can infer the sale line information without the secondary
units computation computation column we choose to hide it if the screen
is too small as Odoo does with the product image column.

TT37137
Ivorra78 and others added 25 commits August 27, 2026 06:04
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-15.0/e-commerce-15.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_secondary_unit/es/
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-15.0/e-commerce-15.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_secondary_unit/it/
…antity description and delete column in purchase summary

There were two quantity columns in the purchase summary, one with the
secondary unit quantity and one with the product quantity. A quantity
column in the purchase summary has been removed to give more clarity
to the view. When product names or units of measure have a considerable
number of characters, having two columns causes a crowding of the view
and therefore a feeling of content clutter. Instead, their content has
been moved so that both the secondary unit quantity and the quantity
of product purchased appear in the same column.

We have also added the option to hide the name of the secondary unit of
measure in the secondary unit description template in case it matches
the unit of measure of the product as depending on where it is being
called from it can be redundant.

TT45032
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-15.0/e-commerce-15.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_secondary_unit/it/
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-15.0/e-commerce-15.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_secondary_unit/es/
- Switch to setUpClass for avoiding repeat the same setup for each test.
- Include context keys for avoiding mail operations overhead.
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-15.0/e-commerce-15.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_secondary_unit/it/
- Replaced the popover implementation with notifications, following the update in odoo/odoo#133990.
- Removed the Unit from the displayed price. Previously, Odoo showed the price per unit, making it appropriate to include the UoM. However, as it now displays the total, the UoM is unnecessary.
Currently translated at 100.0% (14 of 14 strings)

Translation: e-commerce-17.0/e-commerce-17.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-17-0/e-commerce-17-0-website_sale_secondary_unit/it/
Currently translated at 35.7% (5 of 14 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/fr/
Currently translated at 85.7% (12 of 14 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/es/
Currently translated at 35.7% (5 of 14 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/ca/
Currently translated at 100.0% (14 of 14 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/it/
Currently translated at 35.7% (5 of 14 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/de/
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/it/
Currently translated at 100.0% (15 of 15 strings)

Translation: e-commerce-18.0/e-commerce-18.0-website_sale_secondary_unit
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_secondary_unit/es/
@CarlosRoca13
CarlosRoca13 force-pushed the 19.0-MIG-website_sale_secondary_unit branch from a170f80 to b3e0cc1 Compare August 27, 2026 04:04
@CarlosRoca13

Copy link
Copy Markdown
Contributor Author

@carlos-lopez-tecnativa solved

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for the improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:website_sale_secondary_unit Module website_sale_secondary_unit series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.