1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# ShineERP, Enterprise Management Solution
5
# Copyright (C) 2007-2012 ShineERP Co.,ltd (<http://www.erp.mn>). All Rights Reserved
7
# Address : Suhkbaatar District, National ITPark, ShineERP LLC
9
# Phone : 976 + 11-318043
11
##############################################################################
13
from osv import osv,fields,orm
14
from tools.translate import _
17
class account_bank_statement_line(osv.osv):
18
_inherit = 'account.bank.statement.line'
21
'cash_move_type': fields.many2one('account.cash.move.type', 'Cash Move Type')
23
def print_cash_order(self, cr, uid, ids, context={}):
24
''' Кассын орлогын баримт, зарлагын баримт хэвлэх
30
line = self.browse(cr, uid, ids[0], context=context)
31
context.update({'active_ids':ids,'active_id':ids[0]})
33
if line.amount > 0 : # Орлогын баримт
35
'type': 'ir.actions.report.xml',
36
'report_name': 'cash.statement.line.income',
41
else : # Зарлагын баримт
43
'type': 'ir.actions.report.xml',
44
'report_name': 'cash.statement.line.expense',
50
account_bank_statement_line()
52
class account_bank_statement(osv.osv):
53
_inherit = 'account.bank.statement'
55
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
59
res_currency_obj = self.pool.get('res.currency')
60
account_move_obj = self.pool.get('account.move')
61
account_move_line_obj = self.pool.get('account.move.line')
62
account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
63
st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context)
64
st = st_line.statement_id
66
context.update({'date': st_line.date})
68
move_id = account_move_obj.create(cr, uid, {
69
'journal_id': st.journal_id.id,
70
'period_id': st.period_id.id,
72
'name': st_line_number,
75
account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
76
'move_ids': [(4, move_id, False)]
80
if st_line.amount >= 0:
81
account_id = st.journal_id.default_credit_account_id.id
83
account_id = st.journal_id.default_debit_account_id.id
85
acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
87
'res.currency.compute.account': acc_cur,
89
amount = res_currency_obj.compute(cr, uid, st.currency.id,
90
company_currency_id, st_line.amount, context=context)
97
'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
98
'account_id': (st_line.account_id) and st_line.account_id.id,
99
'credit': ((amount>0) and amount) or 0.0,
100
'debit': ((amount<0) and -amount) or 0.0,
101
'statement_id': st.id,
102
'journal_id': st.journal_id.id,
103
'period_id': st.period_id.id,
104
# 'currency_id': st.currency.id,
105
'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
108
if st.currency.id <> company_currency_id:
109
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
110
st.currency.id, amount, context=context)
111
val['amount_currency'] = -amount_cur
113
if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
114
val['currency_id'] = st_line.account_id.currency_id.id
115
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
116
st_line.account_id.currency_id.id, amount, context=context)
117
val['amount_currency'] = -amount_cur
119
move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
121
torec.append(move_line_id)
123
# Fill the secondary amount/currency
124
# if currency is not the same than the company
125
amount_currency = False
127
if st.currency.id <> company_currency_id:
128
amount_currency = st_line.amount
129
currency_id = st.currency.id
130
account_move_line_obj.create(cr, uid, {
131
'name': st_line.name,
132
'date': st_line.date,
135
'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
136
'account_id': account_id,
137
'credit': ((amount < 0) and -amount) or 0.0,
138
'debit': ((amount > 0) and amount) or 0.0,
139
'statement_id': st.id,
140
'journal_id': st.journal_id.id,
141
'period_id': st.period_id.id,
142
'amount_currency': amount_currency,
143
#'currency_id': currency_id,
144
'cash_move_type': st_line.cash_move_type.id # Мөнгөн гүйлгээний төрөл
146
# Мөнгөн гүйлгээний зөв төрөл сонгосон эсэхийг шалгана
147
if st_line.cash_move_type and st_line.cash_move_type.group <> 'dummy':
148
if amount > 0 and st_line.cash_move_type.group not in ('activities_income','investing_income','financing_income'):
149
raise osv.except_osv(_('Integrity Error!'), _('You have selected wrong cash move type. Please to point in transaction amount sign!'))
150
elif amount < 0 and st_line.cash_move_type.group not in ('activities_expense','investing_expense','financing_expense'):
151
raise osv.except_osv(_('Integrity Error!'), _('You have selected wrong cash move type. Please to point in transaction amount sign!'))
153
for line in account_move_line_obj.browse(cr, uid, [x.id for x in
154
account_move_obj.browse(cr, uid, move_id,
155
context=context).line_id],
157
if line.state <> 'valid':
158
raise osv.except_osv(_('Error !'),
159
_('Journal item "%s" is not valid.') % line.name)
161
# Bank statements will not consider boolean on journal entry_posted
162
account_move_obj.post(cr, uid, [move_id], context=context)
165
account_bank_statement()
167
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'