summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/mrp_production.py17
-rw-r--r--indoteknik_custom/views/mrp_production.xml2
2 files changed, 17 insertions, 2 deletions
diff --git a/indoteknik_custom/models/mrp_production.py b/indoteknik_custom/models/mrp_production.py
index 54d90256..0bf98702 100644
--- a/indoteknik_custom/models/mrp_production.py
+++ b/indoteknik_custom/models/mrp_production.py
@@ -6,5 +6,18 @@ class MrpProduction(models.Model):
_inherit = 'mrp.production'
desc = fields.Text(string='Description')
-
- \ No newline at end of file
+ sale_order = fields.Many2one('sale.order', string='Sale Order', required=True, copy=False)
+
+ def action_confirm(self):
+ """Override action_confirm untuk mengirim pesan ke Sale Order jika state berubah menjadi 'confirmed'."""
+ if self._name != 'mrp.production':
+ return super(MrpProduction, self).action_confirm()
+
+ result = super(MrpProduction, self).action_confirm()
+
+ for record in self:
+ if record.sale_order and record.state == 'confirmed':
+ message = _("Manufacturing order telah dibuat dengan nomor %s") % (record.name)
+ record.sale_order.message_post(body=message)
+
+ return result \ No newline at end of file
diff --git a/indoteknik_custom/views/mrp_production.xml b/indoteknik_custom/views/mrp_production.xml
index f81d65e8..95f419f6 100644
--- a/indoteknik_custom/views/mrp_production.xml
+++ b/indoteknik_custom/views/mrp_production.xml
@@ -7,6 +7,7 @@
<field name="arch" type="xml">
<field name="bom_id" position="after">
<field name="desc"/>
+ <field name="sale_order"/>
</field>
</field>
</record>
@@ -18,6 +19,7 @@
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="desc"/>
+ <field name="sale_order"/>
</field>
</field>
</record>