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] sale_order_carrier_auto_assign: Migration to 18.0 #3394

Open
wants to merge 40 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8686950
Create module sale_order_carrier_auto_assign
grindtildeath Aug 4, 2020
3069514
Use context key to avoid breaking other modules tests
grindtildeath Aug 5, 2020
a4f2f18
[UPD] Update sale_order_carrier_auto_assign.pot
oca-travis Aug 17, 2020
5d3f5d0
[UPD] README.rst
OCA-git-bot Aug 17, 2020
bce1380
[ADD] icon.png
OCA-git-bot Aug 17, 2020
9a09a53
Compute shipping rate on carrier auto-assign
guewen Aug 19, 2020
724f319
sale_order_carrier_auto_assign 13.0.1.1.0
OCA-git-bot Aug 19, 2020
436e7c3
Added translation using Weblate (Spanish)
danimv5 Oct 26, 2020
03d9690
Translated using Weblate (Spanish)
danimv5 Oct 26, 2020
fc9d830
[MIG] sale_order_carrier_auto_assign: Migration to 14.0
phuctranfxvn Jan 11, 2021
ab11784
[UPD] Update sale_order_carrier_auto_assign.pot
oca-travis Aug 9, 2021
6ebbb28
[UPD] README.rst
OCA-git-bot Aug 9, 2021
110621c
sale_order_carrier_auto_assign 14.0.1.0.1
OCA-git-bot Aug 9, 2021
76c9373
[UPD] README.rst
OCA-git-bot Jun 2, 2022
a1385ec
[UPD] README.rst
OCA-git-bot Jun 2, 2022
4e1c4a3
[MIG] sale_order_carrier_auto_assign: Migration to 15.0
vib-adhoc Aug 26, 2022
0a7955a
[UPD] Update sale_order_carrier_auto_assign.pot
Sep 29, 2022
9e07f3f
[UPD] README.rst
OCA-git-bot Sep 29, 2022
27addb3
sale_order_carrier_auto_assign 15.0.1.0.1
OCA-git-bot Sep 29, 2022
7ac24bd
[MIG] sale_order_carrier_auto_assign: Migration to 16.0
matiasperalta1 May 30, 2023
21eb927
[UPD] Update sale_order_carrier_auto_assign.pot
Jan 27, 2024
af338e9
[BOT] post-merge updates
OCA-git-bot Jan 27, 2024
0cf228e
Added translation using Weblate (Italian)
mymage Feb 1, 2024
c9139b4
Translated using Weblate (Italian)
mymage Feb 1, 2024
a8a174b
[IMP] sale_order_carrier_auto_assigni: add settings
santostelmo Dec 7, 2023
d000290
[IMP] sale_order_carrier_auto_assign multi-company
trisdoan Feb 23, 2024
9173cd9
[UPD] Update sale_order_carrier_auto_assign.pot
Mar 11, 2024
8f48b87
[BOT] post-merge updates
OCA-git-bot Mar 11, 2024
3120cea
Update translation files
weblate Mar 11, 2024
8c100ac
Translated using Weblate (Italian)
mymage Mar 18, 2024
6032287
[IMP] sale_order_carrier_auto_assign: pre-commit auto fixes
lef-adhoc Apr 26, 2024
2cdc20f
[MIG] sale_order_carrier_auto_assign: Migration to 17.0
lef-adhoc Apr 26, 2024
cd684d4
[UPD] Update sale_order_carrier_auto_assign.pot
Jun 24, 2024
04684c0
[BOT] post-merge updates
OCA-git-bot Jun 24, 2024
f1e9d20
Update translation files
weblate Jun 24, 2024
034f284
Update translation files
weblate Jun 24, 2024
86f0256
Translated using Weblate (Spanish)
jjscarafia Sep 19, 2024
216ba9b
[IMP] sale_order_carrier_auto_assign: pre-commit execution
lef-adhoc Nov 8, 2024
42e714d
[MIG] sale_order_carrier_auto_assign: Migration to 18.0
lef-adhoc Feb 3, 2025
e082bdd
[REF] sale: optimize `action_confirm` by filtering relevant records f…
lef-adhoc Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions sale_order_carrier_auto_assign/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
==============================
Sale Order Carrier Auto Assign
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2095b87a55c93f980c861af47ededa6b2886cf0ccdfb2cbfe9e3d9a8db2446cd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_order_carrier_auto_assign
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_order_carrier_auto_assign
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module assigns automatically delivery carrier on sale order
confirmation.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

