From 01f308991afffaff5eda1b758dbb98d0f3ba8396 Mon Sep 17 00:00:00 2001
From: Azka Nathan
Date: Tue, 26 Sep 2023 15:06:52 +0700
Subject: User can't create data cab on form input, add multi update data sale
order to update state and invoice_status
---
indoteknik_custom/models/purchase_order.py | 2 +-
indoteknik_custom/models/sale_order.py | 23 +++++++++++++++++++++++
indoteknik_custom/views/invoice_reklas.xml | 2 +-
indoteknik_custom/views/sale_order.xml | 18 ++++++++++++++++++
4 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index daf8d269..08f38afe 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -324,7 +324,7 @@ class PurchaseOrder(models.Model):
def re_calculate(self):
for line in self.order_line:
sale_order_line = self.env['sale.order.line'].search([
- ('product_id', '=', line.product_id.id),
+ ('id', '=', line.so_line_id.id),
('order_id', '=', line.order_id.sale_order_id.id)
], limit=1, order='price_reduce_taxexcl')
for so_line in sale_order_line:
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 2d8d97bd..13f4745d 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -80,6 +80,29 @@ class SaleOrder(models.Model):
estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0)
email = fields.Char(string='Email')
+ @api.model
+ def action_multi_update_state(self):
+ order_ids = self.env.context.get('active_ids', [])
+ sale_order = self.search([('id', 'in', order_ids)])
+ for sale in sale_order:
+ sale.update({
+ 'state': 'cancel',
+ })
+
+ if sale.state == 'cancel':
+ sale.update({
+ 'approval_status': False,
+ })
+
+ @api.model
+ def action_multi_update_invoice_status(self):
+ order_ids = self.env.context.get('active_ids', [])
+ sale_order = self.search([('id', 'in', order_ids)])
+ for sale in sale_order:
+ sale.update({
+ 'invoice_status': 'invoiced',
+ })
+
def _compute_purchase_total(self):
for order in self:
total = 0
diff --git a/indoteknik_custom/views/invoice_reklas.xml b/indoteknik_custom/views/invoice_reklas.xml
index e807dca5..a29139ad 100644
--- a/indoteknik_custom/views/invoice_reklas.xml
+++ b/indoteknik_custom/views/invoice_reklas.xml
@@ -10,7 +10,7 @@
-
+