Skip to content

[19.0][MIG] product_sequence: Migration to 19.0 - #2369

Open
bosd wants to merge 52 commits into
OCA:19.0from
bosd:19.0-mig-product_sequence
Open

[19.0][MIG] product_sequence: Migration to 19.0#2369
bosd wants to merge 52 commits into
OCA:19.0from
bosd:19.0-mig-product_sequence

Conversation

@bosd

@bosd bosd commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Supersedes #2127.

Migration of product_sequence to 19.0, redone from scratch with the standard
OCA migration procedure. The 19.0 migration commit of @fd-oerp is cherry-picked
(with -x) so their authorship and work are preserved, and they have been added
to readme/CONTRIBUTORS.md.

Why redo it

  • [19.0][MIG] product_sequence: Migration to 19.0 #2127 squashed the administrative commits into the functional commits, so
    several [MIG]/[IMP] commits ended up carrying the bodies of unrelated
    .pot/README/Weblate commits, blurring the attribution of the real changes.
  • It was branched off an older 18.0, so it did not carry
    [IMP] product_sequence: default_code shouldn't be mandatory nor the Turkish,
    Croatian, Catalan and Slovenian translations that landed on 18.0 since.

Migration changes

  • test_product_category_sequence: since 19.0, categ_id is no longer required
    on product.template, so assertTrue(product_4.categ_id) no longer holds.
    Rather than dropping the case (as [19.0][MIG] product_sequence: Migration to 19.0 #2127 did), it now asserts what the module
    actually guarantees: a product without category falls back on the default
    product sequence.

On top of the plain migration

  • New OCA icon ([IMP] product_sequence: use the new OCA icon), the one
    already used by other addons of this repository.

  • Demo data ([ADD] product_sequence: demo data), illustrating the three
    ways a reference is assigned:

    Product Category Reference
    Floor Lamp Lamps (prefix LAMP) LAMP00001
    Desk Lamp Desk Lamps (no prefix, child of Lamps) LAMP00002
    Office Chair Furniture (prefix FURN) FURN00001
    Extension Cord none PR/00001

    The parent-category fallback is enabled on the main company so the Desk Lamp
    case is actually demonstrated; test_product_parent_category_sequence
    therefore now disables that setting explicitly instead of relying on the
    ambient company configuration.

    Three tests assert the demo references. They skip when the database has no
    demo data, which is the case on the CI since Odoo 19.0 does not load demo data
    by default.

@fd-oerp thanks for the original migration.
the history rework could not be done as a review suggestion. @NICO-SOLUTIONS the
copy() discussion from #2127 is deliberately left out of this PR to keep the
migration reviewable; happy to open a follow-up for it.

Jordi Esteve and others added 30 commits August 6, 2026 14:54
… reference. The reference (default code) is unique (SQL constraint) and required.
some minor reformatting in the process
Version numbers should only have 2 digits.
Squashed administrative commits:
* Added german translation
* Add bug tracker link on README.rst

Co-authored-by: Malte Jacobi <malte.jacobi@htwsaar.de>
Co-authored-by: Yannick Vaucher <yannick.vaucher@camptocamp.com>
Add pre_init_hook to manually set nulls and '/' default codes
 to a unique code to greenify branch
add pragma to pre_init method as it must have completed successfully
if module installs
* Migration to v11
* Support sequence by Product Category
Squashed administrative commits:
* remove obsolete .pot files [ci skip]
* [UPD] Update product_sequence.pot

Co-authored-by: Stéphane Bidoul (ACSONE) <stephane.bidoul@acsone.eu>
Co-authored-by: oca-travis <oca+oca-travis@odoo-community.org>
Squashed administrative commits:
* [UPD] Update product_sequence.pot
* Update translation files

Co-authored-by: oca-travis <oca+oca-travis@odoo-community.org>
Co-authored-by: OCA Transbot <transbot@odoo-community.org>
… dictionary values contains the default_code key.
Squashed administrative commits:
* [UPD] Update product_sequence.pot
* Update translation files
* Translated using Weblate (German)
* pre-commit update
* Translated using Weblate (French)

Co-authored-by: oca-travis <oca+oca-travis@odoo-community.org>
Co-authored-by: OCA Transbot <transbot@odoo-community.org>
Co-authored-by: Ben Brich <b.brich@humanilog.org>
Co-authored-by: OCA-git-bot <oca-git-bot@odoo-community.org>
Co-authored-by: c2cdidier <didier.donze@camptocamp.com>
watthanun and others added 20 commits August 6, 2026 14:54
[UPD] Update product_sequence.pot

[UPD] README.rst
…settings for the prefix.

[UPD] Update product_sequence.pot

[UPD] README.rst

product_sequence 14.0.2.0.1

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-14.0/product-attribute-14.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-14-0/product-attribute-14-0-product_sequence/

Translated using Weblate (Dutch)

Currently translated at 100.0% (18 of 18 strings)

Translation: product-attribute-14.0/product-attribute-14.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-14-0/product-attribute-14-0-product_sequence/nl/
[UPD] Update product_sequence.pot

[UPD] README.rst

product_sequence 16.0.1.0.1

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/

Translated using Weblate (German)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/de/
…nd product.category

product_sequence 16.0.1.0.2

[UPD] Update product_sequence.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/
[UPD] README.rst

product_sequence 16.0.2.0.0

Translated using Weblate (Italian)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/it/

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/pt_BR/

Translated using Weblate (Spanish)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/es/

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/
- Switch to setUpClass for avoiding repeat the same setup for each test.
- Include context keys for avoiding mail operations overhead.
Translated using Weblate (Italian)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/it/

Translated using Weblate (Italian)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/it/

Translated using Weblate (Italian)

Currently translated at 100.0% (16 of 16 strings)

Translation: product-attribute-16.0/product-attribute-16.0-product_sequence
Translate-URL: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_sequence/it/
Squashed administrative commits:
* [UPD] Update product_sequence.pot
* [BOT] post-merge updates

Co-authored-by: oca-ci <oca-ci@odoo-community.org>
Co-authored-by: OCA-git-bot <oca-git-bot@odoo-community.org>
Squashed administrative commits:
* [UPD] Update product_sequence.pot
* [BOT] post-merge updates
* Added translation using Weblate (Slovak)
* Translated using Weblate (Slovak)

Co-authored-by: oca-ci <oca-ci@odoo-community.org>
Co-authored-by: OCA-git-bot <oca-git-bot@odoo-community.org>
Co-authored-by: Jan Prokop <jprokop@jackie.sk>
Disable 2 test that were making branch to fail, not easy solution has been found, so diasable for now.
Squashed administrative commits:
* [BOT] post-merge updates
* Translated using Weblate (Turkish)
* Translated using Weblate (Croatian)
* Translated using Weblate (Catalan)
* Translated using Weblate (Turkish)

Co-authored-by: OCA-git-bot <oca-git-bot@odoo-community.org>
Co-authored-by: Betül Öğmen <betulo@eska.biz>
Co-authored-by: Ana Matulin <ana@uvid.hr>
Co-authored-by: Ricard <ricard.calvo@forgeflow.com>
Since there is already a module that makes the field mandatory, such as product_code_mandatory, adding this requirement at the database level, in my opinion, goes beyond the scope of this module.
Squashed administrative commits:
* Translated using Weblate (Slovenian)
* [BOT] post-merge updates

Co-authored-by: Matjaz Mozetic <matjaz@luxim.si>
Co-authored-by: OCA-git-bot <oca-git-bot@odoo-community.org>
- Bump manifest version to 19.0.1.0.0.
- Adapt test_product_category_sequence: since 19.0 product.category is no
  longer a required field on product.template, so a product without a
  category now falls back on the default sequence instead of always having
  a category set.

(cherry picked from commit cb70b43)

Co-authored-by: bosd <ebo@stefcy.com>
Replace the legacy OCA icon by the current one, as already used by other
addons in this repository.
bosd added 2 commits August 6, 2026 22:28
Add demo data illustrating the three ways an internal reference is
assigned by this module:

* Floor Lamp (category "Lamps", prefix LAMP) -> LAMP00001
* Desk Lamp (category "Desk Lamps", no prefix, parent "Lamps") -> LAMP00002
* Office Chair (category "Furniture", prefix FURN) -> FURN00001
* Extension Cord (no category) -> PR/00001, the default product sequence

The parent category fallback is enabled on the main company so that the
"Desk Lamps" case is actually demonstrated. Because of that,
test_product_parent_category_sequence now disables the setting explicitly
instead of relying on the ambient company configuration.

Since 19.0 Odoo does not load demo data by default, so the new tests load
the demo files themselves when they are missing. That way the demo data is
checked on the CI too, instead of silently skipping.
Since Odoo 14 (odoo/odoo#38303) copying a product.product does not copy the
variant: the template is copied instead and its first variant is returned.
That variant is built by _create_variant_ids without any reference, so it
gets a brand new sequence number and the default_code put in `default` by
copy() was silently dropped:

* copying PROD02 gave PR/00007 instead of PROD02-copy;
* product.copy({"default_code": "REF"}) ignored "REF" altogether.

This is why the two copy tests had to be disabled in
63a0f5b "[FIX] product_sequence: disable test". Restore the reference on
the new variant after the copy and re-enable both tests.

Also add tests for a copy without source reference and for the multi variant
case, where the reference stays on the variant and is not pushed up to the
template.
@bosd
bosd force-pushed the 19.0-mig-product_sequence branch from 981de95 to bef3c3b Compare August 6, 2026 20:31
@bosd

bosd commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up to get Codecov green.

Two things came out of it:

1. The demo tests no longer skip. Since 19.0 Odoo does not load demo data by default, so the CI databases have none and the tests were skipped there. They now load the demo files themselves via convert_file(..., mode="init", noupdate=True) when the records are missing, so the demo data is actually validated on the CI. Verified both ways: with and without --with-demo.

2. copy() was broken and is fixed ([FIX] product_sequence: keep the reference of copied products). This is why the two copy tests had to be disabled in 63a0f5b "[FIX] product_sequence: disable test", and it is the thread @NICO-SOLUTIONS opened on #2127.

Since odoo/odoo#38303 (14.0), copying a product.product does not copy the variant: the template is copied and its first variant returned. That variant is built by _create_variant_ids with no reference, so it gets a fresh sequence number and the default_code the override put into default was silently discarded:

  • copying PROD02 produced PR/00007 instead of PROD02-copy;
  • product.copy({"default_code": "REF"}) ignored REF entirely.

The override now restores the requested reference on the new variant after the copy, and both tests are re-enabled. Added tests for the no-source-reference case (copy just gets a new sequence number, no -copy suffix) and for the multi-variant case (the reference stays on the variant and is not pushed up to the template).

@NICO-SOLUTIONS if you would rather have a copy always take a fresh sequence number instead of the -copy suffix, that is a one-line change from here let me know and i will change it.

@Reyes4711-S73 Reyes4711-S73 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

@NICO-SOLUTIONS

Copy link
Copy Markdown
Member

@NICO-SOLUTIONS if you would rather have a copy always take a fresh sequence number instead of the -copy suffix, that is a one-line change from here let me know and i will change it.

@bosd
Thanks for tackling this and for the explanation of the Odoo core change behind it.

From my point of view, a copied product should receive a fresh sequence number instead of keeping the -copy suffix. default_code should identify the new product and not describe how the record was created.

I can see the benefit of the -copy suffix for temporary drafts or work copies, as it makes the origin of a duplicate immediately visible. On the other hand, if a user wants a new sequence-generated reference, this can already be achieved by setting default_code to /, but this requires an additional manual step.

However, I would not expect the -copy suffix to remain as the final product reference used in sales, purchasing, inventory, or integrations.

This is just my perspective though; I won´t make this decision alone. I am happy to follow the consensus of the maintainers/contributors here. If there are other advantages of keeping the -copy behavior, I would be interested to understand them.

If this is handled in a separate follow-up PR, that is also fine for me. However, I think we should define a clear approach for this scenario.

I'll review the code once I find some time.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.