Task #034593: Integration with GLS

This commit is contained in:
Sim? Albert i Beltran 2018-07-23 13:11:49 +02:00
parent 35def100fd
commit 4a1d6f38b4
7 changed files with 41 additions and 23 deletions

25
api.py
View file

@ -24,7 +24,7 @@ __all__ = ['CarrierApi', 'CarrierApiRedyserZip', 'CarrierApiRedyserOffline',
'CarrierApiRedyserOfflineSendStart', 'CarrierApiRedyserOfflineSend',
'LoadCarrierApiRedyserZipStart', 'LoadCarrierApiRedyserZip']
REDYSER_LOAD_ZIP = 'http://webservices.redyser.com/services/downloads/canalizaciones_int.csv'
REDYSER_LOAD_ZIP = 'https://webservices.redyser.com/services/downloads/canalizaciones_gls.csv'
class CarrierApi:
@ -79,8 +79,9 @@ class CarrierApi:
@staticmethod
def _get_keys():
return ['postal_code', 'country_code', 'center_code', 'center_name',
'service_1030', 'service_saturday', 'max_pickup_time']
return ['country_code', 'postal_code', 'center_name', 'mnemonic',
'service_1030', 'today_pickup', 'max_pickup_time',
'service_saturday']
@classmethod
def test_redyser(cls, api):
@ -92,14 +93,15 @@ class CarrierApiRedyserZip(ModelSQL, ModelView):
__name__ = 'carrier.api.redyser.zip'
postal_code = fields.Char('Postal Code', required=True, select=True)
country_code = fields.Char('Country code')
center_code = fields.Char('Center code')
center_name = fields.Char('Center name')
mnemonic = fields.Char('Mnemonic')
service_1030 = fields.Boolean('Delivery 10:30')
today_pickup = fields.Boolean('Today Pickup')
service_saturday = fields.Boolean('Delivery Saturdays')
max_pickup_time = fields.Time('Maximum pickup time')
def get_rec_name(self, name=None):
return '%s-%s' % (self.postal_code, self.center_code)
return '%s-%s' % (self.postal_code, self.center_name)
@classmethod
def load_redyser_zip(cls):
@ -126,15 +128,16 @@ class CarrierApiRedyserZip(ModelSQL, ModelView):
continue
new_line = {}
new_line['postal_code'] = row[0]
new_line['country_code'] = row[1]
new_line['center_code'] = row[2]
new_line['center_name'] = row[3]
new_line['country_code'] = row[0]
new_line['postal_code'] = row[1]
new_line['center_name'] = row[2]
new_line['mnemonic'] = row[3]
new_line['service_1030'] = True if row[4] == 'S' else False
new_line['service_saturday'] = True if row[5] == 'S' else False
new_line['today_pickup'] = True if row[5] == 'S' else False
if row[6]:
new_line['max_pickup_time'] = datetime.datetime.strptime(
row[6], '%H:%M:%S').time()
row[6], '%H:%M').time()
new_line['service_saturday'] = True if row[7] == 'S' else False
to_create.append(new_line)
if to_create:

View file

@ -123,6 +123,10 @@ copyright notices and license terms. -->
<field name="action" ref="redyser_zip_load_wizard"/>
<field name="sequence" eval="50"/>
</record>
<menuitem name="Update Redyser Zips"
parent="menu_carrier_api_redyser_zip_form"
action="redyser_zip_load_wizard"
id="menu_redyser_zip_load_wizard"/>
<!-- Sequence -->
<record model="ir.sequence.type" id="sequence_type_carrier_api_redyser">

View file

