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 73 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:

To avoid Odoo external URL calls restriction, decorate your test class with @common.tagged("-standard") (removing the standard tag which is by default). This way, Odoo doesn't patch the request.Session.send method to throw an exception in an external URL call case.

@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 20 commits February 26, 2025 15:02
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/
@StephaneMangin StephaneMangin force-pushed the 18.0-mig-delivery_postlogistics branch from 0b24d58 to ad7ffa5 Compare February 26, 2025 14:03
@StephaneMangin StephaneMangin force-pushed the 18.0-mig-delivery_postlogistics branch from ad7ffa5 to 9920b76 Compare February 27, 2025 13:56
@StephaneMangin
Copy link
Author

@bizzappdev Hi, you can find the solution to external URL call avoid by Odoo on the description.



# This tag removal will allow to call external API URL
@common.tagged("-standard")

Choose a reason for hiding this comment

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

This tag allows all traffic to the external URL.

From my understanding, VCR will only listen when use_cassette is in context. Additionally, Odoo has explicitly blocked external URLs, likely for a valid reason. Ideally, the URL used in the cassette and the shipping method for test cases should be set to localhost.

Using localhost should not cause any issues, while bypassing Odoo's URL check could introduce a potential risk. Could you confirm if there is a specific reason for allowing an external URL in this case?
@StephaneMangin

Copy link
Author

@StephaneMangin StephaneMangin Feb 27, 2025

Choose a reason for hiding this comment

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

Yes, when we want to refresh the testcase when the API changes. We want to keep the original URLs and configuration.

Here the call is not done externally, Odoo check the validity of the URL before VCR applies... Which is difficult to get around easily. For now i don't see any risks with this configuration. Later on we could find a way to manage differently this approach or if someone finds it, we would update this module accordingly.

Choose a reason for hiding this comment

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

Thanks for the clarification, I agree that these particular test cases and modules do not pose a risk. However, since this is a generic module, what if someone inherits a test case class or a module method that interacts with the external URL? Wouldn't that introduce a potential risk?

Additionally, since Odoo validates the URL before VCR applies, bypassing this check could lead to unforeseen issues in the future. While there may not be immediate concerns, would it be worth exploring an approach in the future where we mock the API response while still keeping the external URL intact in the cassettes? This might help maintain Odoo’s validation integrity while ensuring test cases remain up to date.

Alternatively, you could consider having separate test cases specifically for API changes and tagging them with a -standard tag, which would serve your purpose while also ensuring test cases remain risk-free and enhance the module’s extensibility.

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.