summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-07-04 11:54:41 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-07-04 11:54:41 +0700
commit17e4deaaa9b274069e2ee01c2cdba7630532b68b (patch)
tree70bddc3d5b52fe9b527fde25d50e07f582c2ee0f /indoteknik_custom/models
parentdee0f12ed114837636d34824f86e5bfa2e055eb0 (diff)
shipment group
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/shipment_group.py58
2 files changed, 59 insertions, 0 deletions
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
+