summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-10 16:54:57 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-10 16:54:57 +0700
commite1a19093f74222251280bf598a6256d6766dc4a2 (patch)
tree30bd46d13c69388f72fbedb9e3399af3819c5032 /indoteknik_custom/models
parentb12be84e1f8f4b0082a4c77e25b3dc68434b1ebc (diff)
add reklas for uang muka penjualan
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/invoice_reklas.py58
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
3 files changed, 61 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index d7d3e03c..4b9d4545 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -41,3 +41,4 @@ from . import purchase_outstanding
from . import sales_outstanding
from . import customer_review
from . import website_content
+from . import invoice_reklas
diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py
new file mode 100644
index 00000000..7c29ebca
--- /dev/null
+++ b/indoteknik_custom/models/invoice_reklas.py
@@ -0,0 +1,58 @@
+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 InvoiceReklas(models.TransientModel):
+ _name = 'invoice.reklas'
+ _description = "digunakan untuk reklas Uang Muka Penjualan"
+ reklas_id = fields.Many2one('account.move', string='Nomor CAB')
+ pay_amt = fields.Float(string='Yang dibayarkan')
+
+ def create_reklas(self):
+ if not self.reklas_id:
+ raise UserError('Nomor CAB harus diisi')
+ invoices = self.env['account.move'].browse(self._context.get('active_ids', []))
+ current_time = datetime.now()
+ for invoice in invoices:
+
+ parameters_header = {
+ 'ref': 'REKLAS '+self.reklas_id.name+" UANG MUKA PENJUALAN "+invoice.name+" "+invoice.partner_id.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,
+ 'partner_id': invoice.partner_id.id,
+ 'currency_id': 12,
+ 'debit': self.pay_amt,
+ 'credit': 0
+ }
+ 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
+ }
+ 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/sale_order.py b/indoteknik_custom/models/sale_order.py
index e7b28c6d..c8937ca4 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -235,6 +235,8 @@ class SaleOrder(models.Model):
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
for order in self:
+ if order.warehouse_id.id != 8: #GD Bandengan
+ raise UserError('Gudang harus Bandengan')
if not order.sales_tax_id:
raise UserError("Tax di Header harus diisi")
if not order.carrier_id: