summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-07-07 08:49:23 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-07-07 08:49:23 +0700
commita07c0242de1c79f3ea0add3ee6b51e2cbf4982b6 (patch)
tree7a044e1efab5978363497748236f0301a6d1c630
parent444e0b38349a33c9bd007e262eb8cb7f4c39f61d (diff)
compute field airway bill
-rw-r--r--indoteknik_custom/models/airway_bill.py175
-rw-r--r--indoteknik_custom/views/airway_bill.xml24
2 files changed, 177 insertions, 22 deletions
diff --git a/indoteknik_custom/models/airway_bill.py b/indoteknik_custom/models/airway_bill.py
index 6da83af6..09f88a91 100644
--- a/indoteknik_custom/models/airway_bill.py
+++ b/indoteknik_custom/models/airway_bill.py
@@ -19,25 +19,25 @@ class AirwayBill(models.Model):
manifest_ids = fields.One2many('airway.bill.manifest', 'waybill_id', string='Airway Bill Lines', auto_join=True)
delivered = fields.Boolean(string='Delivered', help='terkirim atau belum / true or false')
response = fields.Char(string='Response', help='hasil history tracking dalam format json')
- way_bill_date = fields.Char(string='Way Bill Date', compute='_compute_way_bill_date')
- way_bill_time = fields.Char(string='Way Bill Time')
- weigth = fields.Char(string='Weigth')
- origin = fields.Char(string='Origin')
- destination = fields.Char(string='Destination')
- shipper_name = fields.Char(string='Shipper Name')
- shipper_address1 = fields.Char(string='Shipper Address 1')
- shipper_address2 = fields.Char(string='Shipper Address 2')
- shipper_address3 = fields.Char(string='Shipper Address 3')
- shipper_city = fields.Char(string='Shipper City')
- receiver_name = fields.Char(string='Receiver Name')
- receiver_address1 = fields.Char(string='Receiver Address 1')
- receiver_address2 = fields.Char(string='Receiver Address 2')
- receiver_address3 = fields.Char(string='Receiver Address 3')
- receiver_city = fields.Char(string='Receiver City')
- status = fields.Char(string='Status')
- pod_receiver = fields.Char(string='Pod Receiver')
- pod_date = fields.Char(string='Pod Date')
- pod_time = fields.Char(string='Pod Time')
+ way_bill_date = fields.Char(string='Way Bill Date', compute='_compute_way_bill_datetime')
+ # way_bill_time = fields.Char(string='Way Bill Time')
+ weight = fields.Char(string='Weight ', compute='_compute_way_bill_weight')
+ origin = fields.Char(string='Origin', compute='_compute_way_bill_origin')
+ destination = fields.Char(string='Destination', compute='_compute_way_bill_destination')
+ shipper_name = fields.Char(string='Shipper Name', compute='_compute_way_bill_shipper_name')
+ shipper_address1 = fields.Char(string='Shipper Address 1', compute='_compute_way_bill_shipper_address1')
+ shipper_address2 = fields.Char(string='Shipper Address 2', compute='_compute_way_bill_shipper_address2')
+ shipper_address3 = fields.Char(string='Shipper Address 3', compute='_compute_way_bill_shipper_address3')
+ shipper_city = fields.Char(string='Shipper City', compute='_compute_way_bill_shipper_city')
+ receiver_name = fields.Char(string='Receiver Name', compute='_compute_way_bill_receiver_name')
+ receiver_address1 = fields.Char(string='Receiver Address 1', compute='_compute_way_bill_receiver_address1')
+ receiver_address2 = fields.Char(string='Receiver Address 2', compute='_compute_way_bill_receiver_address2')
+ receiver_address3 = fields.Char(string='Receiver Address 3', compute='_compute_way_bill_receiver_address3')
+ receiver_city = fields.Char(string='Receiver City', compute='_compute_way_bill_receiver_city')
+ status = fields.Char(string='Status', compute='_compute_way_bill_status')
+ pod_receiver = fields.Char(string='Pod Receiver', compute='_compute_way_bill_pod_receiver')
+ pod_datetime = fields.Char(string='Pod Date', compute='_compute_way_bill_pod_datetime')
+ # pod_time = fields.Char(string='Pod Time')
def decode_response(self):
self.ensure_one()
@@ -108,12 +108,143 @@ class AirwayBill(models.Model):
return response
return self.decode_response()['raja_ongkir']['result'][key]
- def _compute_way_bill_date(self):
+ def _compute_way_bill_datetime(self):
for airway in self:
details = airway._get_history('details')
if details:
- airway.way_bill_date = details['waybill_date']
+ waybill_date = details['waybill_date']
+ waybill_time = details['waybill_date']
+ airway.way_bill_date = waybill_date+' '+waybill_time
else:
airway.way_bill_date = '-'
- \ No newline at end of file
+ def _compute_way_bill_weight(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.weight = details['weight']
+ else:
+ airway.weight = '-'
+
+ def _compute_way_bill_origin(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.origin = details['origin']
+ else:
+ airway.origin = '-'
+
+ def _compute_way_bill_destination(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.destination = details['destination']
+ else:
+ airway.destination = '-'
+
+ def _compute_way_bill_shipper_name(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.shipper_name = details['shipper_name']
+ else:
+ airway.shipper_name = '-'
+
+ def _compute_way_bill_shipper_address1(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.shipper_address1 = details['shipper_address1']
+ else:
+ airway.shipper_address1 = '-'
+
+ def _compute_way_bill_shipper_address2(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.shipper_address2 = details['shipper_address2']
+ else:
+ airway.shipper_address2 = '-'
+
+ def _compute_way_bill_shipper_address3(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.shipper_address3 = details['shipper_address3']
+ else:
+ airway.shipper_address3 = '-'
+
+ def _compute_way_bill_shipper_city(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.shipper_city = details['shipper_city']
+ else:
+ airway.shipper_city = '-'
+
+ def _compute_way_bill_receiver_name(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.receiver_name = details['receiver_name']
+ else:
+ airway.receiver_name = '-'
+
+ def _compute_way_bill_receiver_address1(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.receiver_address1 = details['receiver_address1']
+ else:
+ airway.receiver_address1 = '-'
+
+ def _compute_way_bill_receiver_address2(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.receiver_address2 = details['receiver_address2']
+ else:
+ airway.receiver_address2 = '-'
+
+ def _compute_way_bill_receiver_address3(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.receiver_address3 = details['receiver_address3']
+ else:
+ airway.receiver_address3 = '-'
+
+ def _compute_way_bill_receiver_city(self):
+ for airway in self:
+ details = airway._get_history('details')
+ if details:
+ airway.receiver_city = details['receiver_city']
+ else:
+ airway.receiver_city = '-'
+
+ def _compute_way_bill_status(self):
+ for airway in self:
+ details = airway._get_history('delivery_status')
+ if details:
+ airway.status = details['status']
+ else:
+ airway.status = '-'
+
+ def _compute_way_bill_pod_receiver(self):
+ for airway in self:
+ details = airway._get_history('delivery_status')
+ if details:
+ airway.pod_receiver = details['pod_receiver']
+ else:
+ airway.pod_receiver = '-'
+
+ def _compute_way_bill_pod_datetime(self):
+ for airway in self:
+ details = airway._get_history('delivery_status')
+4 if details:
+ pod_date = details['pod_date']
+ pod_time = details['pod_tiem']
+ airway.pod_datetime = pod_date+' '+pod_time
+ else:
+ airway.pod_datetime = '-'
+ \ No newline at end of file
diff --git a/indoteknik_custom/views/airway_bill.xml b/indoteknik_custom/views/airway_bill.xml
index 99f80d7b..2107bdd7 100644
--- a/indoteknik_custom/views/airway_bill.xml
+++ b/indoteknik_custom/views/airway_bill.xml
@@ -42,9 +42,33 @@
<group>
<group>
<field name="way_bill_date"/>
+ <field name="weight"/>
+ <field name="origin"/>
+ <field name="destination"/>
+ <field name="shipper_name"/>
+ <field name="shipper_address1"/>
+ <field name="shipper_address2"/>
+ </group>
+ <group>
+ <field name="shipper_address3"/>
+ <field name="shipper_city"/>
+ <field name="receiver_name"/>
+ <field name="receiver_address1"/>
+ <field name="receiver_address2"/>
+ <field name="receiver_address3"/>
+ <field name="receiver_city"/>
</group>
</group>
</page>
+ <page string="Delivery Status">
+ <group>
+ <group>
+ <field name="status"/>
+ <field name="pod_receiver"/>
+ <field name="pod_datetime"/>
+ </group>
+ </group>
+ </page>
</notebook>
</sheet>
</form>