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

[14.0] [MIG] delivery_carrier_label_gls #778

Closed
Closed
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
[MIG][16.0] delivery_carrier_label_gls: add migration script
  • Loading branch information
glitchov authored and paradoxxxzero committed Mar 7, 2024
commit 91a69ed1c30269abd3af89e0ebdf11104479ef9e
114 changes: 113 additions & 1 deletion delivery_carrier_label_gls/README.rst
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
TODO
==========================
Delivery Carrier Label GLS
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Fdelivery--carrier-lightgray.png?logo=github
:target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls
:alt: OCA/delivery-carrier
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_carrier_label_gls
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/delivery-carrier&target_branch=16.0
:alt: Try me on Runboat

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

Integration with GLS shipping webservices.
Documentation:
http://gls-shipit.gls-group.eu/webservices/2_8_11/doxygen/WS-REST-API/index.html

**Table of contents**

.. contents::
:local:

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

To start using GLS, you need to configure two types of settings in
*Inventory - Configuration- Delivery* or *Inventory - Configuration - Settings*
which leads to the right section in inventory global settings.
First you have the *Carrier Account* where you find account number
and password then you also have *Shipping Methods* with other GLS
parameters to configure such as contact ID, urls and return address.
These 2 types of settings use **"GLS"** as delivery type.
The contact ID corresponds to the sender which needs to be a contact in the
GLS database. This determines the default return address, as well as the billing.
You can also configure the tracking url that is used for each carrier.

For client integration tests you need to fill your credentials in the tests/common.py.

Usage
=====

Create the packages on GLS which returns a tracking ID.
If there is any kind of mistake (address, weight),
it is possible to cancel it as long as it has not been scanned yet.
If the package is not cancelled, it is invoiced even if it never ships.

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

The end of day report should be printed when the delivery takes place.
At the last resort, this function should be called at the end of the day.
If it had already run, it would have no impact.
In case the delivery is delayed, the report should simply be kept for the
next day, and provided with the next report if there is one.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`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**>`_.

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

Credits
=======

Authors
~~~~~~~

* Acsone
* Akretion

Contributors
~~~~~~~~~~~~

* David Beal @ Akretion
* Nans Lefebvre <nans.lefebvre@acsone.eu>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Hughes Damry <hughes.damry@acsone.eu>

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/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/16.0/delivery_carrier_label_gls>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
45 changes: 45 additions & 0 deletions delivery_carrier_label_gls/migrations/16.0.1.0.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 ACSONE SA/NV
Copy link
Member

Choose a reason for hiding this comment

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

Rename version ? 16.0.1.0.0 => 14.0.0.0

# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging

from openupgradelib import openupgrade

from odoo.tools import sql

_logger = logging.getLogger(__name__)


def _update_from_res_company_to_delivery_carrier(env):
_logger.info("update from res_company to delivery_carrier")
company_id = env.ref("base.main_company").id
if sql.column_exists(env.cr, "res_company", "gls_contact_id"):
# update value in delivery.carrier from res_company gls_contact_id
env.cr.execute(
f"""UPDATE delivery_carrier
SET gls_contact_id =
(SELECT gls_contact_id FROM res_company WHERE id={company_id})
WHERE delivery_type like 'gls'"""
)
# remove gls_contact_id from res_company
env.cr.execute("ALTER TABLE res_company DROP COLUMN gls_contact_id")


def _update_from_delivery_carrier_to_carrier_account(env):
_logger.info("update value in carrier.account from delivery.carrier")
for column in ("gls_login", "gls_password"):
if sql.column_exists(env.cr, "delivery.carrier", column):
# update column value in carrier_account
env.cr.execute(
f"""UPDATE carrier_account
SET {column} =
(SELECT {column} FROM delivery_carrier WHERE delivery_type like 'gls')
WHERE delivery_type like 'gls'"""
)
# remove column from delivery.carrier
env.cr.execute(f"ALTER TABLE delivery_carrier DROP COLUMN {column}")


@openupgrade.migrate()
def migrate(env, version):
_update_from_res_company_to_delivery_carrier(env)
_update_from_delivery_carrier_to_carrier_account(env)
2 changes: 1 addition & 1 deletion delivery_carrier_label_gls/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ First you have the *Carrier Account* where you find account number
and password then you also have *Shipping Methods* with other GLS
parameters to configure such as contact ID, urls and return address.
These 2 types of settings use **"GLS"** as delivery type.
The contact ID corresponds to the sender, which needs to be a contact in the
The contact ID corresponds to the sender which needs to be a contact in the
GLS database. This determines the default return address, as well as the billing.
You can also configure the tracking url that is used for each carrier.

4 changes: 2 additions & 2 deletions delivery_carrier_label_gls/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Create the packages on GLS, which returns a tracking ID.
Create the packages on GLS which returns a tracking ID.
If there is any kind of mistake (address, weight),
it is possible to cancel it as long as it has not been scanned yet.
If the package is not cancelled, it is invoiced even if it never ships.

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

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