To enable sale order carrier auto assign:

1. Go to *Settings > Sales > Carrier Auto Assign*.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_carrier_auto_assign%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- Akim Juillerat <[email protected]>
- Son (Ho Dac) <[email protected]>
- Phuc (Tran Thanh) <[email protected]>
- Telmo Santos <[email protected]>
- Tris Doan <[email protected]>

Other credits
-------------



Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_order_carrier_auto_assign>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_order_carrier_auto_assign/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions sale_order_carrier_auto_assign/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Sale Order Carrier Auto Assign",
"summary": "Auto assign delivery carrier on sale order confirmation",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Operations/Inventory/Delivery",
"website": "https://github.com/OCA/sale-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"data": ["views/res_config_settings_views.xml"],
"application": False,
"installable": True,
"depends": ["delivery"],
}
52 changes: 52 additions & 0 deletions sale_order_carrier_auto_assign/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_carrier_auto_assign
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-09-19 18:06+0000\n"
"Last-Translator: Juan José Scarafía <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.2\n"

#. module: sale_order_carrier_auto_assign
#: model_terms:ir.ui.view,arch_db:sale_order_carrier_auto_assign.res_config_settings_view_form_sale
msgid "Assigns automatically delivery carrier on sale order confirmation."
msgstr ""
"Asigna automáticamente el transportista de entrega en la confirmación del "
"pedido de venta."

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_company__carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Carrier Auto Assign"
msgstr "Asignación automática del transportista"

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_company
msgid "Companies"
msgstr "Empresas"

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_config_settings
msgid "Config Settings"
msgstr "Ajustes de configuración"

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,help:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Enable carrier auto assign on sale order confirmation."
msgstr ""
"Habilite la asignación automática del transportista en la confirmación del "
"pedido de venta."

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_sale_order
msgid "Sales Order"
msgstr "Pedido de venta"
54 changes: 54 additions & 0 deletions sale_order_carrier_auto_assign/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_carrier_auto_assign
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-18 09:38+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: sale_order_carrier_auto_assign
#: model_terms:ir.ui.view,arch_db:sale_order_carrier_auto_assign.res_config_settings_view_form_sale
msgid "Assigns automatically delivery carrier on sale order confirmation."
msgstr ""
"Assegna automaticamente il corriere della consegna alla conferma "
"dell'ordineidi vendita."

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_company__carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Carrier Auto Assign"
msgstr "Auto assegnazione corriere"

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_company
msgid "Companies"
msgstr "Aziende"

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_config_settings
msgid "Config Settings"
msgstr "Impostazioni configurazione"

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,help:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Enable carrier auto assign on sale order confirmation."
msgstr ""
"Anilita l'auto assegnazione corriere alla conferma dell'ordine di vendita."

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#~ msgid "Carrier auto assign"
#~ msgstr "Auto assegnazione corriere"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_carrier_auto_assign
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_carrier_auto_assign
#: model_terms:ir.ui.view,arch_db:sale_order_carrier_auto_assign.res_config_settings_view_form_sale
msgid "Assigns automatically delivery carrier on sale order confirmation."
msgstr ""

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_company__carrier_auto_assign
#: model:ir.model.fields,field_description:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Carrier Auto Assign"
msgstr ""

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_company
msgid "Companies"
msgstr ""

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: sale_order_carrier_auto_assign
#: model:ir.model.fields,help:sale_order_carrier_auto_assign.field_res_config_settings__carrier_auto_assign
msgid "Enable carrier auto assign on sale order confirmation."
msgstr ""

