odoo/ext/custom-addons/tz_carrier_allow_tracking_m.../models/TZCarrier.py

75 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import api, fields, models, registry, SUPERUSER_ID, _
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
class TZCarrier(models.Model):
_inherit = 'delivery.carrier'
delivery_type = fields.Selection(selection_add=[('TZCarrier', 'TZCarrier')])
# ------------------------------------------------ #
# Fixed price shipping, aka a very simple provider #
# ------------------------------------------------ #
# fixed_price = fields.Float(compute='_compute_fixed_price', inverse='_set_product_fixed_price', store=True,
# string='Fixed Price')
#
#
# @api.depends('product_id.list_price', 'product_id.product_tmpl_id.list_price')
# def _compute_fixed_price(self):
# for carrier in self:
# carrier.fixed_price = carrier.product_id.list_price
#
#
# def _set_product_fixed_price(self):
# for carrier in self:
# carrier.product_id.list_price = carrier.fixed_price
#
#
def TZCarrier_rate_shipment(self, order):
price = 0
# price = self.fixed_price
# if self.company_id.currency_id.id != order.currency_id.id:
# price = self.env['res.currency']._compute(self.company_id.currency_id, order.currency_id, price)
# return {'success': True,
# 'price': price,
# 'error_message': False,
# 'warning_message': False}
return False
def TZCarrier_send_shipping(self, pickings):
res = []
# for p in pickings:
# res = res + [{'exact_price': p.carrier_id.fixed_price,
# 'tracking_number': False}]
return res
def TZCarrier_get_tracking_link(self, picking):
lSearch = picking.carrier_tracking_ref
if self.name == 'Weiss':
if picking.carrier_tracking_ref == '?':
lSearch = picking.origin
TZLink = r'http://isis.gw-world.com/siprod/sixWeb.pStartApp?i_vcAction=SearchConLight&i_vcSearchKey=%s&i_vcAdd=Glaser&i_vclangid=DE' % lSearch
elif self.name == 'DHL':
TZLink = r'https://www.dhl.at/en/express/tracking.html?AWB=%s&brand=DHL' % lSearch
elif self.name == 'Dachser':
TZLink = r'http://partner.dachser.com/shp2/?wicket:interface=:5:pnlHead:frmHead:btnSearch::IActivePageBehaviorListener:0:-1&wicket:ignoreIfNotActive=true&random=0.35369399622175934&tfiSearch=%s' % lSearch
elif self.name == 'DPD':
TZLink = r'https://tracking.dpd.de/status/de_AT/parcel/%s' % lSearch
else:
TZLink = False
return TZLink
def TZCarrier_cancel_shipment(self, pickings):
# return True
raise UserError('Derzeit nicht möglich!')