Skip to content

Conversation

@mathieudelva
Copy link
Member

@mathieudelva mathieudelva commented Feb 2, 2022

This field "parcel_sequence" allows you to add a value to T400 which is mandatory for Belgium.
The value of the field parcel_sequence is calculated on Odoo module like this:

vals["parcel_sequence"] = self.calc_parcel_num() --> I added this line in the inheritance of the function _gls_fr_glsbox_get_parcel(self, picking)

@api.model
def _get_sequence(self):
    sequence = self.env["ir.sequence"].next_by_code("delivery_carrier_gls")
    if not sequence:
        raise UserError(_("There is no sequence defined for the label GLS"))
    return sequence

def calc_parcel_num(self):
    start_num = (
        self.env["ir.config_parameter"]
        .sudo()
        .get_param("PARCEL_NUM_START", 01234567890)
    )
    parcel_num = self._get_sequence()
    num = int(start_num) + int(parcel_num)
    num = str(num)
    num = list(num)
    num.reverse()
    weighting = 3
    sum_of_num = 0
    for item in num:
        sum_of_num += int(item) * weighting
        if weighting == 3:
            weighting = 1
        else:
            weighting = 3
    sum_of_num += 1
    check_num = int(math.ceil(sum_of_num / 10.0)) * 10 - sum_of_num
    num.reverse()
    num.append(str(check_num))
    return "".join(num)

@florian-dacosta
Copy link
Member

Hello @math0706 thanks for the contribution.
That's strange, GLS told me quite recenlty that its web service was country dependent. Meaning it works for France but not for spain for example.

I guess maybe france and Belgium are together...
The T400 value has no description in the documentation I have... But I see it is already present in the ZPL template https://github.com/akretion/roulier/blob/master/roulier/carriers/gls_fr/glsbox/templates/zpl.zpl#L75

So I guess there are not problem.
I'll make a quick test later to validate and I should be able to merge your PR quicky enough.

Where is the Odoo code you are talking about ?

FYI, in version 14, there is this module that manage the glsbox api :
https://github.com/akretion/delivery-carrier/tree/14.0-mig-delivery_roulier_gls_fr
Which is used in production since the begging of the year (by a french company)
And https://github.com/akretion/delivery-carrier/tree/14-gls-rest-webservice
Which is not yet used in production but should be soon, it implements a more modern webservice which allow more stuff (multi parcel, ship worlwide, etc...)
GLS has still one more rest webservice, a kind of v2 I think but it is not implemented at all in roulier for now.
All of this for France, but maybe for Belgium too then...

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.

2 participants