1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
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': 668, # 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="[('sale_id', '=', sale_id)]")
sale_id = fields.Many2one('sale.order', string='Sale Order')
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')
|