summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fixco_custom/models/shipment_group.py43
-rwxr-xr-xfixco_custom/views/stock_picking.xml9
2 files changed, 48 insertions, 4 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py
index 117de0b..2e2dffa 100644
--- a/fixco_custom/models/shipment_group.py
+++ b/fixco_custom/models/shipment_group.py
@@ -52,12 +52,26 @@ class ShipmentGroup(models.Model):
raise UserError(f"Pickings berikut telah dibatalkan:{cancelled_names}")
for picking_line in shipment.picking_lines:
+ if picking_line.picking_id:
+ # set shipment group ke stock.picking
+ picking_line.picking_id.write({
+ 'shipment_group_id': shipment.id
+ })
+ picking_line.picking_id.message_post(
+ body=_(
+ "📦 <b>Dispatched</b><br/>"
+ "Picking ini telah di-dispatch melalui "
+ "<b>Shipment Group %s</b>."
+ ) % shipment.number
+ )
+
shipment_lines = self.env['shipment.group.line'].search([
('shipment_id', '=', shipment.id),
('invoice_marketplace', '=', picking_line.invoice_marketplace),
('picking_id', '=', picking_line.picking_id.id)
])
+ # reset product shipment
picking_line.product_shipment_lines.unlink()
for sl in shipment_lines:
@@ -70,6 +84,35 @@ class ShipmentGroup(models.Model):
'order_reference': sl.order_reference,
})
+
+ # def sync_product_to_picking_line(self):
+ # for shipment in self:
+ # cancelled_picking = shipment.picking_lines.filtered(
+ # lambda picking: picking.status == 'CANCELLED'
+ # )
+ # if cancelled_picking:
+ # cancelled_names = "\n - " + "\n - ".join(cancelled_picking.mapped("name"))
+ # raise UserError(f"Pickings berikut telah dibatalkan:{cancelled_names}")
+
+ # for picking_line in shipment.picking_lines:
+ # shipment_lines = self.env['shipment.group.line'].search([
+ # ('shipment_id', '=', shipment.id),
+ # ('invoice_marketplace', '=', picking_line.invoice_marketplace),
+ # ('picking_id', '=', picking_line.picking_id.id)
+ # ])
+
+ # picking_line.product_shipment_lines.unlink()
+
+ # for sl in shipment_lines:
+ # self.env['product.shipment.line'].create({
+ # 'picking_line_id': picking_line.id,
+ # 'product_id': sl.product_id.id,
+ # 'carrier': sl.carrier or picking_line.carrier,
+ # 'invoice_marketplace': sl.invoice_marketplace,
+ # 'picking_id': sl.picking_id.id,
+ # 'order_reference': sl.order_reference,
+ # })
+
def _compute_related_count(self):
for record in self:
record.related_count = len(record.picking_lines)
diff --git a/fixco_custom/views/stock_picking.xml b/fixco_custom/views/stock_picking.xml
index 5095333..cc1fca1 100755
--- a/fixco_custom/views/stock_picking.xml
+++ b/fixco_custom/views/stock_picking.xml
@@ -46,6 +46,7 @@
<field name="tracking_number" readonly="1"/>
<field name="invoice_number" readonly="1"/>
<field name="invoice_mp" readonly="1"/>
+ <field name="shipment_group_id" readonly="1"/>
<field name="channel" readonly="1"/>
<field name="ginee_task_id" readonly="1"/>
<field name="pdf_label_url" readonly="1" widget="url"/>
@@ -63,7 +64,7 @@
<field name="ginee_pickup_time_id" readonly="1"/>
</group>
</group>
-
+
<field name="location_id" position="after">
<field name="carrier"/>
<field name="shipment_group_id"/>
@@ -89,7 +90,7 @@
filter_domain="['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('invoice_mp', 'ilike', self)]"/>
</field>
</field>
- </record>
+ </record>
<record id="stock_picking_shipment_group_ir_actions_server" model="ir.actions.server">
<field name="name">Shipment Group</field>
@@ -98,7 +99,7 @@
<field name="state">code</field>
<field name="code">action = records.open_form_shipment_group()</field>
</record>
-
+
<record id="stock_picking_print_picking_list_ir_actions_server" model="ir.actions.server">
<field name="name">Print Picking List</field>
<field name="model_id" ref="stock.model_stock_picking"/>
@@ -152,4 +153,4 @@
</data>
-</odoo> \ No newline at end of file
+</odoo>