Browse Source

store UPS pickup number in delivery.carrier.pickup

When following-up with UPS, we need their pickup number, not the UUID of shipcloud.

The returned json looks like this:

{u'shipments': [{u'id': u'a23d961097526050d1f75c2ceef0ec4988e99487'}, {u'id': u'03bca49429ee181f473d8fa7c27cc0166afb6e62'}, {u'id': u'8785ef61d5254726ecb0084a6234ec1ab943cfca'}], u'pickup_time': {u'earliest': u'2021-05-07T08:00:24+02:00', u'latest': u'2021-05-07T14:00:09+02:00'}, u'carrier': u'ups', u'carrier_pickup_number': u'29E4A3S0I71', u'id': u'0360d24d-ce69-49fc-9938-0ec818eb6d54', u'pickup_address': {u'city': u'Berlin', u'first_name': u'Maike', u'last_name': u'Welte', u'country': u'DE', u'company': u'sysmocom GmbH (LRW34a)', u'street_no': u'34a', u'care_of': None, u'id': u'81128c61-b6ba-458e-a7e7-817f2c094f40', u'phone': u'030609871280', u'state': None, u'street': u'Landreiterweg', u'email': None, u'zip_code': u'12353'}}

so in the above example, we want to store u'carrier_pickup_number': u'29E4A3S0I71'

Closes: SYS#5422
master
Harald Welte 6 months ago
parent
commit
75f5e374fb
  1. 2
      models/shipcloud_pickup.py
  2. 2
      views/shipcloud_pickup.xml

2
models/shipcloud_pickup.py

@ -29,6 +29,7 @@ class SCPickup(models.Model):
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done','Done')],
string='Status', default='draft', readonly=True, required=True, copy=False)
sc_pickup_id = fields.Char('Shipcloud Pick-up ID', readonly=True, copy=False)
carrier_pickup_number = fields.Char('Carrier Pick-up Number', readonly=True, copy=False)
def _shipcloud_api(self):
@ -71,6 +72,7 @@ class SCPickup(models.Model):
raise Warning(err)
_logger.info("shipcloud response: %s", result)
self.sc_pickup_id = result['id']
self.sc_pickup_id = result['carrier_pickup_number']
self.state = 'confirmed'
# somehow this didn't work as a new (v8) style ORM ?!?

2
views/shipcloud_pickup.xml

@ -26,6 +26,7 @@
</group>
<group name="misc">
<field name="sc_pickup_id"/>
<field name="carrier_pickup_number"/>
</group>
</sheet>
</form>
@ -39,6 +40,7 @@
<field name="arch" type="xml">
<tree string="pickup">
<field name="carrier"/>
<field name="carrier_pickup_number"/>
<field name="earliest"/>
<field name="latest"/>
<field name="address"/>

Loading…
Cancel
Save