onesteinbv / addons-sendcloud

Other
3 stars 9 forks source link

Issue with country of origin - Odoo Enterprise #18

Closed HunkBenny closed 1 year ago

HunkBenny commented 1 year ago

For shipping outside of the EEA, you advise users to use the 'product_harmonized_system' module from OCA. However, this module is incompatible with Odoo Enterprise.. So; your Sendcloud-app will not behave as expected for Odoo Enterprise.

Look at lines 333 - 340: https://github.com/onesteinbv/addons-sendcloud/blob/b67059c317a7700da7a4838e9ec90572a25947b3/delivery_sendcloud_official/models/stock_picking.py#L328-L341

For Odoo Enterprise, if the 'account_intrastat' module is enabled, a country_of_origin field is added to products that has the functionality that's needed. The value can be accessed as follows:

origin_country = product_tmplate.intrastat_origin_country_id.code I hardcoded this in our backend for now. It works for us.

What I advise is adding something along the lines of:

is_account_intrastat_installed = self.env["ir.module.module"].search([
            ("name", "=", "account_intrastat "),
            ("state", "=", "installed")
        ], limit=1)
if is_account_intrastat_installed:
    origin_country = product_tmplate.intrastat_origin_country_id.code

Love to hear from ya!

Benny

astirpe commented 1 year ago

Hi @HunkBenny thank you very much! That's very appreciated. I'm going to apply your solution soon!

astirpe commented 1 year ago

@HunkBenny the module was updated with the fix you proposed. Thanks again!