From 735e0e896d9f58bb98921ce1463f411cfd5289fd Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Thu, 6 Sep 2018 15:32:08 -0700 Subject: [PATCH] Modifications needed for Odoo 11.0 and Python3 --- delivery_stamps/__init__.py | 3 +-- delivery_stamps/__manifest__.py | 28 +---------------------- delivery_stamps/models/__init__.py | 1 - delivery_stamps/models/api/config.py | 6 ++--- delivery_stamps/models/api/services.py | 2 +- delivery_stamps/models/delivery_stamps.py | 17 +++++++------- 6 files changed, 14 insertions(+), 43 deletions(-) diff --git a/delivery_stamps/__init__.py b/delivery_stamps/__init__.py index 89d26e2f..0650744f 100644 --- a/delivery_stamps/__init__.py +++ b/delivery_stamps/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- -import models +from . import models diff --git a/delivery_stamps/__manifest__.py b/delivery_stamps/__manifest__.py index 1aa584ae..6a16401d 100644 --- a/delivery_stamps/__manifest__.py +++ b/delivery_stamps/__manifest__.py @@ -1,28 +1,7 @@ -# -*- coding: utf-8 -*- -# -# -# Author: Jared Kipe -# Copyright 2017 Hibou Corp. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - { 'name': 'Stamps.com (USPS) Shipping', 'summary': 'Send your shippings through Stamps.com and track them online.', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'author': "Hibou Corp.", 'category': 'Warehouse', 'license': 'AGPL-3', @@ -34,11 +13,6 @@ Stamps.com (USPS) Shipping Send your shippings through Stamps.com and track them online. -Contributors ------------- - -* Jared Kipe - """, 'depends': [ 'delivery', diff --git a/delivery_stamps/models/__init__.py b/delivery_stamps/models/__init__.py index c58180b1..d675855d 100644 --- a/delivery_stamps/models/__init__.py +++ b/delivery_stamps/models/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import delivery_stamps diff --git a/delivery_stamps/models/api/config.py b/delivery_stamps/models/api/config.py index 09fd27ec..4665780f 100755 --- a/delivery_stamps/models/api/config.py +++ b/delivery_stamps/models/api/config.py @@ -9,9 +9,9 @@ :license: BSD, see LICENSE for more details. """ -from ConfigParser import NoOptionError, NoSectionError, SafeConfigParser -from urllib import pathname2url -from urlparse import urljoin +from configparser import NoOptionError, NoSectionError, SafeConfigParser +from urllib.request import pathname2url +from urllib.parse import urljoin import os diff --git a/delivery_stamps/models/api/services.py b/delivery_stamps/models/api/services.py index 50b313a3..1f7b350a 100755 --- a/delivery_stamps/models/api/services.py +++ b/delivery_stamps/models/api/services.py @@ -285,7 +285,7 @@ class XDecimal(XBuiltin): value for python. """ if topython: - if isinstance(value, basestring) and len(value): + if isinstance(value, str) and len(value): ret_val = Decimal(value) else: ret_val = None diff --git a/delivery_stamps/models/delivery_stamps.py b/delivery_stamps/models/delivery_stamps.py index 61f68dbb..9965320d 100644 --- a/delivery_stamps/models/delivery_stamps.py +++ b/delivery_stamps/models/delivery_stamps.py @@ -1,14 +1,13 @@ -# -*- coding: utf-8 -*- from datetime import date from logging import getLogger -import urllib2 +from urllib.request import urlopen from suds import WebFault from odoo import api, fields, models, _ from odoo.exceptions import ValidationError -from api.config import StampsConfiguration -from api.services import StampsService +from .api.config import StampsConfiguration +from .api.services import StampsService _logger = getLogger(__name__) @@ -105,16 +104,16 @@ class ProviderStamps(models.Model): return ret_val def _get_order_for_picking(self, picking): - if picking.group_id and picking.group_id.procurement_ids and picking.group_id.procurement_ids[0].sale_line_id: - return picking.group_id.procurement_ids[0].sale_line_id.order_id + if picking.sale_id: + return picking.sale_id return None def _get_company_for_order(self, order): company = order.company_id if order.team_id and order.team_id.subcompany_id: company = order.team_id.subcompany_id.company_id - elif order.project_id and order.project_id.subcompany_id: - company = order.project_id.subcompany_id.company_id + elif order.analytic_account_id and order.analytic_account_id.subcompany_id: + company = order.analytic_account_id.subcompany_id.company_id return company def _get_company_for_picking(self, picking): @@ -273,7 +272,7 @@ class ProviderStamps(models.Model): carrier_price += float(label.Rate.Amount) url = label.URL - response = urllib2.urlopen(url) + response = urlopen(url) attachment = response.read() picking.message_post(body=body, attachments=[('LabelStamps-%s.%s' % (label.TrackingNumber, self.stamps_image_type), attachment)]) shipping_data = {'exact_price': carrier_price, 'tracking_number': ','.join(tracking_numbers)}