From 92f33f2851a76bf391c0cfdee8fc0d4047e22a1d Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 May 2024 16:30:43 +0700 Subject: sync dunning to ged --- indoteknik_custom/models/dunning_run.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'indoteknik_custom/models/dunning_run.py') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index abfd68be..b5b8acb5 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -3,6 +3,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError from datetime import timedelta import logging + _logger = logging.getLogger(__name__) @@ -25,6 +26,7 @@ class DunningRun(models.Model): shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') is_validated = fields.Boolean(string='Validated') notification = fields.Char(string='Notification') + last_status_awb = fields.Char(string='Last Status AWB') def copy_date_faktur(self): if not self.is_validated: @@ -105,6 +107,33 @@ class DunningRun(models.Model): result = super(DunningRun, self).create(vals) return result + def _get_tracking_history(self, test_awb_number): + if test_awb_number: + query = [ + ('last_status', '!=', 'POD Return'), + ('resi_tukar_faktur', '=', test_awb_number), + ('shipper_faktur_id', '=', 123) + ] + else: + query = [ + ('last_status', '!=', 'POD Return'), + ('resi_tukar_faktur', '!=', False), + ('shipper_faktur_id', '=', 123) + ] + dunnings = self.env['dunning.run'].search(query) + + for dunning in dunnings: + current_tracking = self.env['ged.tracking'].search([('awb_no', '=', dunning.resi_tukar_faktur)], limit=1) + if current_tracking: + current_tracking.unlink() + else: + ged_api = self.env['ged.api'] + last_status = ged_api.get_tracking_awb(dunning.id) + if not last_status: + dunning.last_status_awb = last_status + return + + class DunningRunLine(models.Model): _name = 'dunning.run.line' -- cgit v1.2.3 From b88662f880bfcc03d8de4c4e272054a35acf1e4a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 May 2024 16:35:38 +0700 Subject: refactor code dunning run to ged class --- indoteknik_custom/models/dunning_run.py | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'indoteknik_custom/models/dunning_run.py') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index b5b8acb5..8f17fea6 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -107,33 +107,6 @@ class DunningRun(models.Model): result = super(DunningRun, self).create(vals) return result - def _get_tracking_history(self, test_awb_number): - if test_awb_number: - query = [ - ('last_status', '!=', 'POD Return'), - ('resi_tukar_faktur', '=', test_awb_number), - ('shipper_faktur_id', '=', 123) - ] - else: - query = [ - ('last_status', '!=', 'POD Return'), - ('resi_tukar_faktur', '!=', False), - ('shipper_faktur_id', '=', 123) - ] - dunnings = self.env['dunning.run'].search(query) - - for dunning in dunnings: - current_tracking = self.env['ged.tracking'].search([('awb_no', '=', dunning.resi_tukar_faktur)], limit=1) - if current_tracking: - current_tracking.unlink() - else: - ged_api = self.env['ged.api'] - last_status = ged_api.get_tracking_awb(dunning.id) - if not last_status: - dunning.last_status_awb = last_status - return - - class DunningRunLine(models.Model): _name = 'dunning.run.line' -- cgit v1.2.3 From 777380f7346afc91189502c7f7943ce4b7b2e7f1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 May 2024 16:36:23 +0700 Subject: revert column in dunning run related with ged --- indoteknik_custom/models/dunning_run.py | 1 - 1 file changed, 1 deletion(-) (limited to 'indoteknik_custom/models/dunning_run.py') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index 8f17fea6..4e04c03c 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -26,7 +26,6 @@ class DunningRun(models.Model): shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') is_validated = fields.Boolean(string='Validated') notification = fields.Char(string='Notification') - last_status_awb = fields.Char(string='Last Status AWB') def copy_date_faktur(self): if not self.is_validated: -- cgit v1.2.3