2015-08-19 23:29:04 +02:00
|
|
|
# This file is part of the carrier_send_shipments_seurvalencia module for Tryton.
|
2014-03-26 11:36:26 +01:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains the full
|
|
|
|
# copyright notices and license terms.
|
2018-09-15 18:08:52 +02:00
|
|
|
import logging
|
2014-03-26 11:36:26 +01:00
|
|
|
from trytond.pool import PoolMeta
|
2015-08-19 23:29:04 +02:00
|
|
|
from trytond.pyson import Eval, Not, Equal
|
2020-07-05 11:05:00 +02:00
|
|
|
from trytond.i18n import gettext
|
|
|
|
from trytond.exceptions import UserError
|
2018-09-15 18:08:52 +02:00
|
|
|
from seurvalencia.picking import *
|
2014-03-26 11:36:26 +01:00
|
|
|
|
|
|
|
__all__ = ['CarrierApi']
|
|
|
|
|
|
|
|
|
2018-09-15 18:08:52 +02:00
|
|
|
class CarrierApi(metaclass=PoolMeta):
|
2014-03-26 11:36:26 +01:00
|
|
|
__name__ = 'carrier.api'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_carrier_app(cls):
|
2016-11-30 23:25:29 +01:00
|
|
|
'Add Carrier Seur APP'
|
2014-03-26 11:36:26 +01:00
|
|
|
res = super(CarrierApi, cls).get_carrier_app()
|
|
|
|
res.append(('seurvalencia', 'Seur Valencia'))
|
|
|
|
return res
|
|
|
|
|
2015-08-19 23:29:04 +02:00
|
|
|
@classmethod
|
|
|
|
def view_attributes(cls):
|
|
|
|
return super(CarrierApi, cls).view_attributes() + [
|
2015-08-19 23:45:54 +02:00
|
|
|
('//page[@id="seurvalencia"]', 'states', {
|
2015-08-19 23:29:04 +02:00
|
|
|
'invisible': Not(Equal(Eval('method'), 'seurvalencia')),
|
|
|
|
})]
|
|
|
|
|
2016-11-30 23:25:29 +01:00
|
|
|
@classmethod
|
|
|
|
def test_seurvalencia(cls, api):
|
|
|
|
'Test Seur Valencia connection'
|
2014-03-26 11:36:26 +01:00
|
|
|
message = 'Connection unknown result'
|
2016-11-30 23:25:29 +01:00
|
|
|
|
2014-03-26 11:36:26 +01:00
|
|
|
with API(api.username, api.password, api.debug) as seurvalencia_api:
|
|
|
|
message = seurvalencia_api.test_connection()
|
2020-07-05 11:05:00 +02:00
|
|
|
raise UserError(gettext(
|
|
|
|
'carrier_send_shipments_seurvalencia.msg_test_connection',
|
|
|
|
message=message))
|