diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-11 13:10:24 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-11 13:10:24 +0700 |
| commit | 9a630354c1d00e218595db9b2e8cd0b7df9ed97c (patch) | |
| tree | d3275f79dbf6757bbf41bf7a509777e9be76c529 | |
| parent | 5c5c0bbcb7ad09a8951b8ee2800b73e7a2ab8c8d (diff) | |
Fix feature
- Fix voucher API
- Add field shipping status on stock picking
| -rw-r--r-- | indoteknik_api/controllers/api_v1/stock_picking.py | 2 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/voucher.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 12 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 5 |
4 files changed, 16 insertions, 5 deletions
diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py index 7e246a9f..74f4564a 100644 --- a/indoteknik_api/controllers/api_v1/stock_picking.py +++ b/indoteknik_api/controllers/api_v1/stock_picking.py @@ -56,6 +56,7 @@ class StockPicking(controller.Controller): res_pickings = [] for picking in stock_pickings: manifests = picking.get_manifests() + res_pickings.append({ 'id': picking.id, 'name': picking.name, @@ -67,6 +68,7 @@ class StockPicking(controller.Controller): 'client_order_ref': picking.sale_id.client_order_ref or '' }, 'delivered': picking.waybill_id.delivered or picking.driver_arrival_date != False, + 'status': picking.shipping_status, 'carrier_name': picking.carrier_id.name or '', 'last_manifest': next(iter(manifests), None) }) diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index a76d57e6..dfe9ceba 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -67,7 +67,7 @@ class Voucher(controller.Controller): voucher_res['can_apply'] = can_apply voucher_res['discount_voucher'] = voucher_discount - cleaned_tnc = BeautifulSoup(voucher.terms_conditions, "html.parser").get_text() + cleaned_tnc = BeautifulSoup(voucher.terms_conditions or '', "html.parser").get_text() voucher_res['terms_conditions'] = voucher.terms_conditions if cleaned_tnc else voucher.generate_tnc() results.append(voucher_res) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8e8c1e79..8cb48755 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -73,6 +73,17 @@ class StockPicking(models.Model): waybill_id = fields.One2many(comodel_name='airway.bill', inverse_name='do_id', string='Airway Bill') purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative", readonly=True) + shipping_status = fields.Char(string='Shipping Status', compute="_compute_shipping_status") + + def _compute_shipping_status(self): + for rec in self: + status = 'pending' + if rec.driver_departure_date and not rec.driver_arrival_date: + status = 'shipment' + elif rec.driver_departure_date and rec.driver_arrival_date: + status = 'completed' + + rec.shipping_status = status def action_create_invoice_from_mr(self): """Create the invoice associated to the PO. @@ -414,6 +425,7 @@ class StockPicking(models.Model): 'receiver_city': '' }, 'delivered': False, + 'status': self.shipping_status, 'waybill_number': self.delivery_tracking_no or '', 'delivery_status': None, 'eta': self.generate_eta_delivery(), diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 720c465e..4865db2f 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -114,14 +114,11 @@ class Voucher(models.Model): return round(calculate_time.total_seconds()) def filter_order_line(self, order_line): - if self.apply_type == 'all': - return order_line - voucher_manufacture_ids = self.collect_manufacture_ids() results = [] for line in order_line: manufacture_id = line['product_id'].x_manufacture.id or None - if manufacture_id not in voucher_manufacture_ids: + if self.apply_type == 'brand' and manufacture_id not in voucher_manufacture_ids: continue product_flashsale = line['product_id']._get_active_flash_sale() |
