From 17e4deaaa9b274069e2ee01c2cdba7630532b68b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 4 Jul 2024 11:54:41 +0700 Subject: shipment group --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/shipment_group.py | 58 +++++++++++++++++++++++ indoteknik_custom/security/ir.model.access.csv | 2 + indoteknik_custom/views/ir_sequence.xml | 10 ++++ indoteknik_custom/views/shipment_group.xml | 65 ++++++++++++++++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 indoteknik_custom/models/shipment_group.py create mode 100644 indoteknik_custom/views/shipment_group.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 67f16800..4a37414f 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -135,6 +135,7 @@ 'views/logbook_bill.xml', 'views/report_logbook_bill.xml', 'views/sale_order_multi_uangmuka_penjualan.xml', + 'views/shipment_group.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ffd1b645..10f4acee 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -120,3 +120,4 @@ from . import purchase_order_multi_uangmuka2 from . import logbook_bill from . import report_logbook_bill from . import sale_order_multi_uangmuka_penjualan +from . import shipment_group diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py new file mode 100644 index 00000000..bc593437 --- /dev/null +++ b/indoteknik_custom/models/shipment_group.py @@ -0,0 +1,58 @@ +from odoo import models, api, fields +from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import timedelta, date +import logging + +_logger = logging.getLogger(__name__) + +class ShipmentGroup(models.Model): + _name = "shipment.group" + _description = "Shipment Group" + _inherit = ['mail.thread'] + _rec_name = 'number' + + 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) + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('shipment.group') or '0' + result = super(ShipmentGroup, self).create(vals) + return result + +class ShipmentGroupLine(models.Model): + _name = 'shipment.group.line' + _description = 'Shipment Group Line' + _order = 'shipment_id, id' + + shipment_id = fields.Many2one('shipment.group', string='Shipment Ref', required=True, ondelete='cascade', index=True, copy=False) + 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') + + def _get_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' + 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) + + self.partner_id = picking.partner_id + + self.state = picking.state + + self.sale_id = picking.sale_id + diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 30bc7d06..d33ec5e3 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -128,3 +128,5 @@ access_report_logbook_bill,access.report.logbook.sj,model_report_logbook_bill,,1 access_report_logbook_bill_line,access.report.logbook.sj.line,model_report_logbook_bill_line,,1,1,1,1 access_report_logbook_bill_line,access.report.logbook.sj.line,model_report_logbook_bill_line,,1,1,1,1 access_sale_order_multi_uangmuka_penjualan,access.sale.order.multi_uangmuka_penjualan,model_sale_order_multi_uangmuka_penjualan,,1,1,1,1 +access_shipment_group,access.shipment.group,model_shipment_group,,1,1,1,1 +access_shipment_group_line,access.shipment.group.line,model_shipment_group_line,,1,1,1,1 diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 40ce135c..b4fb5c0c 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -21,6 +21,16 @@ 1 + + Shipment Group + shipment.group + TRUE + SG/%(year)s/ + 5 + 1 + 1 + + Logbook Bill report.logbook.bill diff --git a/indoteknik_custom/views/shipment_group.xml b/indoteknik_custom/views/shipment_group.xml new file mode 100644 index 00000000..33d08920 --- /dev/null +++ b/indoteknik_custom/views/shipment_group.xml @@ -0,0 +1,65 @@ + + + + shipment.group.tree + shipment.group + + + + + + + + + shipment.group.line.tree + shipment.group.line + + + + + + + + + + + + shipment.group.form + shipment.group + +
+ + + + + + + + + + + + +
+ + +
+
+
+
+ + + Shipment Group + ir.actions.act_window + shipment.group + tree,form + + + +
-- cgit v1.2.3