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

[18.0] [MIG] delivery_postlogistics: Migration to 18.0 #974

Open
wants to merge 76 commits into
base: 18.0
Choose a base branch
from

Conversation

StephaneMangin
Copy link

@StephaneMangin StephaneMangin commented Feb 10, 2025

Includes:

  • reusing of "delivery.carrier.template.option" from OCA module "delivery_carrier_option"
  • reusing of "shipping.label" from OCA module "delivery_carrier_shipping_label" instead of custom "postlogistics.shipping.label"
  • Add a default package type to fullfill postlogistics_send_shipping requirements (Using ECO default shipping pricing)

Depends on:

Due to some modules overrding the web service and as this implementation doesn't allow to properly chain modules (that could not be chained). An API refactoring has occur to allow to override from the picking instead of the webservice (some prepare methods)

@StephaneMangin
Copy link
Author

Superseeds #940

@yankinmax
Copy link
Contributor

hello @StephaneMangin
There is an issue in migration. You're overriding the selection of the type field declared for delivery.carrier.template.option model in delivery_carrier_option module.
Here is Odoo logs:

WARNING testdb odoo.fields: delivery.carrier.template.option.type: selection=[('label_layout', 'Label Layout'), ('output_format', 'Output Format'), ('resolution', 'Output Resolution'), ('basic', 'Basic Service'), ('additional', 'Additional Service'), ('delivery', 'Delivery Instructions'), ('partner_option', 'Partner Option')] overrides existing selection; use selection_add instead

@rousseldenis
Copy link
Contributor

/ocabot migration delivery_postlogistics

@StephaneMangin
Copy link
Author

hello @StephaneMangin There is an issue in migration. You're overriding the selection of the type field declared for delivery.carrier.template.option model in delivery_carrier_option module. Here is Odoo logs:

WARNING testdb odoo.fields: delivery.carrier.template.option.type: selection=[('label_layout', 'Label Layout'), ('output_format', 'Output Format'), ('resolution', 'Output Resolution'), ('basic', 'Basic Service'), ('additional', 'Additional Service'), ('delivery', 'Delivery Instructions'), ('partner_option', 'Partner Option')] overrides existing selection; use selection_add instead

Yes it is transitional, because these values are added in a dependency. Updating...

@StephaneMangin StephaneMangin force-pushed the 18.0-mig-delivery_postlogistics branch 4 times, most recently from 3fe8f87 to 78c780f Compare February 18, 2025 14:15
@StephaneMangin StephaneMangin force-pushed the 18.0-mig-delivery_postlogistics branch 2 times, most recently from 0f171db to 894894d Compare February 21, 2025 14:29
@StephaneMangin StephaneMangin force-pushed the 18.0-mig-delivery_postlogistics branch 3 times, most recently from e9dc13c to 0b24d58 Compare February 26, 2025 13:58
OCA-git-bot and others added 24 commits March 25, 2025 17:04
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_postlogistics
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_postlogistics/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_postlogistics
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_postlogistics/
Postlogistics limit for fields such as name, street and city,
is 35 chars for the recipient fields but is limited to 25 characters.
Sometimes due to API error it may happen we don't receive anything back when requesting token.
In this case we want to show meaningful message.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_postlogistics
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_postlogistics/
If a stock.picking is created and in the same transaction we generate
a label, when the webservice returns an error, the module rollbacks
the transaction, so 'self' is empty and will fail with:

Record does not exist or has been deleted. (Record:
stock.picking(8211067,), User: 6)

When trying to write the tracking number, and will therefore not
raise the details of the error.
The tests from d5c3f73 failed due to partner city being required
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_postlogistics
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_postlogistics/
…oid loss when several unchained modules implements new behaviors in it
@leemannd leemannd force-pushed the 18.0-mig-delivery_postlogistics branch 2 times, most recently from 57b587a to 1ca568d Compare March 25, 2025 16:15
models_spec = [
(
"postlogistics.delivery.carrier.template.option",
"delivery.carrier.template.option",

Choose a reason for hiding this comment

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

I suspect this will not work.

  1. The model is already created by the module delivery_carrier_option
2025-03-25 16:20:21,900 98 ERROR prod odoo.sql_db: bad query: b"UPDATE ir_model SET model = 'delivery.carrier.template.option' WHERE model = 'postlogistics.delivery.carrier.template.option'"
ERROR: duplicate key value violates unique constraint "ir_model_obj_name_uniq"
DETAIL:  Key (model)=(delivery.carrier.template.option) already exists.
 
2025-03-25 16:20:21,901 98 ERROR prod OpenUpgrade: Error after 0:00:00.001743 running UPDATE ir_model SET model = 'delivery.carrier.template.option' WHERE model = 'postlogistics.delivery.carrier.template.option' 
2025-03-25 16:20:21,977 98 WARNING prod odoo.modules.loading: Transient module states were reset 
2025-03-25 16:20:21,980 98 ERROR prod odoo.modules.registry: Failed to load registry 
2025-03-25 16:20:21,980 98 CRITICAL prod odoo.service.server: Failed to initialize database `prod`. 
Traceback (most recent call last):
  File "/odoo/src/odoo/service/server.py", line 1318, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/odoo/src/odoo/tools/func.py", line 97, in locked
    return func(inst, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/odoo/src/odoo/modules/registry.py", line 127, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/odoo/src/odoo/modules/loading.py", line 476, in load_modules
    processed_modules += load_marked_modules(env, graph,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/odoo/src/odoo/modules/loading.py", line 364, in load_marked_modules
    loaded, processed = load_module_graph(
                        ^^^^^^^^^^^^^^^^^^
  File "/odoo/src/odoo/modules/loading.py", line 181, in load_module_graph
    migrations.migrate_module(package, 'pre')
  File "/odoo/src/odoo/modules/migration.py", line 254, in migrate_module
    mod.migrate(self.cr, installed_version)
  File "/odoo/external-src/delivery-carrier/delivery_postlogistics/migrations/18.0.1.0.0/pre-migration.py", line 61, in migrate
    _rename_models(cr)
  File "/odoo/external-src/delivery-carrier/delivery_postlogistics/migrations/18.0.1.0.0/pre-migration.py", line 40, in _rename_models
    openupgrade.rename_models(cr, models_spec)
  File "/usr/local/lib/python3.12/site-packages/openupgradelib/openupgrade.py", line 922, in rename_models
    logged_query(
  File "/usr/local/lib/python3.12/site-packages/openupgradelib/openupgrade.py", line 1730, in logged_query
    cr.execute(query, args)
  File "/odoo/src/odoo/sql_db.py", line 354, in execute
    res = self._obj.execute(query, params)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "ir_model_obj_name_uniq"
DETAIL:  Key (model)=(delivery.carrier.template.option) already exists.

AFAIR best is:

@leemannd leemannd force-pushed the 18.0-mig-delivery_postlogistics branch from 1ca568d to 7762891 Compare March 25, 2025 21:38
@leemannd leemannd force-pushed the 18.0-mig-delivery_postlogistics branch from 7762891 to 19ad31d Compare March 27, 2025 09:33
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.