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

[17.0][WIP] delivery_auto_refresh: Migration to 17.0 #1002

Open
wants to merge 53 commits into
base: 17.0
Choose a base branch
from

Conversation

victoralmau
Copy link
Member

@victoralmau victoralmau commented Mar 21, 2025

Migration to 17.0

Locked by:

Please @chienandalu can you review it?

@Tecnativa TT52316

pedrobaeza and others added 30 commits March 21, 2025 09:49
Auto-refresh delivery price in sales orders
===========================================

This module automates the delivery price handling for the following cases:

* If you change any line in your draft sales order (SO), when saving, the
  delivery price will be adjusted without having to click on "→ Set price".
* If specified in the system parameter, the delivery line can be also
  auto-added when creating/saving.
* If you deliver a different quantity than the ordered one, the delivery price
  is adjusted on the linked SO when the picking is transferred.

Configuration
=============

* Activate developer mode.
* Go to *Settings > Technical > Parameters > System Parameters*.
* Locate the setting with key "delivery_auto_refresh.auto_add_delivery_line"
  or create a new one if not exists.
* Put a non Falsy value (1, True...) if you want to add automatically the
  delivery line on save.

Known issues / Roadmap
======================

* After confirming the sales order, the price of the delivery line (if exists)
  will be only updated after the picking is transferred, but not when you
  might modify the order lines.
* There can be some duplicate delivery unset/set for assuring that the refresh
  is done on all cases.
* On multiple deliveries, second and successive pickings update the delivery
  price, but you can't invoice the new delivery price.
* This is only working from user interface, as there's no way of making
  compatible the auto-refresh intercepting create/write methods from sale order
  lines.

OCA Transbot updated translations from Transifex
Currently translated at 100.0% (2 of 2 strings)

Translation: delivery-carrier-12.0/delivery-carrier-12.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-12-0/delivery-carrier-12-0-delivery_auto_refresh/zh_CN/

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (2 of 2 strings)

Translation: delivery-carrier-12.0/delivery-carrier-12.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-12-0/delivery-carrier-12-0-delivery_auto_refresh/zh_CN/
Currently translated at 100.0% (2 of 2 strings)

Translation: delivery-carrier-12.0/delivery-carrier-12.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-12-0/delivery-carrier-12-0-delivery_auto_refresh/pt_BR/
…+ add on create

As the used method now has a check for not being used when the order is confirmed, so
it collapses when you want to add the delivery line in that moment.

Previous code didn't take into account the direct creation of the sales order.
For not having bad interaction with the rest of the tests.
new() doesn't invoke defaults, so you can get an SO without company for example,
and interacts bad with other modules.
Currently translated at 100.0% (2 of 2 strings)

Translation: delivery-carrier-12.0/delivery-carrier-12.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-12-0/delivery-carrier-12-0-delivery_auto_refresh/sl/
In the core the onchange is now aligned with `partner_shipping_id`
instead of `partner_id`.
odoo/odoo@b6f91e3
Update translation files

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

Translation: delivery-carrier-13.0/delivery-carrier-13.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-13-0/delivery-carrier-13-0-delivery_auto_refresh/
… after refresh to prevent warning decoration

delivery_auto_refresh 13.0.1.0.1
When the company has different currency than the pricelist asociated to the partner. The final price is converted to the currency of the pricelist.

With this changes we achieve to avoid this recomputation and solve this problems on tests.

TT26914

delivery_auto_refresh 13.0.1.0.2
…n website

The steps to reproduce the problem are these:
    - Set delivery_auto_refresh.auto_add_delivery_line.
    - Set a default delivery method on the user's partner.
    - Place a new ecommerce order with that user adding to the cart.

Doing this steps we get the error:
    Record does not exist or has been deleted.
    (Record: sale.order.line(63,), User: 1)

delivery_auto_refresh 13.0.1.0.3
We should get as the same default carrier as Odoo does.

TT34020

delivery_auto_refresh 13.0.1.0.4
Added new config paramerter that automates de voiding of the delivery
line for the case of returning a picking that just didn't go away from
the warehouse (due to several causes like the customer cancelling the
sale order in the last minute).

