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

[MIG][IMP] delivery_multi_destination: Introduce 'based on destination' delivery type #887

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from

Conversation

carmenbianca
Copy link
Member

Backported from #871
Internal task T12787

website_sale_delivery checks whether delivery_type is set to 'fixed' for some behaviours. And before this commit, multi-destination carriers effectively always had the delivery_type set to 'fixed'. However, because children of the multi-destination carrier can be something other than 'fixed', this causes some strange behaviours.

(Example, on the delivery selection page, you expect 'Select to compute delivery rate' to show up for non-'fixed' carriers, but this doesn't happen.)

We can't make website_sale_delivery aware of destination_type, but we can introduce a non-'fixed' delivery type. So that's what we do here.

The choice was made to turn the destination type into a computed value dependent on the delivery type because there is strong coupling between the two values, and trying to keep the two values in sync using onchange/constrains/etc resulted in terrible spaghetti code.

…livery type

website_sale_delivery checks whether delivery_type is set to 'fixed' for
some behaviours. And before this commit, multi-destination carriers
effectively always had the delivery_type set to 'fixed'. However,
because children of the multi-destination carrier can be something other
than 'fixed', this causes some strange behaviours.

(Example, on the delivery selection page, you expect 'Select to compute
delivery rate' to show up for non-'fixed' carriers, but this doesn't
happen.)

We can't make website_sale_delivery aware of destination_type, but we
_can_ introduce a non-'fixed' delivery type. So that's what we do here.

The choice was made to turn the destination type into a computed value
dependent on the delivery type because there is strong coupling between
the two values, and trying to keep the two values in sync using
onchange/constrains/etc resulted in terrible spaghetti code.

Co-Authored-By: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
@pedrobaeza pedrobaeza added this to the 16.0 milestone Sep 23, 2024
@polchampion
Copy link

polchampion commented Oct 29, 2024

@carmenbianca tested functionally on the runboat

  • I created some multiple destination delivery methods with non fixed children
  • On the delivery selection page, the available carrier rate is computed right away
  • The other carrier rates are displayed loading instead of being hidden
  • I get the error below on the delivery selection page:

screenshot-oca-delivery-carrier-16-0-pr887-88a7398d1f76 runboat odoo-community org-2024 10 29-16_28_06


Uncaught Javascript Error > browser.navigator.clipboard is undefined

TypeError: browser.navigator.clipboard is undefined
    onClickClipboard@http://oca-delivery-carrier-16-0-pr887-88a7398d1f76.runboat.odoo-community.org/web/assets/641-afd6f82/1/web.assets_frontend_lazy.min.js:6760:20
    mainEventHandler@http://oca-delivery-carrier-16-0-pr887-88a7398d1f76.runboat.odoo-community.org/web/assets/641-afd6f82/1/web.assets_frontend_lazy.min.js:2063:77
    listener@http://oca-delivery-carrier-16-0-pr887-88a7398d1f76.runboat.odoo-community.org/web/assets/641-afd6f82/1/web.assets_frontend_lazy.min.js:1233:15```
    
 

@huguesdk huguesdk force-pushed the 16.0-mig-delivery_multi_destination-based-on-destination branch from 88a7398 to 0c29bca Compare February 6, 2025 20:43
@huguesdk
Copy link
Member

huguesdk commented Feb 6, 2025

@polchampion could you try again? it seems that the error you reported is unrelated to the changes. how to reproduce it?

@polchampion
Copy link

polchampion commented Feb 25, 2025

@huguesdk Can't reproduce the above error, but I tested anew and couldn't make it work.
Tested on this test db.

  • I created a multi-destination delivery method called "xtra multi", with two non-fixed children. The price calculation is based on rules and depends on the product weight.
  • Odoo can neither calculate the price in the backend nor on the website:

screenshot-odoo16 main test srv coopiteasy be-2025 02 25-10_50_40

screenshot-odoo16 main test srv coopiteasy be-2025 02 25-10_50_47

screenshot-odoo16 main test srv coopiteasy be-2025 02 25-10_51_44

I'm perhaps wrong on the multi-destination usage, but I'm otherwise not sure how to best test the wanted behaviour. I believe the test should work in any case.

* take the provided domain into account in .name_search() (and add a
  condition to it) instead of replacing it completely.
* rename the args argument of .search() to domain, as in the parent
  method.
* define .base_on_destination_rate_shipment() and
  .base_on_destination_send_shipping() instead of overriding
  .rate_shipment() and .send_shipping() and filtering on
  destination_type.
* always return a value in .base_on_destination_rate_shipment() to fail
  nicely if no sub-carrier matches.
@huguesdk huguesdk force-pushed the 16.0-mig-delivery_multi_destination-based-on-destination branch from deec538 to dbab84b Compare February 28, 2025 08:48
@huguesdk
Copy link
Member

delivery_multi_destination is only about defining different carriers depending on the shipping destination. i think that the rules only allow to compute a different price for the same carrier.

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.

5 participants