summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-06-10 14:30:21 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-06-10 14:30:21 +0700
commitaf45ca3aa0864d22014657e91bcc942fa5df8d3e (patch)
tree71f917770e08ebb6089095279fb12698560ac007
parent5f5753dbec8af518dd34821820462cd6340a2a08 (diff)
parent05dafe1ab837cac8992d1dc6c012a26bce88c15c (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
-rwxr-xr-xindoteknik_custom/models/sale_order.py42
-rwxr-xr-xindoteknik_custom/views/x_manufactures.xml40
2 files changed, 71 insertions, 11 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 705d16ef..baa8207f 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -2091,11 +2091,22 @@ class SaleOrder(models.Model):
# @api.depends('commitment_date')
def _compute_ready_to_ship_status_detail(self):
+ def is_empty(val):
+ """Helper untuk cek data kosong yang umum di Odoo."""
+ return val is None or val == "" or val == [] or val == {}
+
for order in self:
+ order.ready_to_ship_status_detail = 'On Track' # Default value
+
+ # Skip if no commitment date
+ if is_empty(order.commitment_date):
+ continue
+
eta = order.commitment_date
match_lines = self.env['purchase.order.sales.match'].search([
('sale_id', '=', order.id)
])
+
if match_lines:
for match in match_lines:
po = match.purchase_order_id
@@ -2104,20 +2115,31 @@ class SaleOrder(models.Model):
('order_id', '=', po.id),
('product_id', '=', product.id)
], limit=1)
+
+ if is_empty(po_line):
+ continue
+
stock_move = self.env['stock.move'].search([
('purchase_line_id', '=', po_line.id)
], limit=1)
+
+ if is_empty(stock_move) or is_empty(stock_move.picking_id):
+ continue
+
picking_in = stock_move.picking_id
- result_date = picking_in.date_done if picking_in else None
- if result_date:
- status = "Early" if result_date < eta else "Delay"
- result_date_str = result_date.strftime('%m/%d/%Y')
- eta_str = eta.strftime('%m/%d/%Y')
- order.ready_to_ship_status_detail = f"Expected: {eta_str} | Realtime: {result_date_str} | {status}"
- else:
- order.ready_to_ship_status_detail = "On Track"
- else:
- order.ready_to_ship_status_detail = 'On Track'
+ result_date = picking_in.date_done
+
+ if is_empty(result_date):
+ continue
+
+ try:
+ if result_date < eta:
+ order.ready_to_ship_status_detail = f"Early (Actual: {result_date.strftime('%m/%d/%Y')})"
+ else:
+ order.ready_to_ship_status_detail = f"Delay (Actual: {result_date.strftime('%m/%d/%Y')})"
+ except Exception as e:
+ _logger.error(f"Error computing ready to ship status: {str(e)}")
+ continue
def write(self, vals):
diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml
index 01e90a1e..02061251 100755
--- a/indoteknik_custom/views/x_manufactures.xml
+++ b/indoteknik_custom/views/x_manufactures.xml
@@ -3,7 +3,7 @@
<record id="x_manufactures_action" model="ir.actions.act_window">
<field name="name">Manufacture</field>
<field name="res_model">x_manufactures</field>
- <field name="view_mode">tree,form</field>
+ <field name="view_mode">kanban,tree,form</field> <!-- Tambahkan kanban di sini -->
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add Manufactures!
@@ -11,6 +11,44 @@
</field>
</record>
+ <record id="x_manufactures_kanban" model="ir.ui.view">
+ <field name="name">Manufactures Kanban</field>
+ <field name="model">x_manufactures</field>
+ <field name="arch" type="xml">
+ <kanban default_group_by="x_manufacture_level">
+ <field name="id"/> <!-- Tambahkan ini -->
+ <field name="x_name"/>
+ <field name="x_logo_manufacture"/>
+ <field name="x_manufacture_level"/>
+ <templates>
+ <t t-name="kanban-box">
+ <div class="oe_kanban_global_click">
+ <div class="o_kanban_image">
+ <img t-if="record.x_logo_manufacture.raw_value"
+ t-att-src="kanban_image('x_manufactures', 'x_logo_manufacture', record.id.raw_value)"
+ alt="Logo" class="img-fluid" width="64" height="64"/>
+ <img t-else=""
+ src="/web/static/src/img/placeholder.png"
+ alt="No Logo" class="img-fluid" width="64" height="64"/>
+ </div>
+ <div class="o_kanban_details">
+ <strong><field name="x_name"/></strong>
+ <div>
+ <span class="badge badge-secondary">
+ <field name="x_manufacture_level"/>
+ </span>
+ </div>
+ <div t-if="record.x_short_desc.raw_value">
+ <small><field name="x_short_desc"/></small>
+ </div>
+ </div>
+ </div>
+ </t>
+ </templates>
+ </kanban>
+ </field>
+ </record>
+
<record id="x_manufactures_tree" model="ir.ui.view">
<field name="name">Manufactures</field>
<field name="model">x_manufactures</field>