This will only be performed if the order wasn't already invoiced and the
return was set to refund.

TT30359

delivery_auto_refresh 13.0.1.0.5

Update translation files

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

Translation: delivery-carrier-13.0/delivery-carrier-13.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-13-0/delivery-carrier-13-0-delivery_auto_refresh/
If there were more than one delivery line, we'd get a singleton error
when trying to refresh due to the need of taking the discount of the
former lines.

TT35025
When choosing the sale carrier from the header of the order form we
should filter those carriers not available for the given shipping
address the in the same way the wizard does it.

TT35200
Added parameter set_default_carrier to avoid conflicts with other modules.

delivery_auto_refresh 14.0.1.1.0
Currently translated at 100.0% (5 of 5 strings)

Translation: delivery-carrier-14.0/delivery-carrier-14.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-14-0/delivery-carrier-14-0-delivery_auto_refresh/it/
TT36943

[UPD] Update delivery_auto_refresh.pot

[UPD] README.rst

Update translation files

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

Translation: delivery-carrier-15.0/delivery-carrier-15.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-15-0/delivery-carrier-15-0-delivery_auto_refresh/
Steps to reproduce:

- Create a delivery method (delivery.carrier) with a fixed rate.
- Enable the system parameter "delivery_auto_refresh.refresh_after_picking".
- Create a sales order with such delivery method and storable products.
- Confirm the sales order.
- Validate the picking.

Result: It can't be validated with the message "There is no matching
delivery rule.".

Explanation: Previous code computes the shipping values and call
directly to `_get_price_from_picking`, which uses rules and doesn't
take into account the rest of possibilities (integration or fixed
price).

We keep such computation for carriers based on rules, as they are not
properly updated, but added the possibility of writing back the price
for other carriers with fixed price or integrations, using the
`carrier_price` field that contains it.

TT43533

delivery_auto_refresh 15.0.1.0.1
[UPD] Update delivery_auto_refresh.pot

[UPD] README.rst
Currently translated at 100.0% (13 of 13 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/es/

[UPD] README.rst
solo4games and others added 23 commits March 21, 2025 09:50
Now when creating a new SO consisting of product services,
the delivery line is not added

oca-github-bot post-merge updates
Don't modify standard method docstring
Limit change of write to calling the auto refresh feature
Prevent to call auto refresh multiple times

Don't pass discount variable in context
Create or delete line only if necessary
Update existing line if necessary
This commit can be reverted in the migration to 17.0
Move config to company level
Prefix config settings by sale
Currently translated at 100.0% (13 of 13 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/it/
Currently translated at 100.0% (13 of 13 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/pt_BR/

[UPD] Update delivery_auto_refresh.pot

[BOT] post-merge updates

Update translation files

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

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/
Currently translated at 100.0% (14 of 14 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/pt_BR/
Currently translated at 100.0% (14 of 14 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/it/
Currently translated at 85.7% (12 of 14 strings)

Translation: delivery-carrier-16.0/delivery-carrier-16.0-delivery_auto_refresh
Translate-URL: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_auto_refresh/fr/
Some other modules could trigger the autorefresh even when the order
record isn't in the db, and making the line creation fail. We only need
it when the record is saved.

TT55206

[BOT] post-merge updates
Since odoo/odoo@d0342c8, the default existing company is not getting a
CoA automatically, provoking than the current tests fail with the error:

odoo.exceptions.UserError: No journal could be found in company My Company (San Francisco) for any of those types: sale

Thus, we put tests post-install for being sure localization modules are
installed, the same as AccountTestInvoicingCommon does, but we don't
inherit from it, as it creates an overhead creating 2 new companies and
loading their CoA and some more stuff, while we don't need all of that.

Besides, if you don't have `l10n_generic_coa` installed, you can't use
another CoA (like `l10n_es`) easily, so we put little code to select the
first available CoA.

[BOT] post-merge updates
@victoralmau victoralmau force-pushed the 17.0-mig-delivery_auto_refresh branch from 37e17f7 to 964da58 Compare March 21, 2025 15:46
@victoralmau victoralmau marked this pull request as ready for review March 21, 2025 16:04
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.