From 074f7e6c0190c1ae5e08db6db0dd3f4f3e28e941 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 5 Jul 2024 15:08:02 +0700 Subject: change request --- indoteknik_custom/models/purchase_order.py | 1 - indoteknik_custom/models/sale_order.py | 4 ++ indoteknik_custom/models/shipment_group.py | 55 ++++++++++++++++------- indoteknik_custom/models/stock_picking.py | 2 + indoteknik_custom/views/mail_template_efaktur.xml | 3 +- indoteknik_custom/views/shipment_group.xml | 4 ++ indoteknik_custom/views/stock_picking.xml | 4 +- 7 files changed, 54 insertions(+), 19 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 4a029441..32ddf1e5 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -487,7 +487,6 @@ class PurchaseOrder(models.Model): for purchasing_job in purchasing_job_state: purchasing_job.unlink() - def _send_po_not_sync(self): # Mengirim data ke model Po Sync Price jika harga po dan purchase pricelist tidak singkron for line in self.order_line: diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ac81737d..0d28e677 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -201,6 +201,10 @@ class SaleOrder(models.Model): @api.model def action_multi_update_state(self): for sale in self: + for picking_ids in sale.picking_ids: + if not picking_ids.state == 'cancel': + raise UserError('DO harus cancel terlebih dahulu') + sale.update({ 'state': 'cancel', }) diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py index bc593437..92f76db7 100644 --- a/indoteknik_custom/models/shipment_group.py +++ b/indoteknik_custom/models/shipment_group.py @@ -13,6 +13,7 @@ class ShipmentGroup(models.Model): number = fields.Char(string='Document No', index=True, copy=False, readonly=True, tracking=True) shipment_line = fields.One2many('shipment.group.line', 'shipment_id', string='Shipment Group Lines', auto_join=True) + partner_id = fields.Many2one('res.partner', string='Customer') @api.model def create(self, vals): @@ -29,30 +30,52 @@ class ShipmentGroupLine(models.Model): partner_id = fields.Many2one('res.partner', string='Customer') picking_id = fields.Many2one('stock.picking', string='Picking') sale_id = fields.Many2one('sale.order', string='Sale Order') - state = fields.Char(string='Status', readonly=True, compute='_get_state') + state = fields.Char(string='Status', readonly=True, compute='_compute_state') - def _get_state(self): + @api.depends('picking_id.state') + def _compute_state(self): for rec in self: - if rec.picking_id.state == 'assigned': - rec.state = 'Ready' - elif rec.picking_id.state == 'done': - rec.state = 'Done' - elif rec.picking_id.state == 'cancel': - rec.state = 'Cancelled' - elif rec.picking_id.state == 'confirmed': - rec.state = 'Waiting' - elif rec.picking_id.state == 'waiting': - rec.state = 'Waiting Another Operation' + if rec.picking_id: + if rec.picking_id.state == 'assigned': + rec.state = 'Ready' + elif rec.picking_id.state == 'done': + rec.state = 'Done' + elif rec.picking_id.state == 'cancel': + rec.state = 'Cancelled' + elif rec.picking_id.state == 'confirmed': + rec.state = 'Waiting' + elif rec.picking_id.state == 'waiting': + rec.state = 'Waiting Another Operation' + else: + rec.state = 'draft' else: rec.state = 'draft' @api.onchange('picking_id') def onchange_picking_id(self): - picking = self.env['stock.picking'].search([('id', '=', self.picking_id.id)], limit=1) + if self.picking_id: + picking = self.env['stock.picking'].browse(self.picking_id.id) + + if self.shipment_id.partner_id and self.shipment_id.partner_id != picking.partner_id: + raise UserError('Partner must be same as shipment group') + + self.partner_id = picking.partner_id - self.partner_id = picking.partner_id + if not self.shipment_id.partner_id: + self.shipment_id.partner_id = picking.partner_id - self.state = picking.state + self.sale_id = picking.sale_id + + @api.model + def create(self, vals): + record = super(ShipmentGroupLine, self).create(vals) + if record.picking_id: + record.onchange_picking_id() + return record - self.sale_id = picking.sale_id + def write(self, vals): + res = super(ShipmentGroupLine, self).write(vals) + if 'picking_id' in vals: + self.onchange_picking_id() + return res diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 62d86911..daa05c14 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -82,6 +82,8 @@ class StockPicking(models.Model): ('not_printed', 'Belum Print'), ('printed', 'Printed') ], string='Printed?', copy=False, tracking=True) + date_printed_sj = fields.Datetime(string='Status Printed Surat Jalan', copy=False, tracking=True) + date_printed_list = fields.Datetime(string='Status Printed Picking List', copy=False, tracking=True) date_unreserve = fields.Datetime(string="Date Unreserved", copy=False, tracking=True) date_availability = fields.Datetime(string="Date Availability", copy=False, tracking=True) sale_order = fields.Char(string='Matches SO', copy=False) diff --git a/indoteknik_custom/views/mail_template_efaktur.xml b/indoteknik_custom/views/mail_template_efaktur.xml index 0b646e7c..3856b591 100644 --- a/indoteknik_custom/views/mail_template_efaktur.xml +++ b/indoteknik_custom/views/mail_template_efaktur.xml @@ -6,7 +6,8 @@ Your Invoice ${object.name} pajak@indoteknik.co.id - sales@indoteknik.com + pajak@indoteknik.co.id + sales@indoteknik.com, pajak@indoteknik.co.id ${object.partner_id.email|safe}

Dengan Hormat Bpk/Ibu ${object.partner_id.name},

diff --git a/indoteknik_custom/views/shipment_group.xml b/indoteknik_custom/views/shipment_group.xml index 33d08920..b66bda3c 100644 --- a/indoteknik_custom/views/shipment_group.xml +++ b/indoteknik_custom/views/shipment_group.xml @@ -6,6 +6,7 @@ + @@ -33,6 +34,9 @@ + + + diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 90f662cc..4de1ac91 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -59,7 +59,6 @@ - @@ -75,6 +74,9 @@ + + +