summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-06 13:12:51 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-06 13:12:51 +0700
commit38b28cfb316a1abf62f192ce03f938c70f21f1fb (patch)
tree2be84b9182aeb4e18e943b2eac75c0cdd9598a06 /indoteknik_custom/models
parent89d4e9c8df4babbaa8daccdf4a6f77fee8a06123 (diff)
multiple reklas
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/account_move.py17
-rw-r--r--indoteknik_custom/models/invoice_reklas.py48
-rw-r--r--indoteknik_custom/models/invoice_reklas_penjualan.py79
4 files changed, 145 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index e7bcd323..509fceef 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -95,3 +95,4 @@ from . import stock_warehouse_orderpoint
from . import commision
from . import sale_advance_payment_inv
from . import purchase_order_multi_update
+from . import invoice_reklas_penjualan
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 82a86a39..929d2ee6 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -35,6 +35,23 @@ class AccountMove(models.Model):
('belum_upload', 'Belum Upload FP'),
('sudah_upload', 'Sudah Upload FP'),
], 'Mark Upload Faktur', compute='_compute_mark_upload_efaktur', default='belum_upload')
+ reklas_id = fields.Many2one('account.move', string='Nomor CAB', domain="[('partner_id', '=', partner_id)]")
+
+ def open_form_multi_create_reklas_penjualan(self):
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_view_invoice_reklas_penjualan')
+ invoice = self.env['invoice.reklas.penjualan'].create([{
+ 'name': '-',
+ }])
+ for move in self:
+ self.env['invoice.reklas.penjualan.line'].create([{
+ 'invoice_reklas_id': invoice.id,
+ 'name': move.name,
+ 'partner_id': move.partner_id.id,
+ 'amount_untaxed_signed': move.amount_untaxed_signed,
+ 'amount_total_signed': move.amount_total_signed,
+ }])
+ action['res_id'] = invoice.id
+ return action
def _compute_mark_upload_efaktur(self):
for move in self:
diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py
index c2ee7e3d..b1ba49e8 100644
--- a/indoteknik_custom/models/invoice_reklas.py
+++ b/indoteknik_custom/models/invoice_reklas.py
@@ -94,3 +94,51 @@ class InvoiceReklas(models.TransientModel):
'type': 'ir.actions.act_window',
'res_id': account_move.id
}
+
+
+ def create_reklas_penjualan(self):
+ if not self.pay_amt:
+ raise UserError('Yang dibayarkan harus diisi')
+
+ account_ids = self._context['account_ids']
+ invoices = self.env['account.move'].browse(account_ids)
+ current_time = datetime.now()
+ for invoice in invoices:
+ ref_name = 'REKLAS '+invoice.reklas_id.name+" UANG MUKA PENJUALAN "+invoice.name+" "+invoice.partner_id.name
+ parameters_header = {
+ 'ref': ref_name,
+ 'date': current_time,
+ 'journal_id': 13
+ }
+
+ account_move = request.env['account.move'].create([parameters_header])
+ _logger.info('Success Reklas with %s' % account_move.name)
+
+ parameter_debit = {
+ 'move_id': account_move.id,
+ 'account_id': 449, # uang muka penjualan
+ 'partner_id': invoice.partner_id.id,
+ 'currency_id': 12,
+ 'debit': self.pay_amt,
+ 'credit': 0,
+ 'name': ref_name
+ }
+ parameter_credit = {
+ 'move_id': account_move.id,
+ 'account_id': 395,
+ 'partner_id': invoice.partner_id.id,
+ 'currency_id': 12,
+ 'debit': 0,
+ 'credit': self.pay_amt,
+ 'name': ref_name
+ }
+ request.env['account.move.line'].create([parameter_debit, parameter_credit])
+ return {
+ 'name': _('Journal Entries'),
+ 'view_mode': 'form',
+ 'res_model': 'account.move',
+ 'target': 'current',
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ 'res_id': account_move.id
+ }
diff --git a/indoteknik_custom/models/invoice_reklas_penjualan.py b/indoteknik_custom/models/invoice_reklas_penjualan.py
new file mode 100644
index 00000000..22417864
--- /dev/null
+++ b/indoteknik_custom/models/invoice_reklas_penjualan.py
@@ -0,0 +1,79 @@
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError
+from datetime import datetime
+from odoo.http import request
+
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class InvoiceReklasPenjualan(models.TransientModel):
+ _name = 'invoice.reklas.penjualan'
+ _description = "digunakan untuk reklas Uang Muka Penjualan"
+
+ name = fields.Char(string='Name')
+ invoice_reklas_line = fields.One2many('invoice.reklas.penjualan.line', 'invoice_reklas_id', string='Invoice Reklas Line')
+
+ def create_reklas_penjualan(self):
+ # invoices = self.invoice_reklas_line.mapped('invoice_id')
+ invoices = self.invoice_reklas_line
+
+ current_time = datetime.now()
+ account_move_ids = []
+ for invoice in invoices:
+ ref_name = 'REKLAS ' + invoice.reklas_id.name + " UANG MUKA PENJUALAN " + invoice.name + " " + invoice.partner_id.name
+ parameters_header = {
+ 'ref': ref_name,
+ 'date': current_time,
+ 'journal_id': 13
+ }
+
+ account_move = self.env['account.move'].create([parameters_header])
+ _logger.info('Success Reklas with %s' % account_move.name)
+
+ parameter_debit = {
+ 'move_id': account_move.id,
+ 'account_id': 449, # uang muka penjualan
+ 'partner_id': invoice.partner_id.id,
+ 'currency_id': 12,
+ 'debit': invoice.pay_amt,
+ 'credit': 0,
+ 'name': ref_name
+ }
+ parameter_credit = {
+ 'move_id': account_move.id,
+ 'account_id': 395,
+ 'partner_id': invoice.partner_id.id,
+ 'currency_id': 12,
+ 'debit': 0,
+ 'credit': invoice.pay_amt,
+ 'name': ref_name
+ }
+ self.env['account.move.line'].create([parameter_debit, parameter_credit])
+ account_move_ids.append(account_move.id)
+ invoice.unlink()
+
+ self.unlink()
+ return {
+ 'name': _('Journal Entries'),
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.move',
+ 'target': 'current',
+ 'type': 'ir.actions.act_window',
+ 'domain': [('id', 'in', account_move_ids)],
+ }
+
+class InvoiceReklasPenjualanLine(models.TransientModel):
+ _name = 'invoice.reklas.penjualan.line'
+ _description = "digunakan untuk reklas Uang Muka Penjualan"
+
+ invoice_reklas_id = fields.Many2one('invoice.reklas.penjualan', string='Invoice Reklas')
+ pay_amt = fields.Float(string='Yang dibayarkan')
+ reklas_id = fields.Many2one('account.move', string='Nomor CAB', domain="[('partner_id', '=', partner_id)]")
+ amount_untaxed_signed = fields.Float(string='Tax excluded')
+ amount_total_signed = fields.Float(string='Total')
+ name = fields.Char(string='Name')
+ partner_id = fields.Many2one('res.partner', string='Partner')
+
+