Skip to content

Commit e8b0be4

Browse files
committed
[MIG][16.0] delivery_carrier_label_gls: add migration script
1 parent a9a33ff commit e8b0be4

File tree

4 files changed

+161
-4
lines changed

4 files changed

+161
-4
lines changed

delivery_carrier_label_gls/README.rst

+113-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,113 @@
1-
TODO
1+
==========================
2+
Delivery Carrier Label GLS
3+
==========================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
17+
:target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls
18+
:alt: OCA/delivery-carrier
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_carrier_label_gls
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
23+
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/delivery-carrier&target_branch=16.0
24+
:alt: Try me on Runboat
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
Integration with GLS shipping webservices.
29+
Documentation:
30+
http://gls-shipit.gls-group.eu/webservices/2_8_11/doxygen/WS-REST-API/index.html
31+
32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
37+
Configuration
38+
=============
39+
40+
To start using GLS, you need to configure two types of settings in
41+
*Inventory - Configuration- Delivery* or *Inventory - Configuration - Settings*
42+
which leads to the right section in inventory global settings.
43+
First you have the *Carrier Account* where you find account number
44+
and password then you also have *Shipping Methods* with other GLS
45+
parameters to configure such as contact ID, urls and return address.
46+
These 2 types of settings use **"GLS"** as delivery type.
47+
The contact ID corresponds to the sender which needs to be a contact in the
48+
GLS database. This determines the default return address, as well as the billing.
49+
You can also configure the tracking url that is used for each carrier.
50+
51+
For client integration tests you need to fill your credentials in the tests/common.py.
52+
53+
Usage
54+
=====
55+
56+
Create the packages on GLS which returns a tracking ID.
57+
If there is any kind of mistake (address, weight),
58+
it is possible to cancel it as long as it has not been scanned yet.
59+
If the package is not cancelled, it is invoiced even if it never ships.
60+
61+
When sending a picking, all products should be put in one or multiple packages.
62+
These packages need to have a GLS packaging either Parcel, Express, or Freight.
63+
These are already pre-configured in the module data.
64+
65+
The end of day report should be printed when the delivery takes place.
66+
At the last resort, this function should be called at the end of the day.
67+
If it had already run, it would have no impact.
68+
In case the delivery is delayed, the report should simply be kept for the
69+
next day, and provided with the next report if there is one.
70+
71+
Bug Tracker
72+
===========
73+
74+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
75+
In case of trouble, please check there if your issue has already been reported.
76+
If you spotted it first, help us smashing it by providing a detailed and welcomed
77+
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_carrier_label_gls%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
78+
79+
Do not contact contributors directly about support or help with technical issues.
80+
81+
Credits
82+
=======
83+
84+
Authors
85+
~~~~~~~
86+
87+
* Acsone
88+
* Akretion
89+
90+
Contributors
91+
~~~~~~~~~~~~
92+
93+
* David Beal @ Akretion
94+
* Nans Lefebvre <nans.lefebvre@acsone.eu>
95+
* Laurent Mignon <laurent.mignon@acsone.eu>
96+
* Hughes Damry <hughes.damry@acsone.eu>
97+
98+
Maintainers
99+
~~~~~~~~~~~
100+
101+
This module is maintained by the OCA.
102+
103+
.. image:: https://odoo-community.org/logo.png
104+
:alt: Odoo Community Association
105+
:target: https://odoo-community.org
106+
107+
OCA, or the Odoo Community Association, is a nonprofit organization whose
108+
mission is to support the collaborative development of Odoo features and
109+
promote its widespread use.
110+
111+
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls>`_ project on GitHub.
112+
113+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2023 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
import logging
4+
5+
from openupgradelib import openupgrade
6+
7+
from odoo.tools import sql
8+
9+
_logger = logging.getLogger(__name__)
10+
11+
12+
def _update_from_res_company_to_delivery_carrier(env):
13+
_logger.info("update from res_company to delivery_carrier")
14+
company_id = env.ref("base.main_company").id
15+
if sql.column_exists(env.cr, "res_company", "gls_contact_id"):
16+
# update value in delivery.carrier from res_company gls_contact_id
17+
env.cr.execute(
18+
f"""UPDATE delivery_carrier
19+
SET gls_contact_id =
20+
(SELECT gls_contact_id FROM res_company WHERE id={company_id})
21+
WHERE delivery_type like 'gls'"""
22+
)
23+
# remove gls_contact_id from res_company
24+
env.cr.execute("ALTER TABLE res_company DROP COLUMN gls_contact_id")
25+
26+
27+
def _update_from_delivery_carrier_to_carrier_account(env):
28+
_logger.info("update value in carrier.account from delivery.carrier")
29+
for column in ("gls_login", "gls_password"):
30+
if sql.column_exists(env.cr, "delivery.carrier", column):
31+
# update column value in carrier_account
32+
env.cr.execute(
33+
f"""UPDATE carrier_account
34+
SET {column} =
35+
(SELECT {column} FROM delivery_carrier WHERE delivery_type like 'gls')
36+
WHERE delivery_type like 'gls'"""
37+
)
38+
# remove column from delivery.carrier
39+
env.cr.execute(f"ALTER TABLE delivery_carrier DROP COLUMN {column}")
40+
41+
42+
@openupgrade.migrate()
43+
def migrate(env, version):
44+
_update_from_res_company_to_delivery_carrier(env)
45+
_update_from_delivery_carrier_to_carrier_account(env)

delivery_carrier_label_gls/readme/CONFIGURE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ First you have the *Carrier Account* where you find account number
55
and password then you also have *Shipping Methods* with other GLS
66
parameters to configure such as contact ID, urls and return address.
77
These 2 types of settings use **"GLS"** as delivery type.
8-
The contact ID corresponds to the sender, which needs to be a contact in the
8+
The contact ID corresponds to the sender which needs to be a contact in the
99
GLS database. This determines the default return address, as well as the billing.
1010
You can also configure the tracking url that is used for each carrier.
1111

delivery_carrier_label_gls/readme/USAGE.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Create the packages on GLS, which returns a tracking ID.
1+
Create the packages on GLS which returns a tracking ID.
22
If there is any kind of mistake (address, weight),
33
it is possible to cancel it as long as it has not been scanned yet.
44
If the package is not cancelled, it is invoiced even if it never ships.
55

66
When sending a picking, all products should be put in one or multiple packages.
7-
These packages need to have a GLS packaging, either Parcel, Express, or Freight.
7+
These packages need to have a GLS packaging either Parcel, Express, or Freight.
88
These are already pre-configured in the module data.
99

1010
The end of day report should be printed when the delivery takes place.

0 commit comments

Comments
 (0)