@ -170,12 +170,19 @@
<reportElement positionType="FixRelativeToBottom" x="2" y="47" width="307" height="1" uuid="cadc68f6-462d-4d78-8679-14c7c0924afa"/>
</line>
<textField>
<reportElement positionType="FixRelativeToBottom" x="120" y="5" width="189" height="22" uuid="faf30060-9ae2-4f6d-a349-94f7748da5d8"/>
<reportElement positionType="FixRelativeToBottom" x="120" y="5" width="50" height="30" uuid="faf30060-9ae2-4f6d-a349-94f7748da5d8"/>
<textElement>
<font size="10"/>
<font size="20"/>
<paragraph leftIndent="5"/>
</textElement>
<textFieldExpression><![CDATA[$F{channeling}]]></textFieldExpression>
<textFieldExpression><![CDATA[$F{channeling}.split()[0]]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="170" y="5" width="120" height="22" uuid="a56a2ec5-8eb4-40cb-9f89-07acff439bd8"/>
<textElement>
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{channeling}.split(' ',2)[1]]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="120" y="27" width="189" height="18" uuid="d50ea5ee-9f6e-451c-97bf-4cb64db00c03"/>
@ -183,7 +190,7 @@
<textFieldExpression><![CDATA[$F{delivery-city}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="21" y="25" width="74" height="20" uuid="5555b137-2743-4b37-b250-51f4df356cf7"/>
<reportElement positionType="FixRelativeToBottom" x="0" y="25" width="120" height="20" uuid="5555b137-2743-4b37-b250-51f4df356cf7"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{carrier-service}]]></textFieldExpression>
</textField>
@ -228,7 +235,7 @@
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{carrier_cashondelivery} ? "REEMBOLSO: " + $F{carrier_cashondelivery_price} : ""]]></textFieldExpression>
<textFieldExpression><![CDATA["Reembolso: " + ($F{carrier_cashondelivery} ? "SI" : "NO")]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="239" y="118" width="71" height="11" uuid="82b95bc3-07b2-4cc3-a952-edab2f9a515e"/>
@ -324,12 +331,12 @@
</band>
</pageHeader>
<pageFooter>
<band height="59">
<band height="75">
<componentElement>
<reportElement positionType="FixRelativeToBottom" x="-2" y="6" width="309" height="50" uuid="f5431006-bd6b-4245-bd3e-f60a3ef88dff">
<reportElement positionType="FixRelativeToBottom" x="-2" y="6" width="205" height="69" uuid="f5431006-bd6b-4245-bd3e-f60a3ef88dff">
<printWhenExpression><![CDATA[!$F{redyser_barcode}.isEmpty()]]></printWhenExpression>
</reportElement>
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="Code128" drawText="false" checksumRequired="true" barWidth="0" barHeight="2">
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="Code128" drawText="false" checksumRequired="true" barWidth="0" barHeight="69">
<jr:codeExpression><![CDATA[$F{redyser_barcode}]]></jr:codeExpression>
</jr:barbecue>
</componentElement>

View file

@ -31,7 +31,7 @@ class ShipmentOut:
if not channeling:
return
return ('%s %s') % (
channeling[0].center_code, channeling[0].center_name)
channeling[0].mnemonic, channeling[0].center_name)
def get_redyser_package(self, name=None):
package = Transaction().context.get('package')

View file

@ -144,6 +144,7 @@ Create API Carrier and services::
>>> Sequence = Model.get('ir.sequence')
>>> sequence, = Sequence.find([('code', '=', 'carrier.api.redyser')])
>>> carrier_api = CarrierAPI()
>>> carrier_api.name = 'Redyser'
>>> carrier_api.method = 'redyser'
>>> carrier_api.carriers.append(carrier_redyser)
>>> carrier_api.vat = '123456'

View file

@ -7,12 +7,14 @@ copyright notices and license terms. -->
<field name="postal_code"/>
<label name="country_code"/>
<field name="country_code"/>
<label name="center_code"/>
<field name="center_code"/>
<label name="center_name"/>
<field name="center_name"/>
<label name="mnemonic"/>
<field name="mnemonic"/>
<label name="service_1030"/>
<field name="service_1030"/>
<label name="today_pickup"/>
<field name="today_pickup"/>
<label name="service_saturday"/>
<field name="service_saturday"/>
<label name="max_pickup_time"/>

View file

@ -5,9 +5,10 @@ copyright notices and license terms. -->
<tree string="Redyser Zip">
<field name="postal_code"/>
<field name="country_code"/>
<field name="center_code"/>
<field name="center_name"/>
<field name="mnemonic"/>
<field name="service_1030"/>
<field name="today_pickup"/>
<field name="service_saturday"/>
<field name="max_pickup_time"/>
</tree>