summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-06-15 10:23:20 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-06-15 10:23:20 +0700
commit080bdd7d1283509e55a0af2459c8e12b7519c0eb (patch)
treebc0fbe2b27f67e2f1a767a8cac9a94e295a36353 /indoteknik_custom/models
parentac997ef851c9e1ce6d061a68951051f0b916b534 (diff)
change request uang muka purchase order
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order.py8
-rw-r--r--indoteknik_custom/models/purchase_order_multi_uangmuka.py37
-rw-r--r--indoteknik_custom/models/purchase_order_multi_uangmuka2.py18
-rw-r--r--indoteknik_custom/models/uangmuka_pembelian.py11
5 files changed, 62 insertions, 13 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 13d8f0b4..e6fefe2a 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -116,3 +116,4 @@ from . import external_api
from . import ged
from . import account_move_multi_update_bills
from . import def_cargo
+from . import purchase_order_multi_uangmuka2
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 5d28e5a1..16fb7cf8 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -58,6 +58,7 @@ class PurchaseOrder(models.Model):
approval_edit_line = fields.Boolean(string='Approval Edit Line', tracking=3)
sale_order = fields.Char(string='Sale Order')
matches_so = fields.Many2many('sale.order', string='Matches SO', compute='_compute_matches_so')
+ is_create_uangmuka = fields.Boolean(string='Uang Muka?')
def _compute_matches_so(self):
for po in self:
@@ -132,6 +133,13 @@ class PurchaseOrder(models.Model):
}
return action
+ def open_form_multi_create_uang_muka2(self):
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka')
+ action['context'] = {
+ 'po_ids': self.id
+ }
+ return action
+
def action_multi_update_paid_status(self):
for purchase in self:
purchase.update({
diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka.py b/indoteknik_custom/models/purchase_order_multi_uangmuka.py
index feb13cbc..3ab3a050 100644
--- a/indoteknik_custom/models/purchase_order_multi_uangmuka.py
+++ b/indoteknik_custom/models/purchase_order_multi_uangmuka.py
@@ -23,7 +23,22 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
for o in self:
o.total_amt = o.pay_amt + o.ongkir_amt + o.selisih_amt
- def create_uangmukapembelian(self, orders):
+ def create_uangmukapembelianselected(self):
+ po_ids = self._context['po_ids']
+ orders = self.env['purchase.order'].browse(po_ids)
+ po_is_uangmuka = self.env['purchase.order'].search([
+ ('id', 'in', [x.id for x in orders]),
+ ('is_create_uangmuka', '=', True)
+ ])
+
+ for rec in orders:
+ if rec.is_create_uangmuka:
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka2')
+ action['context'] = {
+ 'order_ids': [data.id for data in po_is_uangmuka]
+ }
+ return action
+
if not self.account_id:
raise UserError('Bank Intransit harus diisi')
if not self.env.user.has_group('account.group_account_manager'):
@@ -52,6 +67,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
account_move = self.env['account.move'].create([param_header])
debit_entries = []
pay_amt = 0
+
for order in orders:
_logger.info('Success Create Uang Muka Pembelian %s' % account_move.name)
@@ -61,7 +77,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
param_debit = {
'move_id': account_move.id,
'account_id': 401, # uang muka persediaan barang dagang
- 'partner_id': partner_id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': order.amount_total,
'credit': 0,
@@ -96,6 +112,8 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
if is_have_selisih:
debit_entries.append(param_debit_selisih)
pay_amt += self.selisih_amt
+
+ order.is_create_uangmuka = True
param_credit = {
'move_id': account_move.id,
@@ -112,12 +130,6 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
# Create all account.move.line entries at once
self.env['account.move.line'].create(debit_entries)
- return account_move.id
-
- def save_multi_create_uang_muka(self):
- po_ids = self._context['po_ids']
- purchase = self.env['purchase.order'].browse(po_ids)
- account_move = self.create_uangmukapembelian(purchase)
return {
'name': _('Journal Entries'),
'view_mode': 'form',
@@ -125,5 +137,10 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
'target': 'current',
'view_id': False,
'type': 'ir.actions.act_window',
- 'res_id': account_move
- } \ No newline at end of file
+ 'res_id': account_move.id
+ }
+
+ # def save_multi_create_uang_muka(self):
+
+ # account_move = self.create_uangmukapembelianselected(purchase, is_create_uangmuka)
+ \ No newline at end of file
diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka2.py b/indoteknik_custom/models/purchase_order_multi_uangmuka2.py
new file mode 100644
index 00000000..56539c5f
--- /dev/null
+++ b/indoteknik_custom/models/purchase_order_multi_uangmuka2.py
@@ -0,0 +1,18 @@
+from odoo import fields, models, _, api
+from odoo.exceptions import UserError
+from datetime import datetime
+from odoo.http import request
+
+import logging, math
+
+_logger = logging.getLogger(__name__)
+
+
+class PurchaseOrderMultiUangmuka2(models.TransientModel):
+ _name = 'purchase.order.multi_uangmuka2'
+
+ def redirect_to_po(self):
+ po_ids = self._context['order_ids']
+ purchase = self.env['purchase.order'].browse(po_ids)
+ purchase.is_create_uangmuka = False
+ return purchase.open_form_multi_create_uang_muka2() \ No newline at end of file
diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py
index e3ce4a20..3ae8d3fb 100644
--- a/indoteknik_custom/models/uangmuka_pembelian.py
+++ b/indoteknik_custom/models/uangmuka_pembelian.py
@@ -24,8 +24,6 @@ class UangmukaPembelian(models.TransientModel):
o.total_amt = o.pay_amt + o.ongkir_amt + o.selisih_amt
def create_uangmukapembelian(self):
- if self.pay_amt <= 0:
- raise UserError('Payment Amount harus diisi')
if not self.account_id:
raise UserError('Bank Intransit harus diisi')
if not self.env.user.is_accounting:
@@ -41,6 +39,12 @@ class UangmukaPembelian(models.TransientModel):
is_have_selisih = True
for order in orders:
+ if order.is_create_uangmuka == True:
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka2')
+ action['context'] = {
+ 'order_ids': [x.id for x in order]
+ }
+ return action
partner_name = order.partner_id.name
if order.partner_id.parent_id:
partner_name = order.partner_id.parent_id.name
@@ -95,7 +99,7 @@ class UangmukaPembelian(models.TransientModel):
'credit': self.pay_amt + self.ongkir_amt + self.selisih_amt,
'name': ref_label,
}
- if is_have_ongkir and is_have_selisih:
+ if is_have_ongkir and is_have_selisih:
request.env['account.move.line'].create([param_debit, param_debit_ongkir, param_debit_selisih, param_credit])
elif is_have_ongkir:
request.env['account.move.line'].create([param_debit, param_debit_ongkir, param_credit])
@@ -103,6 +107,7 @@ class UangmukaPembelian(models.TransientModel):
request.env['account.move.line'].create([param_debit, param_debit_selisih, param_credit])
else:
request.env['account.move.line'].create([param_debit, param_credit])
+ order.is_create_uangmuka = True
return {
'name': _('Journal Entries'),
'view_mode': 'form',