#. module: sale_order_carrier_auto_assign
#: model:ir.model,name:sale_order_carrier_auto_assign.model_sale_order
msgid "Sales Order"
msgstr ""
3 changes: 3 additions & 0 deletions sale_order_carrier_auto_assign/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import sale_order
from . import res_company
from . import res_config_settings
10 changes: 10 additions & 0 deletions sale_order_carrier_auto_assign/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

carrier_auto_assign = fields.Boolean()
14 changes: 14 additions & 0 deletions sale_order_carrier_auto_assign/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

carrier_auto_assign = fields.Boolean(
related="company_id.carrier_auto_assign",
readonly=False,
help="Enable carrier auto assign on sale order confirmation.",
)
30 changes: 30 additions & 0 deletions sale_order_carrier_auto_assign/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models


class SaleOrder(models.Model):
_inherit = "sale.order"

def action_confirm(self):
self.filtered(
lambda so: so.company_id.carrier_auto_assign
)._add_delivery_carrier_on_confirmation()
return super().action_confirm()

def _add_delivery_carrier_on_confirmation(self):
"""Automatically add delivery.carrier on sale order confirmation"""
for order in self:
Copy link

@xaviedoanhduy xaviedoanhduy Dec 2, 2024

Choose a reason for hiding this comment

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

I see action_confirm has iterated over the records in sale.order and called _add_delivery_carrier_on_confirmation function for each single record. So why do we need to iterate over it again, you can consider it with function that directly handles that record and call ensure_one function will make the code clearer

Copy link
Author

Choose a reason for hiding this comment

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

I did it another way, what do you think?

Choose a reason for hiding this comment

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

it looks fine to me. thanks

if order.delivery_set:
continue

Check warning on line 19 in sale_order_carrier_auto_assign/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_carrier_auto_assign/models/sale_order.py#L19

Added line #L19 was not covered by tests
delivery_wiz_action = order.action_open_delivery_wizard()
delivery_wiz_context = delivery_wiz_action.get("context", {})
if not delivery_wiz_context.get("default_carrier_id"):
continue
delivery_wiz = (
self.env[delivery_wiz_action.get("res_model")]
.with_context(**delivery_wiz_context)
.create({})
)
delivery_wiz._get_delivery_rate()

Choose a reason for hiding this comment

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

do we really need to call this function, I checked and found that it is mainly called in onchange functions and did not see it appear in any test in odoo codebase. I tried removing it and found that the module still works as expected and I guess that just calling button_confirm is enough, since in button_confirm there is a call to set_delivery_line function. I'm not sure if it's completely correct because I might miss something, do you think so?

Copy link
Author

@lef-adhoc lef-adhoc Dec 2, 2024

Choose a reason for hiding this comment

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

I deleted the line and I get an error in the tests and if I don't delete it I don't get an error. Can you check?

Choose a reason for hiding this comment

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

thanks for taking the time, maybe it was worth appearing on that line.

delivery_wiz.button_confirm()
3 changes: 3 additions & 0 deletions sale_order_carrier_auto_assign/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions sale_order_carrier_auto_assign/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To enable sale order carrier auto assign:

1. Go to *Settings \> Sales \> Carrier Auto Assign*.
5 changes: 5 additions & 0 deletions sale_order_carrier_auto_assign/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Akim Juillerat \<<[email protected]>\>
- Son (Ho Dac) \<<[email protected]>\>
- Phuc (Tran Thanh) \<<[email protected]>\>
- Telmo Santos \<<[email protected]>\>
- Tris Doan \<<[email protected]>\>
1 change: 1 addition & 0 deletions sale_order_carrier_auto_assign/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions sale_order_carrier_auto_assign/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module assigns automatically delivery carrier on sale order
confirmation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading