[FIX] Account Voucher
bzr revid: fp@tinyerp.com-20110927130730-1jr4uxos5lbst2ub
This commit is contained in:
parent
5dfc14d359
commit
6391bf5173
|
@ -722,8 +722,6 @@ class account_journal(osv.osv):
|
|||
name = rs.name
|
||||
if rs.currency:
|
||||
name = "%s (%s)" % (rs.name, rs.currency.name)
|
||||
else:
|
||||
name = "%s (%s)" % (rs.name, rs.company_id.currency_id.name)
|
||||
res += [(rs.id, name)]
|
||||
return res
|
||||
|
||||
|
@ -932,17 +930,10 @@ class account_period(osv.osv):
|
|||
return False
|
||||
|
||||
def find(self, cr, uid, dt=None, context=None):
|
||||
if context is None: context = {}
|
||||
if not dt:
|
||||
dt = time.strftime('%Y-%m-%d')
|
||||
#CHECKME: shouldn't we check the state of the period?
|
||||
args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)]
|
||||
if context.get('company_id', False):
|
||||
args.append(('company_id', '=', context['company_id']))
|
||||
else:
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||
args.append(('company_id', '=', company_id))
|
||||
ids = self.search(cr, uid, args, context=context)
|
||||
ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)])
|
||||
if not ids:
|
||||
raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create one.')%dt)
|
||||
return ids
|
||||
|
|
|
@ -234,7 +234,6 @@
|
|||
<field name="payment_ids" colspan="4" nolabel="1" >
|
||||
<tree string="Payments">
|
||||
<field name="date" string="Payment Date"/>
|
||||
<field name="move_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="name" groups="base.group_extended"/>
|
||||
<field name="journal_id"/>
|
||||
|
@ -333,7 +332,6 @@
|
|||
<field name="payment_ids" colspan="4" nolabel="1">
|
||||
<tree string="Payments">
|
||||
<field name="date"/>
|
||||
<field name="move_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id" groups="base.group_user"/>
|
||||
|
|
|
@ -718,7 +718,7 @@ class account_move_line(osv.osv):
|
|||
)
|
||||
return cr.fetchone()
|
||||
|
||||
def reconcile_partial(self, cr, uid, ids, type='auto', context=None):
|
||||
def reconcile_partial(self, cr, uid, ids, type='auto', context=None, writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False):
|
||||
move_rec_obj = self.pool.get('account.move.reconcile')
|
||||
merges = []
|
||||
unmerge = []
|
||||
|
@ -747,7 +747,7 @@ class account_move_line(osv.osv):
|
|||
unmerge.append(line.id)
|
||||
total += (line.debit or 0.0) - (line.credit or 0.0)
|
||||
if self.pool.get('res.currency').is_zero(cr, uid, company_currency_id, total):
|
||||
res = self.reconcile(cr, uid, merges+unmerge, context=context)
|
||||
res = self.reconcile(cr, uid, merges+unmerge, context=context, writeoff_acc_id=writeoff_acc_id, writeoff_period_id=writeoff_period_id, writeoff_journal_id=writeoff_journal_id)
|
||||
return res
|
||||
r_id = move_rec_obj.create(cr, uid, {
|
||||
'type': type,
|
||||
|
@ -812,7 +812,7 @@ class account_move_line(osv.osv):
|
|||
if (not currency_obj.is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \
|
||||
(account.currency_id and (not currency_obj.is_zero(cr, uid, account.currency_id, currency))):
|
||||
if not writeoff_acc_id:
|
||||
raise osv.except_osv(_('Warning'), _('You have to provide an account for the write off entry !'))
|
||||
raise osv.except_osv(_('Warning'), _('You have to provide an account for the write off/exchange difference entry !'))
|
||||
if writeoff > 0:
|
||||
debit = writeoff
|
||||
credit = 0.0
|
||||
|
@ -1249,7 +1249,7 @@ class account_move_line(osv.osv):
|
|||
break
|
||||
# Automatically convert in the account's secondary currency if there is one and
|
||||
# the provided values were not already multi-currency
|
||||
if account.currency_id and 'amount_currency' not in vals and account.currency_id.id != account.company_id.currency_id.id:
|
||||
if account.currency_id and not vals.get('ammount_currency') and account.currency_id.id != account.company_id.currency_id.id:
|
||||
vals['currency_id'] = account.currency_id.id
|
||||
ctx = {}
|
||||
if 'date' in vals:
|
||||
|
|
|
@ -209,7 +209,7 @@ class account_invoice(osv.osv):
|
|||
\n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \
|
||||
\n* The \'Paid\' state is set automatically when invoice is paid.\
|
||||
\n* The \'Cancelled\' state is used when user cancel invoice.'),
|
||||
'date_invoice': fields.date('Invoice Date', readonly=True, states={'draft':[('readonly',False)]}, select=True, help="Keep empty to use the current date"),
|
||||
'date_invoice': fields.date('Invoice Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True, help="Keep empty to use the current date"),
|
||||
'date_due': fields.date('Due Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True,
|
||||
help="If you use payment terms, the due date will be computed automatically at the generation "\
|
||||
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."),
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import account_voucher
|
||||
import company
|
||||
import invoice
|
||||
import report
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -25,22 +25,15 @@
|
|||
"author" : 'OpenERP SA',
|
||||
'complexity': "normal",
|
||||
"description": """
|
||||
Account Voucher module offers an easy way to deal with all the basic requirements of Voucher Entries
|
||||
====================================================================================================
|
||||
Account Voucher module includes all the basic requirements of Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc.
|
||||
====================================================================================================================================
|
||||
|
||||
Its increased usabililty allows you to create easily sales/purchases documents but also to encode payments.
|
||||
Doing so, you'll be able to see all the open transactions for the selected partner and that will help you
|
||||
to reconcile your entry with its invoice.
|
||||
|
||||
Account Voucher module multi-currency support
|
||||
=============================================
|
||||
|
||||
Thanks to the contribution of Camptocamp, the vouchers fully support the multi currency and compute the
|
||||
currency rate difference besides the write off amount. Of course, the accounting entries are also created
|
||||
accordingly.
|
||||
* Voucher Entry
|
||||
* Voucher Receipt
|
||||
* Cheque Register
|
||||
""",
|
||||
"category" : "Finance",
|
||||
"website" : "http://www.openerp.com",
|
||||
"website" : "http://tinyerp.com",
|
||||
"images" : ["images/customer_payment.jpeg","images/journal_voucher.jpeg","images/sales_receipt.jpeg","images/supplier_voucher.jpeg"],
|
||||
"depends" : ["account"],
|
||||
"init_xml" : [],
|
||||
|
@ -55,7 +48,6 @@ accordingly.
|
|||
"wizard/account_voucher_unreconcile_view.xml",
|
||||
"wizard/account_statement_from_invoice_view.xml",
|
||||
"account_voucher_view.xml",
|
||||
"company_view.xml",
|
||||
"voucher_payment_receipt_view.xml",
|
||||
"voucher_sales_purchase_view.xml",
|
||||
"account_voucher_wizard.xml",
|
||||
|
@ -67,12 +59,7 @@ accordingly.
|
|||
"test/account_voucher.yml",
|
||||
"test/sales_receipt.yml",
|
||||
"test/sales_payment.yml",
|
||||
"test/account_voucher_report.yml",
|
||||
"test/case1_usd_usd.yml",
|
||||
"test/case2_usd_eur.yml",
|
||||
"test/case2_suppl_usd_eur.yml",
|
||||
"test/case3_eur_eur.yml",
|
||||
"test/case4_cad_chf.yml",
|
||||
"test/account_voucher_report.yml"
|
||||
],
|
||||
'certificate': '0037580727101',
|
||||
"active": False,
|
||||
|
|
|
@ -39,10 +39,7 @@ class account_voucher(osv.osv):
|
|||
if context is None: context = {}
|
||||
if context.get('period_id', False):
|
||||
return context.get('period_id')
|
||||
if context.get('invoice_id', False):
|
||||
company_id = self.pool.get('account.invoice').browse(cr, uid, context['invoice_id'], context=context).company_id.id
|
||||
context.update({'company_id': company_id})
|
||||
periods = self.pool.get('account.period').find(cr, uid, context=context)
|
||||
periods = self.pool.get('account.period').find(cr, uid)
|
||||
return periods and periods[0] or False
|
||||
|
||||
def _get_journal(self, cr, uid, context=None):
|
||||
|
@ -92,7 +89,9 @@ class account_voucher(osv.osv):
|
|||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||
# currency_id = journal.company_id.currency_id.id
|
||||
if journal.currency:
|
||||
print 'Default', journal.currency.id
|
||||
return journal.currency.id
|
||||
print 'Default', False
|
||||
return False
|
||||
|
||||
def _get_partner(self, cr, uid, context=None):
|
||||
|
@ -145,102 +144,39 @@ class account_voucher(osv.osv):
|
|||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def _check_paid(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
ok = True
|
||||
for line in voucher.move_ids:
|
||||
if (line.account_id.type, 'in', ('receivable', 'payable')) and not line.reconcile_id:
|
||||
ok = False
|
||||
res[voucher.id] = ok
|
||||
return res
|
||||
|
||||
def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount, voucher_date, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
ctx = context.copy()
|
||||
voucher_type = context.get('type', False)
|
||||
counter_for_writeoff = counter_for_currency_diff = real_amount = 0.0
|
||||
ctx.update({'date': voucher_date})
|
||||
def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
|
||||
debit = credit = 0.0
|
||||
for l in line_dr_ids:
|
||||
#compute the amount in voucher currency and in company currency if there aren't set yet
|
||||
if not l.get('amount_in_company_currency', False):
|
||||
ctx.update({'date': l['date_original']})
|
||||
amount_in_company_currency = currency_pool.compute(cr, uid, l['currency_id'], l['company_currency_id'], l['amount'], context=ctx)
|
||||
ctx.update({'date': voucher_date})
|
||||
else:
|
||||
amount_in_company_currency = l.get('amount_in_company_currency', 0.0)
|
||||
if not l.get('amount_in_voucher_currency'):
|
||||
amount_in_voucher_currency = currency_pool.compute(cr, uid, l['currency_id'], l['voucher_currency_id'], l['amount'], context=ctx)
|
||||
else:
|
||||
amount_in_voucher_currency = l.get('amount_in_voucher_currency', 0.0)
|
||||
real_amount -= amount_in_company_currency
|
||||
counter_for_writeoff -= l.get('voucher_currency_id') == l.get('currency_id') and l['amount'] or amount_in_voucher_currency
|
||||
counter_for_currency_diff -= currency_pool.compute(cr, uid, l['currency_id'], l['company_currency_id'], l['amount'], context=ctx)
|
||||
debit += l['amount']
|
||||
for l in line_cr_ids:
|
||||
#compute the amount in voucher currency and in company currency if there aren't set yet
|
||||
if not l.get('amount_in_company_currency', False):
|
||||
ctx.update({'date': l['date_original']})
|
||||
amount_in_company_currency = currency_pool.compute(cr, uid, l['currency_id'], l['company_currency_id'], l['amount'], context=ctx)
|
||||
ctx.update({'date': voucher_date})
|
||||
else:
|
||||
amount_in_company_currency = l.get('amount_in_company_currency', 0.0)
|
||||
if not l.get('amount_in_voucher_currency'):
|
||||
amount_in_voucher_currency = currency_pool.compute(cr, uid, l['currency_id'], l['voucher_currency_id'], l['amount'], context=ctx)
|
||||
else:
|
||||
amount_in_voucher_currency = l.get('amount_in_voucher_currency', 0.0)
|
||||
real_amount += amount_in_company_currency
|
||||
counter_for_writeoff += l.get('voucher_currency_id') == l.get('currency_id') and l['amount'] or amount_in_voucher_currency
|
||||
counter_for_currency_diff += currency_pool.compute(cr, uid, l['currency_id'], l['company_currency_id'], l['amount'], context=ctx)
|
||||
sign = voucher_type in ['sale','receipt'] and 1 or -1
|
||||
writeoff_amount = (sign * amount) - counter_for_writeoff
|
||||
currency_rate_difference = real_amount - counter_for_currency_diff
|
||||
return writeoff_amount, currency_rate_difference
|
||||
credit += l['amount']
|
||||
return abs(amount - abs(credit - debit))
|
||||
|
||||
def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_date, context=None):
|
||||
def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, context=None):
|
||||
context = context or {}
|
||||
if not line_dr_ids and not line_cr_ids:
|
||||
return {'value':{}}
|
||||
line_osv = self.pool.get("account.voucher.line")
|
||||
line_dr_ids = resolve_o2m_operations(cr, uid, line_osv, line_dr_ids, ['amount'], context)
|
||||
line_cr_ids = resolve_o2m_operations(cr, uid, line_osv, line_cr_ids, ['amount'], context)
|
||||
writeoff_amount, currency_rate_diff = self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount, voucher_date, context=context)
|
||||
return {'value': {'writeoff_amount': writeoff_amount, 'currency_rate_difference': currency_rate_diff}}
|
||||
return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}}
|
||||
|
||||
def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None):
|
||||
if not ids: return {}
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}.fromkeys(ids,{})
|
||||
counter_for_writeoff = counter_for_currency_diff = real_amount = 0.0
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
ctx = context.copy()
|
||||
ctx.update({'date': voucher.date})
|
||||
for l in voucher.line_dr_ids:
|
||||
real_amount -= l.amount_in_company_currency
|
||||
counter_for_writeoff -= (l.voucher_currency_id.id == l.currency_id.id) and l.amount or l.amount_in_voucher_currency
|
||||
counter_for_currency_diff -= currency_pool.compute(cr, uid, l.currency_id.id, voucher.company_id.currency_id.id, l.amount, context=ctx)
|
||||
for l in voucher.line_cr_ids:
|
||||
real_amount += l.amount_in_company_currency
|
||||
counter_for_writeoff += (l.voucher_currency_id.id == l.currency_id.id) and l.amount or l.amount_in_voucher_currency
|
||||
counter_for_currency_diff += currency_pool.compute(cr, uid, l.currency_id.id, voucher.company_id.currency_id.id, l.amount, context=ctx)
|
||||
sign = voucher.type in ['sale','receipt'] and 1 or -1
|
||||
writeoff_amount = (sign * voucher.amount) - counter_for_writeoff
|
||||
res[voucher.id]['writeoff_amount'] = writeoff_amount
|
||||
res[voucher.id]['currency_rate_difference'] = real_amount - counter_for_currency_diff
|
||||
return res
|
||||
|
||||
def _currency_id(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
debit = credit = 0.0
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
currency = voucher.journal_id.currency and voucher.journal_id.currency.id or voucher.company_id.currency_id.id
|
||||
res[voucher.id] = {'currency_id': currency, 'currency_id2': currency}
|
||||
for l in voucher.line_dr_ids:
|
||||
debit += l.amount
|
||||
for l in voucher.line_cr_ids:
|
||||
credit += l.amount
|
||||
res[voucher.id] = abs(voucher.amount - abs(credit - debit))
|
||||
return res
|
||||
|
||||
_name = 'account.voucher'
|
||||
_description = 'Accounting Voucher'
|
||||
_order = "date desc, id desc"
|
||||
# _rec_name = 'number'
|
||||
_columns = {
|
||||
'type':fields.selection([
|
||||
('sale','Sale'),
|
||||
|
@ -250,7 +186,7 @@ class account_voucher(osv.osv):
|
|||
],'Default Type', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'date':fields.date('Date', readonly=True, select=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"),
|
||||
'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}, change_default=1),
|
||||
'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'line_cr_ids':fields.one2many('account.voucher.line','voucher_id','Credits',
|
||||
|
@ -259,13 +195,11 @@ class account_voucher(osv.osv):
|
|||
domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'narration':fields.text('Notes', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'currency_id': fields.function(_currency_id, type='many2one', relation='res.currency', string='Currency', store=True, readonly=True, multi="currency"),
|
||||
#duplicated field for display purposes
|
||||
'currency_id2': fields.function(_currency_id, type='many2one', relation='res.currency', string='Currency', store=True, readonly=True, multi="currency"),
|
||||
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
|
||||
'company_currency': fields.related('company_id','currency_id', type='many2one', relation='res.currency', string='Currency', readonly=True),
|
||||
# 'currency_id':fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'currency_id': fields.related('journal_id','currency', type='many2one', relation='res.currency', string='Currency', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'state':fields.selection(
|
||||
[('draft','New'),
|
||||
[('draft','Draft'),
|
||||
('proforma','Pro-forma'),
|
||||
('posted','Posted'),
|
||||
('cancel','Cancelled')
|
||||
|
@ -291,14 +225,13 @@ class account_voucher(osv.osv):
|
|||
'date_due': fields.date('Due Date', readonly=True, select=True, states={'draft':[('readonly',False)]}),
|
||||
'payment_option':fields.selection([
|
||||
('without_writeoff', 'Keep Open'),
|
||||
('with_writeoff', 'Reconcile'),
|
||||
('with_writeoff', 'Reconcile Payment Balance'),
|
||||
], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'comment': fields.char('Write-Off Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'exchange_acc_id': fields.many2one('account.account', 'Exchange Diff. Account', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'writeoff_acc_id': fields.many2one('account.account', 'Counterpart Account', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'comment': fields.char('Counterpart Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'writeoff_amount': fields.function(_get_writeoff_amount, string='Write-Off Amount', type='float', readonly=True, multi="writeoff"),
|
||||
'currency_rate_difference': fields.function(_get_writeoff_amount, string="Currency Rate Difference", type='float', multi="writeoff"),
|
||||
'paid': fields.function(_check_paid, string='Paid', type='boolean', help="The Voucher has been totally paid."),
|
||||
'writeoff_amount': fields.function(_get_writeoff_amount, string='Reconcile Amount', type='float', readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'period_id': _get_period,
|
||||
|
@ -323,7 +256,7 @@ class account_voucher(osv.osv):
|
|||
tax_pool = self.pool.get('account.tax')
|
||||
partner_pool = self.pool.get('res.partner')
|
||||
position_pool = self.pool.get('account.fiscal.position')
|
||||
voucher_voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
voucher_line_pool = self.pool.get('account.voucher.line')
|
||||
voucher_pool = self.pool.get('account.voucher')
|
||||
if context is None: context = {}
|
||||
|
||||
|
@ -332,7 +265,7 @@ class account_voucher(osv.osv):
|
|||
for line in voucher.line_ids:
|
||||
voucher_amount += line.untax_amount or line.amount
|
||||
line.amount = line.untax_amount or line.amount
|
||||
voucher_voucher_line_obj.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
|
||||
voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
|
||||
|
||||
if not voucher.tax_id:
|
||||
self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
|
||||
|
@ -360,7 +293,7 @@ class account_voucher(osv.osv):
|
|||
line_total += tax_line.get('price_unit')
|
||||
total_tax += line_tax
|
||||
untax_amount = line.untax_amount or line.amount
|
||||
voucher_voucher_line_obj.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount})
|
||||
voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount})
|
||||
|
||||
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
|
||||
return True
|
||||
|
@ -370,14 +303,14 @@ class account_voucher(osv.osv):
|
|||
tax_pool = self.pool.get('account.tax')
|
||||
partner_pool = self.pool.get('res.partner')
|
||||
position_pool = self.pool.get('account.fiscal.position')
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
line_pool = self.pool.get('account.voucher.line')
|
||||
res = {
|
||||
'tax_amount': False,
|
||||
'amount': False,
|
||||
}
|
||||
voucher_total = 0.0
|
||||
|
||||
line_ids = resolve_o2m_operations(cr, uid, voucher_line_obj, line_ids, ["amount"], context)
|
||||
line_ids = resolve_o2m_operations(cr, uid, line_pool, line_ids, ["amount"], context)
|
||||
|
||||
total = 0.0
|
||||
total_tax = 0.0
|
||||
|
@ -466,8 +399,8 @@ class account_voucher(osv.osv):
|
|||
|
||||
return default
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, voucher_currency_id, ttype, date, context=None):
|
||||
"""price
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
|
||||
"""
|
||||
Returns a dict that contains new values and context
|
||||
|
||||
@param partner_id: latest value from user input for field partner_id
|
||||
|
@ -476,36 +409,43 @@ class account_voucher(osv.osv):
|
|||
|
||||
@return: Returns a dict which contains new values, and context
|
||||
"""
|
||||
if not journal_id:
|
||||
return {}
|
||||
if context is None:
|
||||
context = {}
|
||||
if not journal_id:
|
||||
return {}
|
||||
context_multi_currency = context.copy()
|
||||
if date:
|
||||
context_multi_currency.update({'date': date})
|
||||
|
||||
line_pool = self.pool.get('account.voucher.line')
|
||||
line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False
|
||||
if line_ids:
|
||||
line_pool.unlink(cr, uid, line_ids)
|
||||
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
partner_pool = self.pool.get('res.partner')
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
voucher_line_obj = self.pool.get('account.voucher.line')
|
||||
#get default values
|
||||
vals = self.onchange_journal(cr, uid, ids, journal_id, [], False, partner_id, context=context)
|
||||
vals = vals.get('value',{})
|
||||
voucher_currency_id = vals.get('currency_id', voucher_currency_id)
|
||||
default = {
|
||||
'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False, 'currency_id': voucher_currency_id},
|
||||
}
|
||||
|
||||
#drop existing lines
|
||||
line_ids = ids and voucher_line_obj.search(cr, uid, [('voucher_id', 'in', ids)]) or []
|
||||
if line_ids:
|
||||
voucher_line_obj.unlink(cr, uid, line_ids, context=context)
|
||||
vals = self.onchange_journal(cr, uid, ids, journal_id, [], False, partner_id, context)
|
||||
vals = vals.get('value')
|
||||
|
||||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||
currency_id = vals.get('currency_id', currency_id)
|
||||
default = {
|
||||
'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False, 'currency_id':currency_id},
|
||||
}
|
||||
currency_id = currency_id or journal.company_id.currency_id.id
|
||||
|
||||
if not partner_id:
|
||||
return default
|
||||
|
||||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||
if not partner_id and ids:
|
||||
line_ids = line_pool.search(cr, uid, [('voucher_id', '=', ids[0])])
|
||||
if line_ids:
|
||||
line_pool.unlink(cr, uid, line_ids)
|
||||
return default
|
||||
|
||||
partner = partner_pool.browse(cr, uid, partner_id, context=context)
|
||||
account_id = False
|
||||
if journal.type in ('sale','sale_refund'):
|
||||
|
@ -520,98 +460,72 @@ class account_voucher(osv.osv):
|
|||
if journal.type not in ('cash', 'bank'):
|
||||
return default
|
||||
|
||||
total_credit = 0.0
|
||||
total_debit = 0.0
|
||||
account_type = 'receivable'
|
||||
if ttype == 'payment':
|
||||
account_type = 'payable'
|
||||
total_debit = price or 0.0
|
||||
else:
|
||||
total_credit = price or 0.0
|
||||
account_type = 'receivable'
|
||||
|
||||
if not context.get('move_line_ids', False):
|
||||
ids = move_line_obj.search(cr, uid, [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
|
||||
ids = move_line_pool.search(cr, uid, [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
|
||||
else:
|
||||
ids = context['move_line_ids']
|
||||
|
||||
#computation of the assignation of voucher amount on voucher lines
|
||||
total_credit = account_type == 'receivable' and price or 0.0
|
||||
total_debit = account_type == 'payable' and price or 0.0
|
||||
moves = move_line_obj.browse(cr, uid, ids, context=context)
|
||||
company_currency = journal.company_id.currency_id.id
|
||||
invoice_id = context.get('invoice_id', False)
|
||||
move_line_found = False
|
||||
#order the lines by most old first
|
||||
ids.reverse()
|
||||
moves = move_line_pool.browse(cr, uid, ids, context=context)
|
||||
|
||||
#company_currency = journal.company_id.currency_id.id
|
||||
#if company_currency != currency_id and ttype == 'payment':
|
||||
# total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
|
||||
#elif company_currency != currency_id and ttype == 'receipt':
|
||||
# total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
|
||||
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
if line.debit and line.reconcile_partial_id and ttype == 'payment':
|
||||
continue
|
||||
if invoice_id:
|
||||
if line.invoice.id == invoice_id:
|
||||
#if the invoice linked to the voucher line is equal to the invoice_id in context
|
||||
#then we assign the amount on that line, whatever the other voucher lines
|
||||
move_line_found = line.id
|
||||
break
|
||||
elif voucher_currency_id == company_currency:
|
||||
#otherwise treatments is the same but with other field names
|
||||
if line.amount_residual == price:
|
||||
#if the amount residual is equal the amount voucher, we assign it to that voucher
|
||||
#line, whatever the other voucher lines
|
||||
move_line_found = line.id
|
||||
break
|
||||
#otherwise we will split the voucher amount on each line (by most old first)
|
||||
total_credit += line.credit or 0.0
|
||||
total_debit += line.debit or 0.0
|
||||
elif voucher_currency_id == line.currency_id.id:
|
||||
if line.amount_residual_currency == price:
|
||||
move_line_found = line.id
|
||||
break
|
||||
total_credit += line.credit and line.amount_currency or 0.0
|
||||
total_debit += line.debit and line.amount_currency or 0.0
|
||||
|
||||
#voucher line creation
|
||||
total_credit += line.credit or 0.0
|
||||
total_debit += line.debit or 0.0
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
if line.debit and line.reconcile_partial_id and ttype == 'payment':
|
||||
continue
|
||||
original_amount = line.credit or line.debit or 0.0
|
||||
amount_original, amount_unreconciled = voucher_line_obj._get_amounts(cr, uid, line, context=context)
|
||||
currency_id = line.currency_id and line.currency_id.id or line.company_id.currency_id.id
|
||||
|
||||
if line.currency_id and currency_id==line.currency_id.id:
|
||||
amount_original = abs(line.amount_currency)
|
||||
amount_unreconciled = abs(line.amount_residual_currency)
|
||||
else:
|
||||
company_currency = journal.company_id.currency_id.id
|
||||
amount_original = currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or line.debit or 0.0)
|
||||
amount_unreconciled = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual))
|
||||
|
||||
#original_amount = line.credit or line.debit or 0.0
|
||||
#amount_unreconciled = currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, abs(line.amount_residual_currency), context=context_multi_currency)
|
||||
rs = {
|
||||
'name':line.move_id.name,
|
||||
'type': line.credit and 'dr' or 'cr',
|
||||
'move_line_id':line.id,
|
||||
'account_id':line.account_id.id,
|
||||
'amount_original': amount_original,
|
||||
'amount': (move_line_found == line.id) and min(price, amount_unreconciled) or 0.0,
|
||||
'currency_id': currency_id,
|
||||
'voucher_currency_id': voucher_currency_id,
|
||||
'date_original':line.date,
|
||||
'company_currency_id': line.company_id.currency_id.id,
|
||||
'date_due':line.date_maturity,
|
||||
'amount_unreconciled': amount_unreconciled,
|
||||
|
||||
}
|
||||
#split voucher amount by most old first
|
||||
if not move_line_found:
|
||||
if company_currency == voucher_currency_id:
|
||||
if line.credit:
|
||||
amount = min(amount_unreconciled, abs(total_debit))
|
||||
rs['amount'] = amount
|
||||
total_debit -= amount
|
||||
else:
|
||||
amount = min(amount_unreconciled, abs(total_credit))
|
||||
rs['amount'] = amount
|
||||
total_credit -= amount
|
||||
elif voucher_currency_id == line.currency_id.id:
|
||||
if line.credit:
|
||||
amount = min(amount_unreconciled, abs(total_debit))
|
||||
rs['amount'] = amount
|
||||
total_debit -= amount
|
||||
else:
|
||||
amount = min(amount_unreconciled, abs(total_credit))
|
||||
rs['amount'] = amount
|
||||
total_credit -= amount
|
||||
|
||||
if line.credit:
|
||||
amount = min(amount_unreconciled, total_debit)
|
||||
rs['amount'] = amount
|
||||
total_debit -= amount
|
||||
else:
|
||||
amount = min(amount_unreconciled, total_credit)
|
||||
rs['amount'] = amount
|
||||
total_credit -= amount
|
||||
|
||||
default['value']['line_ids'].append(rs)
|
||||
if rs['type'] == 'cr':
|
||||
|
@ -623,7 +537,8 @@ class account_voucher(osv.osv):
|
|||
default['value']['pre_line'] = 1
|
||||
elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
|
||||
default['value']['pre_line'] = 1
|
||||
default['value']['writeoff_amount'], default['value']['currency_rate_difference'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price, date, context=context)
|
||||
default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
|
||||
print default
|
||||
return default
|
||||
|
||||
def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
|
||||
|
@ -633,13 +548,9 @@ class account_voucher(osv.osv):
|
|||
@param context: context arguments, like lang, time zone
|
||||
@return: Returns a dict which contains new values, and context
|
||||
"""
|
||||
if context is None: context = {}
|
||||
period_pool = self.pool.get('account.period')
|
||||
res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
|
||||
if context.get('invoice_id', False):
|
||||
company_id = self.pool.get('account.invoice').browse(cr, uid, context['invoice_id'], context=context).company_id.id
|
||||
context.update({'company_id': company_id})
|
||||
pids = period_pool.find(cr, uid, date, context=context)
|
||||
pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)])
|
||||
if pids:
|
||||
if not 'value' in res:
|
||||
res['value'] = {}
|
||||
|
@ -647,9 +558,8 @@ class account_voucher(osv.osv):
|
|||
return res
|
||||
|
||||
def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None):
|
||||
if context is None: context = {}
|
||||
if not journal_id:
|
||||
return {}
|
||||
return False
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||
account_id = journal.default_credit_account_id or journal.default_debit_account_id
|
||||
|
@ -659,14 +569,11 @@ class account_voucher(osv.osv):
|
|||
|
||||
vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
|
||||
vals['value'].update({'tax_id':tax_id})
|
||||
currency_id = journal.company_id.currency_id.id
|
||||
currency_id = False #journal.company_id.currency_id.id
|
||||
if journal.currency:
|
||||
currency_id = journal.currency.id
|
||||
vals['value'].update({'currency_id':currency_id})
|
||||
context.update({'company_id': journal.company_id.id})
|
||||
periods = self.pool.get('account.period').find(cr, uid, context=context)
|
||||
if periods:
|
||||
vals['value'].update({'period_id':periods[0]})
|
||||
print 'oc_journal', vals['value']
|
||||
return vals
|
||||
|
||||
def proforma_voucher(self, cr, uid, ids, context=None):
|
||||
|
@ -707,9 +614,10 @@ class account_voucher(osv.osv):
|
|||
def unlink(self, cr, uid, ids, context=None):
|
||||
for t in self.read(cr, uid, ids, ['state'], context=context):
|
||||
if t['state'] not in ('draft', 'cancel'):
|
||||
raise osv.except_osv(_('Invalid action !'), _('In order to delete a voucher, you must cancel it!'))
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
|
||||
return super(account_voucher, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
# TODO: may be we can remove this method if not used anyware
|
||||
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
|
||||
res = {}
|
||||
if not partner_id:
|
||||
|
@ -730,7 +638,6 @@ class account_voucher(osv.osv):
|
|||
return {'value':res}
|
||||
|
||||
def action_move_line_create(self, cr, uid, ids, context=None):
|
||||
|
||||
def _get_payment_term_lines(term_id, amount):
|
||||
term_pool = self.pool.get('account.payment.term')
|
||||
if term_id and amount:
|
||||
|
@ -740,44 +647,49 @@ class account_voucher(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
move_pool = self.pool.get('account.move')
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
if voucher.move_id:
|
||||
for inv in self.browse(cr, uid, ids, context=context):
|
||||
if inv.move_id:
|
||||
continue
|
||||
context_multi_currency = context.copy()
|
||||
context_multi_currency.update({'date': voucher.date})
|
||||
context_multi_currency.update({'date': inv.date})
|
||||
|
||||
if voucher.number:
|
||||
name = voucher.number
|
||||
if inv.number:
|
||||
name = inv.number
|
||||
elif inv.journal_id.sequence_id:
|
||||
name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
|
||||
else:
|
||||
name = seq_obj.get_id(cr, uid, voucher.journal_id.sequence_id.id)
|
||||
if not voucher.reference:
|
||||
raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
|
||||
if not inv.reference:
|
||||
ref = name.replace('/','')
|
||||
else:
|
||||
ref = voucher.reference
|
||||
ref = inv.reference
|
||||
|
||||
move = {
|
||||
'name': name,
|
||||
'journal_id': voucher.journal_id.id,
|
||||
'narration': voucher.narration,
|
||||
'date': voucher.date,
|
||||
'journal_id': inv.journal_id.id,
|
||||
'narration': inv.narration,
|
||||
'date': inv.date,
|
||||
'ref': ref,
|
||||
'period_id': voucher.period_id and voucher.period_id.id or False
|
||||
'period_id': inv.period_id and inv.period_id.id or False
|
||||
}
|
||||
move_id = move_pool.create(cr, uid, move)
|
||||
|
||||
#create the first line manually
|
||||
company_currency = voucher.journal_id.company_id.currency_id.id
|
||||
voucher_currency = voucher.currency_id.id
|
||||
company_currency = inv.journal_id.company_id.currency_id.id
|
||||
current_currency = inv.currency_id.id or company_currency
|
||||
current_currency_obj = inv.currency_id or inv.journal_id.company_id.currency_id
|
||||
debit = 0.0
|
||||
credit = 0.0
|
||||
if voucher.type in ('purchase', 'payment'):
|
||||
credit = currency_pool.compute(cr, uid, voucher_currency, company_currency, voucher.amount, context=context_multi_currency)
|
||||
elif voucher.type in ('sale', 'receipt'):
|
||||
debit = currency_pool.compute(cr, uid, voucher_currency, company_currency, voucher.amount, context=context_multi_currency)
|
||||
# TODO: is there any other alternative then the voucher type ??
|
||||
# -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt
|
||||
if inv.type in ('purchase', 'payment'):
|
||||
credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
|
||||
elif inv.type in ('sale', 'receipt'):
|
||||
debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
|
||||
if debit < 0:
|
||||
credit = -debit
|
||||
debit = 0.0
|
||||
|
@ -785,71 +697,53 @@ class account_voucher(osv.osv):
|
|||
debit = -credit
|
||||
credit = 0.0
|
||||
sign = debit - credit < 0 and -1 or 1
|
||||
#create the first line of the voucher
|
||||
#create the first line of the voucher, the payment made
|
||||
move_line = {
|
||||
'name': voucher.name or '/',
|
||||
'name': inv.name or '/',
|
||||
'debit': debit,
|
||||
'credit': credit,
|
||||
'account_id': voucher.account_id.id,
|
||||
'account_id': inv.account_id.id,
|
||||
'move_id': move_id,
|
||||
'journal_id': voucher.journal_id.id,
|
||||
'period_id': voucher.period_id.id,
|
||||
'partner_id': voucher.partner_id.id,
|
||||
'currency_id': company_currency <> voucher_currency and voucher_currency or False,
|
||||
'amount_currency': company_currency <> voucher_currency and sign * voucher.amount or 0.0,
|
||||
'date': voucher.date,
|
||||
'date_maturity': voucher.date_due
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'partner_id': inv.partner_id.id,
|
||||
'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
'amount_currency': company_currency <> current_currency and sign * inv.amount or 0.0,
|
||||
'date': inv.date,
|
||||
'date_maturity': inv.date_due
|
||||
}
|
||||
move_line_obj.create(cr, uid, move_line)
|
||||
|
||||
#create the move line for the currency difference
|
||||
if voucher.currency_rate_difference:
|
||||
if voucher.currency_rate_difference > 0:
|
||||
account_id = voucher.company_id.property_expense_currency_exchange
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Warning'),_("Unable to create accounting entry for currency rate difference. You have to configure the field 'Expense Currency Rate' on the company! "))
|
||||
else:
|
||||
account_id = voucher.company_id.property_income_currency_exchange
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Warning'),_("Unable to create accounting entry for currency rate difference. You have to configure the field 'Income Currency Rate' on the company! "))
|
||||
|
||||
currency_diff_line = {
|
||||
'name': _('Currency Difference'),
|
||||
'debit': voucher.currency_rate_difference > 0 and voucher.currency_rate_difference or 0.0,
|
||||
'credit': voucher.currency_rate_difference < 0 and -voucher.currency_rate_difference or 0.0,
|
||||
'account_id': account_id.id,
|
||||
'move_id': move_id,
|
||||
'journal_id': voucher.journal_id.id,
|
||||
'period_id': voucher.period_id.id,
|
||||
'partner_id': voucher.partner_id.id,
|
||||
'date': voucher.date,
|
||||
'date_maturity': voucher.date_due
|
||||
}
|
||||
move_line_obj.create(cr, uid, currency_diff_line, context=context)
|
||||
|
||||
move_line_pool.create(cr, uid, move_line)
|
||||
rec_list_ids = []
|
||||
for line in voucher.line_ids:
|
||||
line_total = debit - credit
|
||||
if inv.type == 'sale':
|
||||
line_total = line_total - currency_pool.compute(cr, uid, current_currency, company_currency, inv.tax_amount, context=context_multi_currency)
|
||||
elif inv.type == 'purchase':
|
||||
line_total = line_total + currency_pool.compute(cr, uid, current_currency, company_currency, inv.tax_amount, context=context_multi_currency)
|
||||
|
||||
for line in inv.line_ids:
|
||||
#create one move line per voucher line where amount is not 0.0
|
||||
if not line.amount:
|
||||
continue
|
||||
#we check if the voucher line is fully paid or not and create a move line to balance the payment and initial invoice if needed
|
||||
if line.amount == line.amount_unreconciled:
|
||||
amount = line.move_line_id.amount_residual #residual amount in company currency
|
||||
amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
|
||||
amount_residual = line.move_line_id.amount_residual - amount #residual amount in company currency
|
||||
else:
|
||||
amount = line.amount_in_company_currency
|
||||
amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
|
||||
amount_residual = 0.0
|
||||
move_line = {
|
||||
'journal_id': voucher.journal_id.id,
|
||||
'period_id': voucher.period_id.id,
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'name': line.name or '/',
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'partner_id': voucher.partner_id.id,
|
||||
'currency_id': company_currency <> line.currency_id.id and line.currency_id.id or False,
|
||||
'partner_id': inv.partner_id.id,
|
||||
'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
|
||||
'quantity': 1,
|
||||
'credit': 0.0,
|
||||
'debit': 0.0,
|
||||
'date': voucher.date
|
||||
'date': inv.date
|
||||
}
|
||||
if amount < 0:
|
||||
amount = -amount
|
||||
|
@ -858,68 +752,97 @@ class account_voucher(osv.osv):
|
|||
else:
|
||||
line.type = 'dr'
|
||||
if (line.type=='dr'):
|
||||
line_total += amount
|
||||
move_line['debit'] = amount
|
||||
else:
|
||||
line_total -= amount
|
||||
move_line['credit'] = amount
|
||||
|
||||
if voucher.tax_id and voucher.type in ('sale', 'purchase'):
|
||||
if inv.tax_id and inv.type in ('sale', 'purchase'):
|
||||
move_line.update({
|
||||
'account_tax_id': voucher.tax_id.id,
|
||||
'account_tax_id': inv.tax_id.id,
|
||||
})
|
||||
if move_line.get('account_tax_id', False):
|
||||
tax_data = tax_obj.browse(cr, uid, [move_line['account_tax_id']], context=context)[0]
|
||||
if not (tax_data.base_code_id and tax_data.tax_code_id):
|
||||
raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))
|
||||
sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1
|
||||
move_line['amount_currency'] = company_currency <> line.currency_id.id and sign * line.amount or 0.0
|
||||
voucher_line = move_line_obj.create(cr, uid, move_line)
|
||||
move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or 0.0
|
||||
voucher_line = move_line_pool.create(cr, uid, move_line)
|
||||
rec_ids = [voucher_line, line.move_line_id.id]
|
||||
|
||||
# Change difference entry
|
||||
if amount_residual:
|
||||
if not inv.exchange_acc_id.id:
|
||||
raise osv.except_osv(_('Error!'), _('You must provide an account for the exchange difference.'))
|
||||
move_line = {
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'name': _('change')+': '+(line.name or '/'),
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'partner_id': inv.partner_id.id,
|
||||
'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
'amount_currency': 0.0,
|
||||
'quantity': 1,
|
||||
'credit': amount_residual > 0 and amount_residual or 0.0,
|
||||
'debit': amount_residual < 0 and -amount_residual or 0.0,
|
||||
'date': inv.date
|
||||
}
|
||||
new_id = move_line_pool.create(cr, uid, move_line)
|
||||
move_line = {
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'name': _('change')+': '+(line.name or '/'),
|
||||
'account_id': inv.exchange_acc_id.id,
|
||||
'move_id': move_id,
|
||||
'amount_currency': 0.0,
|
||||
'partner_id': inv.partner_id.id,
|
||||
'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
'quantity': 1,
|
||||
'debit': amount_residual > 0 and amount_residual or 0.0,
|
||||
'credit': amount_residual < 0 and -amount_residual or 0.0,
|
||||
'date': inv.date
|
||||
}
|
||||
move_line_pool.create(cr, uid, move_line)
|
||||
rec_ids.append(new_id)
|
||||
|
||||
if line.move_line_id.id:
|
||||
rec_ids = [voucher_line, line.move_line_id.id]
|
||||
rec_list_ids.append(rec_ids)
|
||||
|
||||
if not currency_pool.is_zero(cr, uid, voucher.currency_id, voucher.writeoff_amount):
|
||||
#create one line for the write off if needed
|
||||
diff = currency_pool.compute(cr, uid, voucher_currency, company_currency, voucher.writeoff_amount, context=context_multi_currency)
|
||||
if not currency_pool.is_zero(cr, uid, current_currency_obj, line_total):
|
||||
diff = line_total
|
||||
account_id = False
|
||||
write_off_name = ''
|
||||
|
||||
if voucher.payment_option == 'with_writeoff':
|
||||
account_id = voucher.writeoff_acc_id.id
|
||||
write_off_name = voucher.comment
|
||||
elif voucher.type in ('sale', 'receipt'):
|
||||
if not voucher.partner_id:
|
||||
account_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=',False)])
|
||||
else:
|
||||
account_id = voucher.partner_id.property_account_receivable.id
|
||||
if inv.payment_option == 'with_writeoff':
|
||||
account_id = inv.writeoff_acc_id.id
|
||||
write_off_name = inv.comment
|
||||
elif inv.type in ('sale', 'receipt'):
|
||||
account_id = inv.partner_id.property_account_receivable.id
|
||||
else:
|
||||
if not voucher.partner_id:
|
||||
account_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=',False)])
|
||||
else:
|
||||
account_id = voucher.partner_id.property_account_payable.id
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Error !'), _('No receivable/payable account defined in properties!'))
|
||||
account_id = inv.partner_id.property_account_payable.id
|
||||
move_line = {
|
||||
'name': write_off_name or name,
|
||||
'account_id': account_id,
|
||||
'move_id': move_id,
|
||||
'partner_id': voucher.partner_id.id,
|
||||
'date': voucher.date,
|
||||
'debit': diff < 0 and -diff or 0.0,
|
||||
'partner_id': inv.partner_id.id,
|
||||
'date': inv.date,
|
||||
'credit': diff > 0 and diff or 0.0,
|
||||
'amount_currency': company_currency <> voucher_currency and -voucher.writeoff_amount or 0.0,
|
||||
'currency_id': company_currency <> voucher_currency and voucher_currency or False,
|
||||
'debit': diff < 0 and -diff or 0.0,
|
||||
#'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1, context=context_multi_currency) or 0.0,
|
||||
#'currency_id': company_currency <> current_currency and current_currency or False,
|
||||
}
|
||||
move_line_obj.create(cr, uid, move_line)
|
||||
self.write(cr, uid, [voucher.id], {
|
||||
move_line_pool.create(cr, uid, move_line)
|
||||
self.write(cr, uid, [inv.id], {
|
||||
'move_id': move_id,
|
||||
'state': 'posted',
|
||||
'number': name,
|
||||
})
|
||||
if voucher.journal_id.entry_posted:
|
||||
if inv.journal_id.entry_posted:
|
||||
move_pool.post(cr, uid, [move_id], context={})
|
||||
for rec_ids in rec_list_ids:
|
||||
if len(rec_ids) >= 2:
|
||||
move_line_obj.reconcile_partial(cr, uid, rec_ids)
|
||||
move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=inv.exchange_acc_id.id, writeoff_period_id=inv.period_id.id, writeoff_journal_id=inv.journal_id.id)
|
||||
return True
|
||||
|
||||
def copy(self, cr, uid, id, default={}, context=None):
|
||||
|
@ -942,86 +865,45 @@ class account_voucher_line(osv.osv):
|
|||
_description = 'Voucher Lines'
|
||||
_order = "move_line_id"
|
||||
|
||||
def _currency_id(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
move_line = line.move_line_id
|
||||
if move_line:
|
||||
res[line.id] = move_line.currency_id and move_line.currency_id.id or move_line.company_id.currency_id.id
|
||||
else:
|
||||
res[line.id] = line.voucher_id.currency_id.id
|
||||
return res
|
||||
|
||||
def _get_amounts(self, cr, uid, line_browse_rec, context=None):
|
||||
if line_browse_rec.currency_id:
|
||||
amount_original = line_browse_rec.amount_currency or 0.0
|
||||
amount_unreconciled = line_browse_rec.amount_residual_currency
|
||||
elif line_browse_rec.credit > 0:
|
||||
amount_original = line_browse_rec.credit or 0.0
|
||||
amount_unreconciled = line_browse_rec.amount_residual
|
||||
else:
|
||||
amount_original = line_browse_rec.debit or 0.0
|
||||
amount_unreconciled = line_browse_rec.amount_residual
|
||||
return amount_original, amount_unreconciled
|
||||
|
||||
# If the payment is in the same currency than the invoice, we keep the same amount
|
||||
# Otherwise, we compute from company currency to payment currency
|
||||
def _compute_balance(self, cr, uid, ids, name, args, context=None):
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
res = {}
|
||||
rs_data = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
amount_original, amount_unreconciled = self._get_amounts(cr, uid, line.move_line_id, context)
|
||||
res[line.id] = {
|
||||
'amount_original': amount_original,
|
||||
'amount_unreconciled': amount_unreconciled,
|
||||
}
|
||||
ctx = context.copy()
|
||||
ctx.update({'date': line.voucher_id.date})
|
||||
res = {}
|
||||
company_currency = line.voucher_id.journal_id.company_id.currency_id.id
|
||||
voucher_currency = line.voucher_id.currency_id and line.voucher_id.currency_id.id or company_currency
|
||||
move_line = line.move_line_id or False
|
||||
|
||||
return res
|
||||
if not move_line:
|
||||
res['amount_original'] = 0.0
|
||||
res['amount_unreconciled'] = 0.0
|
||||
elif move_line.currency_id and voucher_currency==move_line.currency_id.id:
|
||||
res['amount_original'] = currency_pool.compute(cr, uid, move_line.currency_id.id, voucher_currency, abs(move_line.amount_currency), context=ctx)
|
||||
res['amount_unreconciled'] = currency_pool.compute(cr, uid, move_line.currency_id and move_line.currency_id.id or company_currency, voucher_currency, abs(move_line.amount_residual_currency), context=ctx)
|
||||
elif move_line and move_line.credit > 0:
|
||||
res['amount_original'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.credit, context=ctx)
|
||||
res['amount_unreconciled'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, abs(move_line.amount_residual), context=ctx)
|
||||
else:
|
||||
res['amount_original'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.debit, context=ctx)
|
||||
res['amount_unreconciled'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, abs(move_line.amount_residual), context=ctx)
|
||||
|
||||
def __company_currency_amount(self, cr, uid, line, amount, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
ctx = context.copy()
|
||||
ctx.update({'date': line.date_original})
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
amount_company_cur = currency_pool.compute(cr, uid, line.currency_id.id, line.company_currency_id.id, amount, context=ctx)
|
||||
ctx.update({'date': line.voucher_id.date})
|
||||
amount_voucher_cur = currency_pool.compute(cr, uid, line.currency_id.id, line.voucher_currency_id.id, amount, context=ctx)
|
||||
return amount_company_cur, amount_voucher_cur
|
||||
|
||||
def onchange_amount(self, cr, uid, ids, amount, context=None):
|
||||
if not amount or not ids:
|
||||
return {'value':{'amount_in_company_currency': 0.0, 'amount_in_voucher_currency': 0.0}}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
amount_company_cur, amount_voucher_cur = self.__company_currency_amount(cr, uid, line, amount, context=context)
|
||||
return {'value': {'amount_in_company_currency': amount_company_cur, 'amount_in_voucher_currency': amount_voucher_cur}}
|
||||
|
||||
def _get_amount_in_company_currency(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
amount_in_company_currency, amount_in_voucher_currency = self.__company_currency_amount(cr, uid, line, line.amount, context=context)
|
||||
res[line.id] = {
|
||||
'amount_in_company_currency': amount_in_company_currency,
|
||||
'amount_in_voucher_currency': amount_in_voucher_currency,
|
||||
}
|
||||
return res
|
||||
rs_data[line.id] = res
|
||||
return rs_data
|
||||
|
||||
_columns = {
|
||||
'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1, ondelete='cascade'),
|
||||
'move_line_id': fields.many2one('account.move.line', 'Journal Item'),
|
||||
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr'),
|
||||
'name':fields.char('Description', size=256),
|
||||
'account_id':fields.many2one('account.account','Account', required=True),
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'),
|
||||
'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
|
||||
'untax_amount':fields.float('Untax Amount'),
|
||||
|
||||
'currency_id': fields.function(_currency_id, string='Currency', type='many2one', relation='res.currency'),
|
||||
'company_currency_id': fields.related('move_line_id','company_id','currency_id', type='many2one', relation='res.currency', string="Company Currency"),
|
||||
'voucher_currency_id': fields.related('voucher_id', 'currency_id', type='many2one', relation='res.currency', string="Voucher Currency"),
|
||||
|
||||
'amount':fields.float('Amount', digits_compute=dp.get_precision('Account')),
|
||||
'amount_in_company_currency': fields.function(_get_amount_in_company_currency, string='Amount in Company Currency', type='float', digits_compute=dp.get_precision('Account'), multi="voucher_line_amount"),
|
||||
'amount_in_voucher_currency': fields.function(_get_amount_in_company_currency, string='Amount in Voucher Currency', type='float', digits_compute=dp.get_precision('Account'), multi="voucher_line_amount"),
|
||||
|
||||
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr'),
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'),
|
||||
'move_line_id': fields.many2one('account.move.line', 'Journal Item'),
|
||||
'date_original': fields.related('move_line_id','date', type='date', relation='account.move.line', string='Date', readonly=1),
|
||||
'date_due': fields.related('move_line_id','date_maturity', type='date', relation='account.move.line', string='Due Date', readonly=1),
|
||||
'amount_original': fields.function(_compute_balance, multi='dc', type='float', string='Original Amount', store=True),
|
||||
|
@ -1043,9 +925,9 @@ class account_voucher_line(osv.osv):
|
|||
@return: Returns a dict which contains new values, and context
|
||||
"""
|
||||
res = {}
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
if move_line_id:
|
||||
move_line = move_line_obj.browse(cr, user, move_line_id, context=context)
|
||||
move_line = move_line_pool.browse(cr, user, move_line_id, context=context)
|
||||
if move_line.credit:
|
||||
ttype = 'dr'
|
||||
else:
|
||||
|
@ -1120,7 +1002,7 @@ class account_bank_statement(osv.osv):
|
|||
bank_st_line_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
|
||||
if st_line.voucher_id:
|
||||
voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number, 'date': st_line.date}, context=context)
|
||||
voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context)
|
||||
if st_line.voucher_id.state == 'cancel':
|
||||
voucher_obj.action_cancel_draft(cr, uid, [st_line.voucher_id.id], context=context)
|
||||
wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
|
||||
|
@ -1130,7 +1012,7 @@ class account_bank_statement(osv.osv):
|
|||
'move_ids': [(4, v.move_id.id, False)]
|
||||
})
|
||||
|
||||
return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id, 'date': st_line.date}, update_check=False, context=context)
|
||||
return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
|
||||
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
|
||||
|
||||
account_bank_statement()
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_invoice_customer" model="ir.ui.view">
|
||||
<field name="name">account.invoice.customer.pay</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="invoice_open" position="after">
|
||||
<button name="invoice_pay_customer" type="object" string="Payment" states="open" icon="gtk-go-forward"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_invoice_supplier" model="ir.ui.view">
|
||||
<field name="name">account.invoice.supplier.pay</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="invoice_open" position="after">
|
||||
<button name="invoice_pay_customer" type="object" string="Pay Invoice" states="open" icon="gtk-go-forward"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_invoice_customer" model="ir.ui.view">
|
||||
<field name="name">account.invoice.customer.pay</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="invoice_open" position="after">
|
||||
<button name="invoice_pay_customer" type="object" string="Payment" states="open" icon="gtk-go-forward"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_invoice_supplier" model="ir.ui.view">
|
||||
<field name="name">account.invoice.supplier.pay</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="invoice_open" position="after">
|
||||
<button name="invoice_pay_customer" type="object" string="Pay Invoice" states="open" icon="gtk-go-forward"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<form string="Accounting Voucher">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
|
||||
<field name="date" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date, context)"/>
|
||||
<field name="date" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id" widget="selection" select="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
|
||||
<field name="type" required="1"/>
|
||||
<field name="name" colspan="2"/>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
class res_company(osv.osv):
|
||||
_inherit = "res.company"
|
||||
_columns = {
|
||||
'property_income_currency_exchange': fields.property(
|
||||
'account.account',
|
||||
type='many2one',
|
||||
relation='account.account',
|
||||
string="Income Currency Rate",
|
||||
view_load=True,
|
||||
domain="[('type', '=', 'other')]",),
|
||||
'property_expense_currency_exchange': fields.property(
|
||||
'account.account',
|
||||
type='many2one',
|
||||
relation='account.account',
|
||||
string="Expense Currency Rate",
|
||||
view_load=True,
|
||||
domain="[('type', '=', 'other')]",),
|
||||
}
|
||||
|
||||
res_company()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_company_inherit_currency_xchange_form">
|
||||
<field name="name">res.company.form.inherit</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name="model">res.company</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="currency_id" position="after">
|
||||
<field name="property_income_currency_exchange" colspan="2"/>
|
||||
<field name="property_expense_currency_exchange" colspan="2"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -45,11 +45,10 @@ class invoice(osv.osv):
|
|||
'close_after_process': True,
|
||||
'invoice_type':inv.type,
|
||||
'invoice_id':inv.id,
|
||||
'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
|
||||
'type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
|
||||
'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
|
||||
}
|
||||
}
|
||||
|
||||
invoice()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -73,7 +73,7 @@ class sale_receipt_report(osv.osv):
|
|||
to_char(av.date, 'MM') as month,
|
||||
to_char(av.date, 'YYYY-MM-DD') as day,
|
||||
av.partner_id as partner_id,
|
||||
av.currency_id as currency_id,
|
||||
aj.currency as currency_id,
|
||||
av.journal_id as journal_id,
|
||||
rp.user_id as user_id,
|
||||
av.company_id as company_id,
|
||||
|
@ -111,7 +111,7 @@ class sale_receipt_report(osv.osv):
|
|||
to_char(av.date, 'MM'),
|
||||
to_char(av.date, 'YYYY-MM-DD'),
|
||||
av.partner_id,
|
||||
av.currency_id,
|
||||
aj.currency,
|
||||
av.journal_id,
|
||||
rp.user_id,
|
||||
av.company_id,
|
||||
|
|
|
@ -1,355 +0,0 @@
|
|||
-
|
||||
In order to check the Account_voucher module with multi-currency in OpenERP,
|
||||
I create 2 Invoices in USD and make 2 Payments in USD based on the currency rating on that particular date
|
||||
-
|
||||
I create currency USD in OpenERP for January of 1.333333 Rate
|
||||
-
|
||||
!python {model: res.currency.rate}: |
|
||||
from datetime import datetime
|
||||
curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])
|
||||
date = '%s-01-01' %(datetime.now().year)
|
||||
ids = self.search(cr, uid, [('currency_id','=',curr_id), ('name', '=', date)])
|
||||
self.write(cr, uid, ids, {'rate': 1.333333})
|
||||
-
|
||||
I create currency USD in OpenERP for February of 1.250000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: feb_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
rate: 1.250000
|
||||
|
||||
-
|
||||
I create currency USD in OpenERP for March of 1.111111 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: mar_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-03-01' %(datetime.now().year)"
|
||||
rate: 1.111111
|
||||
|
||||
-
|
||||
I create currency USD in OpenERP for April of 1.052632 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: apr_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-04-01' %(datetime.now().year)"
|
||||
rate: 1.052632
|
||||
|
||||
-
|
||||
I create a bank journal with USD as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_USD}:
|
||||
name: Bank Journal(USD)
|
||||
code: BUSD
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.USD
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
|
||||
-
|
||||
I set up some accounts for currency rate expense/income in my company
|
||||
-
|
||||
!record {model: res.company, id: base.main_company}:
|
||||
property_expense_currency_exchange: account.o_expense
|
||||
property_income_currency_exchange: account.o_income
|
||||
-
|
||||
I create new partner Mark Strauss.
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_strauss0}:
|
||||
address:
|
||||
- city: paris
|
||||
country_id: base.fr
|
||||
name: Mark Strauss
|
||||
street: 1 rue Rockfeller
|
||||
type: invoice
|
||||
zip: '75016'
|
||||
name: Mr. Mark Strauss
|
||||
-
|
||||
I create the first invoice on 1st January for 200 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_jan}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 200.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_strauss0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_jan}
|
||||
-
|
||||
I check that first invoice move is correct for debtor account (debit - credit == 150.0)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account"
|
||||
-
|
||||
I create the second invoice on 1st February for 100 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_feb}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
period_id: account.period_2
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 100.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_strauss0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_feb}
|
||||
-
|
||||
I check that second invoice move is correct for debtor account (debit - credit == 80)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account"
|
||||
|
||||
-
|
||||
I create the first voucher of payment
|
||||
<create with values 240 USD, journal USD, and fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_strauss0"), ref('bank_journal_USD'), 240.00, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 240.00,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.USD'),
|
||||
'journal_id': ref('bank_journal_USD'),
|
||||
'partner_id': ref('res_partner_strauss0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-03-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'First payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 200.00:
|
||||
item['amount'] = 180.00
|
||||
else:
|
||||
item['amount'] = 70.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is -10.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
|
||||
-
|
||||
I check that currency rate difference is -34.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == -34.0), "Currency rate difference is not -34.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my first voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with -180 and -70 as amount_currency columns and that their credit columns are respectively 135 and 56
|
||||
-
|
||||
I check that my currency rate difference is correct. 34 in credit with no amount_currency
|
||||
-
|
||||
I check that my write-off is correct. 9 debit and 10 amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == -180.00:
|
||||
assert move_line.credit == 135.00, "Debtor account has wrong entry."
|
||||
elif move_line.amount_currency == -70.00:
|
||||
assert move_line.credit == 56.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 34.00:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect currency rate difference."
|
||||
elif move_line.amount_currency == 10.00:
|
||||
assert move_line.debit == 9.00, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 20 in amount_currency and 15 in company currency
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15.0) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 30.0 and move_line.amount_residual == 24.0) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I create the second voucher of payment
|
||||
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
|
||||
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_strauss0"), ref('bank_journal_USD'), 45.00, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 45.00,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.USD'),
|
||||
'journal_id': ref('bank_journal_USD'),
|
||||
'partner_id': ref('res_partner_strauss0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-04-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'Second payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 20.00:
|
||||
item['amount'] = 20.00
|
||||
else:
|
||||
item['amount'] = 30.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is -5.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0"
|
||||
-
|
||||
I check that currency rate difference is -8.50
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == -8.50), "Currency rate difference is not -8.50"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my second voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 15 and 24.
|
||||
-
|
||||
I check that my currency rate difference is correct. 8.5 in credit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. 4.75 debit and 5 amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == -20.00:
|
||||
assert move_line.credit == 15.00, "Debtor account has wrong entry."
|
||||
elif move_line.amount_currency == -30.00:
|
||||
assert move_line.credit == 24.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 8.50:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.amount_currency == 5.00:
|
||||
assert move_line.debit == 4.75, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
|
|
@ -1,328 +0,0 @@
|
|||
-
|
||||
In order to check the Account_voucher module with multi-currency in OpenERP,
|
||||
I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
|
||||
-
|
||||
I create a bank journal with EUR as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_EUR}:
|
||||
name: Bank Journal(EUR)
|
||||
code: BEUR
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.EUR
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I create a bank journal with USD as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_USD}:
|
||||
name: Bank Journal(USD)
|
||||
code: BUSD
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.USD
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I create a new partner Robert Clements
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_clements0}:
|
||||
address:
|
||||
- city: marseille
|
||||
country_id: base.fr
|
||||
name: Robert
|
||||
street: 1 rue Rockfeller
|
||||
type: invoice
|
||||
zip: '13016'
|
||||
name: Mr.Robert Clements
|
||||
-
|
||||
I create the first invoice on 1st January for 200 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_first_invoice_jan_suppl}:
|
||||
account_id: account.a_pay
|
||||
type : in_invoice
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_expense
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 200.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_clements0
|
||||
reference_type: none
|
||||
check_total : 200
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_suppl}
|
||||
-
|
||||
I check that first invoice move is correct for debtor account(debit - credit == -150)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == -150.00), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the second invoice on 1st February for 100 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_second_invoice_feb_suppl}:
|
||||
account_id: account.a_pay
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
period_id: account.period_2
|
||||
type : in_invoice
|
||||
invoice_line:
|
||||
- account_id: account.a_expense
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 100.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_clements0
|
||||
reference_type: none
|
||||
check_total : 100.0
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_suppl}
|
||||
-
|
||||
I check that second invoice move is correct for debtor account (debit - credit == -80)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == -80), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the first voucher of payment
|
||||
<create with values 240 EUR, journal EUR, and fills amount 180 for the invoice of 200$ and 70 for the invoice of 100$>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_clements0"), ref('bank_journal_EUR'), 240.0, 2, ttype='payment', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 240.0,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.EUR'),
|
||||
'journal_id': ref('bank_journal_EUR'),
|
||||
'partner_id': ref('res_partner_clements0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'payment',
|
||||
'date': time.strftime("%Y-03-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'First payment',
|
||||
}
|
||||
if not res['value']['line_dr_ids']:
|
||||
res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
|
||||
for item in res['value']['line_dr_ids']:
|
||||
if item['amount_unreconciled'] == 200.00:
|
||||
item['amount'] = 180.00
|
||||
else:
|
||||
item['amount'] = 70.00
|
||||
vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is -15.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == -15.0), "Writeoff amount is not -15.0"
|
||||
-
|
||||
I check that currency rate difference is 34.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == 34.0), "Currency rate difference is not 34.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my creditor account is correct
|
||||
-
|
||||
I check that the creditor account has 2 new lines with 180 and 70 in amount_currency columns and their debit columns are respectively 135 and 56 and currency is USD($).
|
||||
-
|
||||
I check that my currency rate difference is correct. -34 in credit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. -15 in credit with no amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == 180.00:
|
||||
assert move_line.debit == 135.00, "Creditor account has wrong entry."
|
||||
elif move_line.amount_currency == 70.00:
|
||||
assert move_line.debit == 56.00, "Debtor account has wrong entry."
|
||||
elif move_line.debit == 34.00:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.debit == 15.00:
|
||||
assert move_line.amount_currency == 0.00, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice"
|
||||
-
|
||||
I create the second voucher of payment
|
||||
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_clements0"), ref('bank_journal_EUR'), 45.0, 2, ttype='payment', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 45.0,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.USD'),
|
||||
'journal_id': ref('bank_journal_USD'),
|
||||
'partner_id': ref('res_partner_clements0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'payment',
|
||||
'date': time.strftime("%Y-04-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'Second payment',
|
||||
}
|
||||
if not res['value']['line_dr_ids']:
|
||||
res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
|
||||
for item in res['value']['line_dr_ids']:
|
||||
if item['amount_unreconciled'] == 20.00:
|
||||
item['amount'] = 20.00
|
||||
else:
|
||||
item['amount'] = 30.00
|
||||
vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is -5.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0"
|
||||
-
|
||||
I check that currency rate difference is 8.50
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == 8.50), "Currency rate difference is not 8.50"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that my voucher state is posted
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert voucher_id.state == 'posted', "Voucher state is not posted"
|
||||
-
|
||||
I check that my creditor account is correct
|
||||
-
|
||||
I check that the creditor account has 2 new lines with 20 and 30 in amount_currency columns and their debit columns are respectively 15 and 24 and currency is USD($).
|
||||
-
|
||||
I check that my currency rate difference is correct. 8.50 in debit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. 4.75 in credit and 5 in amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == 20.00:
|
||||
assert move_line.debit == 15.00, "Debtor account has wrong entry."
|
||||
elif move_line.amount_currency == 30.00:
|
||||
assert move_line.debit == 24.00, "Debtor account has wrong entry."
|
||||
elif move_line.debit == 8.50:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.amount_currency == -5.00:
|
||||
assert move_line.credit == 4.75, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
|
|
@ -1,360 +0,0 @@
|
|||
-
|
||||
In order to check the Account_voucher module with multi-currency in OpenERP,
|
||||
I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
|
||||
-
|
||||
I create currency USD in OpenERP for January of 1.333333 Rate
|
||||
-
|
||||
!python {model: res.currency.rate}: |
|
||||
from datetime import datetime
|
||||
curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])
|
||||
date = '%s-01-01' %(datetime.now().year)
|
||||
ids = self.search(cr, uid, [('currency_id', '=', curr_id), ('name', '=', date)])
|
||||
self.write(cr, uid, ids, {'rate': 1.333333})
|
||||
-
|
||||
I create currency USD in OpenERP for February of 1.250000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: febr_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
rate: 1.250000
|
||||
-
|
||||
I create currency USD in OpenERP for March of 1.111111 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: marc_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-03-01' %(datetime.now().year)"
|
||||
rate: 1.111111
|
||||
-
|
||||
I create currency USD in OpenERP for April of 1.052632 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: apri_usd}:
|
||||
currency_id: base.USD
|
||||
name: !eval "'%s-04-01' %(datetime.now().year)"
|
||||
rate: 1.052632
|
||||
-
|
||||
I create a bank journal with EUR as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_EUR}:
|
||||
name: Bank Journal(EUR)
|
||||
code: BEUR
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.EUR
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I create a bank journal with USD as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_USD}:
|
||||
name: Bank Journal(USD)
|
||||
code: BUSD
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.USD
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I set up some accounts for currency rate expense/income in my company
|
||||
-
|
||||
!record {model: res.company, id: base.main_company}:
|
||||
property_expense_currency_exchange: account.o_expense
|
||||
property_income_currency_exchange: account.o_income
|
||||
-
|
||||
I create a new partner Michael Geller
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_michael0}:
|
||||
address:
|
||||
- city: paris
|
||||
country_id: base.fr
|
||||
name: Michael
|
||||
street: 1 rue Rockfeller
|
||||
type: invoice
|
||||
zip: '75016'
|
||||
name: Mr.Michael Geller
|
||||
-
|
||||
I create the first invoice on 1st January for 200 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_first_invoice_jan}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 200.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_michael0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan}
|
||||
-
|
||||
I check that first invoice move is correct for debtor account(debit - credit == 150)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the second invoice on 1st February for 100 USD
|
||||
-
|
||||
!record {model: account.invoice, id: account_second_invoice_feb}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.USD
|
||||
date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
period_id: account.period_2
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 100.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_michael0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb}
|
||||
-
|
||||
I check that second invoice move is correct for debtor account (debit - credit == 80)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the first voucher of payment
|
||||
<create with values 240 EUR, journal EUR, and fills amount 180 for the invoice of 200$ and 70 for the invoice of 100$>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_michael0"), ref('bank_journal_EUR'), 240.0, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 240.0,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.EUR'),
|
||||
'journal_id': ref('bank_journal_EUR'),
|
||||
'partner_id': ref('res_partner_michael0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-03-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'First payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 200.00:
|
||||
item['amount'] = 180.00
|
||||
else:
|
||||
item['amount'] = 70.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 15.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 15.0), "Writeoff amount is not 15.0"
|
||||
-
|
||||
I check that currency rate difference is -34.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == -34.0), "Currency rate difference is not -34.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with -180 and -70 in amount_currency columns and their credit columns are respectively 135 and 56 and currency is USD($).
|
||||
-
|
||||
I check that my currency rate difference is correct. 34 in credit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. 15 in credit with no amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == -180.00:
|
||||
assert move_line.credit == 135.00, "Debtor account has wrong entry."
|
||||
elif move_line.amount_currency == -70.00:
|
||||
assert move_line.credit == 56.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 34.00:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.credit == 15.00:
|
||||
assert move_line.amount_currency == 0.00, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice"
|
||||
-
|
||||
I create the second voucher of payment
|
||||
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_michael0"), ref('bank_journal_EUR'), 45.0, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 45.0,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.USD'),
|
||||
'journal_id': ref('bank_journal_USD'),
|
||||
'partner_id': ref('res_partner_michael0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-04-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'Second payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 20.00:
|
||||
item['amount'] = 20.00
|
||||
else:
|
||||
item['amount'] = 30.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is -5.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0"
|
||||
-
|
||||
I check that currency rate difference is -8.50
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == -8.50), "Currency rate difference is not -8.50"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that my voucher state is posted
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert voucher_id.state == 'posted', "Voucher state is not posted"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with -20 and -30 in amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($).
|
||||
-
|
||||
I check that my currency rate difference is correct. 8.50 in credit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. 4.75 in debit and 5 in amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == -20.00:
|
||||
assert move_line.credit == 15.00, "Debtor account has wrong entry."
|
||||
elif move_line.amount_currency == -30.00:
|
||||
assert move_line.credit == 24.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 8.50:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.amount_currency == 5.00:
|
||||
assert move_line.debit == 4.75, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
|
|
@ -1,331 +0,0 @@
|
|||
-
|
||||
In order to check the Account_voucher module with multi-currency in OpenERP,
|
||||
I create 2 Invoices in EUR and make 2 Payments in EUR based on the currency rating on that particular date.
|
||||
-
|
||||
I create currency EUR in OpenERP for January of 1.000000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: jan_eur}:
|
||||
currency_id: base.EUR
|
||||
name: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
rate: 1.000000
|
||||
-
|
||||
I create currency EUR in OpenERP for February of 1.000000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: feb_eur}:
|
||||
currency_id: base.EUR
|
||||
name: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
rate: 1.000000
|
||||
-
|
||||
I create currency EUR in OpenERP for March of 1.000000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: mar_eur}:
|
||||
currency_id: base.EUR
|
||||
name: !eval "'%s-03-01' %(datetime.now().year)"
|
||||
rate: 1.000000
|
||||
-
|
||||
I create currency EUR in OpenERP for April of 1.000000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: apr_eur}:
|
||||
currency_id: base.EUR
|
||||
name: !eval "'%s-04-01' %(datetime.now().year)"
|
||||
rate: 1.000000
|
||||
-
|
||||
I create a bank journal with EUR as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_EUR}:
|
||||
name: Bank Journal(EUR)
|
||||
code: BEUR
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.EUR
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I set up some accounts for currency rate expense/income in my company
|
||||
-
|
||||
!record {model: res.company, id: base.main_company}:
|
||||
property_expense_currency_exchange: account.o_expense
|
||||
property_income_currency_exchange: account.o_income
|
||||
-
|
||||
I create a new partner Peter Lawson.
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_peter0}:
|
||||
address:
|
||||
- city: paris
|
||||
country_id: base.fr
|
||||
name: Peter
|
||||
street: 1 rue Rockfeller
|
||||
type: invoice
|
||||
zip: '75016'
|
||||
name: Mr.Peter Lawson
|
||||
-
|
||||
I create the first invoice on 1st January for 150 EUR
|
||||
-
|
||||
!record {model: account.invoice, id: account_first_invoice_jan_eur}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 150.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_peter0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur}
|
||||
-
|
||||
I check that first invoice move is correct for debtor account(debit - credit == 150)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the second invoice on 1st February for 80 EUR
|
||||
-
|
||||
!record {model: account.invoice, id: account_second_invoice_feb_eur}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 80.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_peter0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur}
|
||||
-
|
||||
I check that second invoice move is correct for debtor account (debit - credit == 80)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the first voucher of payment
|
||||
<create with values 120 EUR, journal EUR, and fill amounts 100 for the invoice of 150 EUR and 20 for the invoice of 80 EUR>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_peter0"), ref('bank_journal_EUR'), 120.00, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 120.00,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.EUR'),
|
||||
'journal_id': ref('bank_journal_EUR'),
|
||||
'partner_id': ref('res_partner_peter0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-03-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'First payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 150.00:
|
||||
item['amount'] = 100.00
|
||||
else:
|
||||
item['amount'] = 20.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 0.00
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00"
|
||||
-
|
||||
I check that currency rate difference is 0.00
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == 0.00), "Currency rate difference is not 0.00"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my first voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.credit == 20.00:
|
||||
assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 100.00:
|
||||
assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
|
||||
-
|
||||
I check the residual amount of Invoice1 is 50
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 50.0 and move_line.amount_residual == 50.0) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2 is 60
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice"
|
||||
-
|
||||
I create the second voucher of payment and check to let open the debtor overpaid amount.
|
||||
<create with values 120 EUR, journal EUR, and fill amounts 50 for the invoice of 150 EUR and 70 for the invoice of 80 EUR>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_peter0"), ref('bank_journal_EUR'), 120.00, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 120.00,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.EUR'),
|
||||
'journal_id': ref('bank_journal_EUR'),
|
||||
'partner_id': ref('res_partner_peter0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-04-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'Second payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 50.00:
|
||||
item['amount'] = 50.00
|
||||
elif item['amount_unreconciled'] == 60.00:
|
||||
item['amount'] = 70.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 0.00
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'),('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0"
|
||||
-
|
||||
I check that currency rate difference is 0.00
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.currency_rate_difference == 0.00), "Currency rate difference is not 0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my second voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.credit == 70.00:
|
||||
assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
|
||||
elif move_line.credit == 50.00:
|
||||
assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
|
||||
-
|
||||
I check the residual amount of Invoice1 is 0
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0 and move_line.amount_residual == 0) , "Residual amount is not correct for first Invoice"
|
||||
-
|
||||
I check the residual amuont of Invoice2 is -10
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == -10.0 and move_line.amount_residual == -10.0) , "Residual amount is not correct for second Invoice"
|
|
@ -1,194 +0,0 @@
|
|||
-
|
||||
In order to check the Account_voucher module with multi-currency in OpenERP,
|
||||
I create an invoice in CAD and make its Payment in CHF based on the currency rating on that particular date.
|
||||
-
|
||||
I create currency CAD in OpenERP for January of 1.338800 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: jan_cad}:
|
||||
currency_id: base.CAD
|
||||
name: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
rate: 1.338800
|
||||
-
|
||||
I create currency CAD in OpenERP for March of 2.000000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: mar_cad}:
|
||||
currency_id: base.CAD
|
||||
name: !eval "'%s-03-01' %(datetime.now().year)"
|
||||
rate: 2.000000
|
||||
-
|
||||
I create currency CHF in OpenERP for January of 1.308600 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: jan_chf}:
|
||||
currency_id: base.CHF
|
||||
name: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
rate: 1.308600
|
||||
-
|
||||
I create currency CHF in OpenERP for March of 1.250000 Rate
|
||||
-
|
||||
!record {model: res.currency.rate, id: mar_chf}:
|
||||
currency_id: base.CHF
|
||||
name: !eval "'%s-03-01' %(datetime.now().year)"
|
||||
rate: 1.250000
|
||||
-
|
||||
I create a bank journal with CHF as currency
|
||||
-
|
||||
!record {model: account.journal, id: bank_journal_CHF}:
|
||||
name: Bank Journal(CHF)
|
||||
code: BCHF
|
||||
type: bank
|
||||
analytic_journal_id: account.sit
|
||||
sequence_id: account.sequence_bank_journal
|
||||
default_debit_account_id: account.cash
|
||||
default_credit_account_id: account.cash
|
||||
currency: base.CHF
|
||||
company_id: base.main_company
|
||||
view_id: account.account_journal_bank_view
|
||||
-
|
||||
I set up some accounts for currency rate expense/income in my company
|
||||
-
|
||||
!record {model: res.company, id: base.main_company}:
|
||||
property_expense_currency_exchange: account.o_expense
|
||||
property_income_currency_exchange: account.o_income
|
||||
-
|
||||
I create a new partner John Armani.
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_john0}:
|
||||
address:
|
||||
- city: paris
|
||||
country_id: base.fr
|
||||
name: John
|
||||
street: 1 rue Rockfeller
|
||||
type: invoice
|
||||
zip: '75016'
|
||||
name: Mr.John Armani
|
||||
-
|
||||
I create the first invoice on 1st January for 200 CAD
|
||||
-
|
||||
!record {model: account.invoice, id: account_first_invoice_jan_cad}:
|
||||
account_id: account.a_recv
|
||||
address_contact_id: base.res_partner_address_3000
|
||||
address_invoice_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
currency_id: base.CAD
|
||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||
period_id: account.period_1
|
||||
invoice_line:
|
||||
- account_id: account.a_sale
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 200.0
|
||||
quantity: 1.0
|
||||
product_id: product.product_product_pc1
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.sales_journal
|
||||
partner_id: res_partner_john0
|
||||
reference_type: none
|
||||
-
|
||||
I Validate invoice by clicking on Validate button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_cad}
|
||||
-
|
||||
I check that first invoice move is correct for debtor account (debit - credit == 149.39)
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad"))
|
||||
assert invoice_id.move_id, "Move not created for open invoice"
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.debit - move_line.credit == 149.39), "Invoice move is incorrect for debtors account"
|
||||
-
|
||||
I create the first voucher of payment
|
||||
<create with values 300 CHF, journal CHF, and fill amounts 200 for the invoice of 200 CAD>
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc, time
|
||||
vals = {}
|
||||
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_john0"), ref('bank_journal_CHF'), 300.00, 2, ttype='receipt', date=False)
|
||||
vals = {
|
||||
'account_id': ref('account.cash'),
|
||||
'amount': 300.00,
|
||||
'company_id': ref('base.main_company'),
|
||||
'currency_id': ref('base.CHF'),
|
||||
'journal_id': ref('bank_journal_CHF'),
|
||||
'partner_id': ref('res_partner_john0'),
|
||||
'period_id': ref('account.period_3'),
|
||||
'type': 'receipt',
|
||||
'date': time.strftime("%Y-03-01"),
|
||||
'payment_option': 'with_writeoff',
|
||||
'writeoff_acc_id': ref('account.a_expense'),
|
||||
'comment': 'Write Off',
|
||||
'name': 'First payment',
|
||||
}
|
||||
if not res['value']['line_cr_ids']:
|
||||
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
|
||||
for item in res['value']['line_cr_ids']:
|
||||
if item['amount_unreconciled'] == 200.00:
|
||||
item['amount'] = 200.00
|
||||
vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
|
||||
id = self.create(cr, uid, vals)
|
||||
voucher_id = self.browse(cr, uid, id)
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 175.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 175.0), "Writeoff amount is not 175.0"
|
||||
-
|
||||
I check that currency rate difference is 49.39
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
curr_diff = float(str(voucher_id.currency_rate_difference))
|
||||
assert (curr_diff == 49.39), "Currency rate difference is not 49.39"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
import netsvc
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
|
||||
-
|
||||
I check that the move of my voucher is valid
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
assert move_line.state == 'valid', "Voucher move is not valid"
|
||||
assert voucher_id.state == 'posted', "Voucher state is not posted"
|
||||
-
|
||||
I check that my debtor account is correct
|
||||
-
|
||||
I check that the debtor account has 1 new line with -200 as amount_currency columns and 149.39 of credit and currency is CAD($).
|
||||
-
|
||||
I check that my currency rate difference is correct. 49.39 in debit with no amount_currency
|
||||
-
|
||||
I check that my writeoff is correct. 140 credit and -175 amount_currency
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
|
||||
for move_line in move_line_obj.browse(cr, uid, move_lines):
|
||||
if move_line.amount_currency == -200:
|
||||
assert move_line.credit == 149.39, "Debtor account has wrong entry."
|
||||
elif move_line.debit == 49.39:
|
||||
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
|
||||
elif move_line.credit == 140.00:
|
||||
assert move_line.amount_currency == -175.00, "Writeoff amount is wrong."
|
||||
-
|
||||
I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad"))
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
|
|
@ -74,24 +74,14 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Bill Payment">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id"
|
||||
required="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
string="Supplier"/>
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)" context="{'invoice_currency':currency_id}" string="Supplier"/>
|
||||
<field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id"
|
||||
domain="[('type','in',['bank', 'cash'])]"
|
||||
widget="selection" select="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"
|
||||
string="Payment Method"/>
|
||||
<field name="amount"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="date"
|
||||
select="1"
|
||||
on_change="onchange_date(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="date" select="1" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="reference" select="1" string="Payment Ref"/>
|
||||
<field name="name" colspan="2"/>
|
||||
<field name="account_id"
|
||||
|
@ -104,37 +94,25 @@
|
|||
<page string="Payment Information">
|
||||
<field name="line_dr_ids" attrs="{'invisible': [('type', '=', 'receipt')]}" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)">
|
||||
<tree string="Open Supplier Journal Entries" editable="bottom">
|
||||
<field name="move_line_id" required="1" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]" invisible="1"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('type', '=', 'payment')]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)">
|
||||
<tree string="Open Customer Journal Entries" editable="bottom">
|
||||
<field name="move_line_id" required="1"/>
|
||||
<field name="move_line_id"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="date_original"/>
|
||||
<field name="amount_original"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group col="2" colspan="3">
|
||||
|
@ -159,28 +137,15 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Bill Payment">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id"
|
||||
domain="[('supplier','=',True)]"
|
||||
required="1"
|
||||
invisible="context.get('line_type', False)"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
string="Supplier"/>
|
||||
<field name="partner_id" domain="[('supplier','=',True)]" required="1" invisible="context.get('line_type', False)" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)" context="{'invoice_currency':currency_id}" string="Supplier"/>
|
||||
<field name="amount" invisible="context.get('line_type', False)" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id"
|
||||
domain="[('type','in',['bank', 'cash'])]"
|
||||
invisible="context.get('line_type', False)"
|
||||
widget="selection" select="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"
|
||||
string="Payment Method"/>
|
||||
<field name="amount"
|
||||
invisible="context.get('line_type', False)"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="date"
|
||||
invisible="context.get('line_type', False)"
|
||||
on_change="onchange_date(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
|
||||
<field name="name" colspan="2" invisible="context.get('line_type', False)"/>
|
||||
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
|
||||
|
@ -194,37 +159,25 @@
|
|||
<page string="Payment Information">
|
||||
<field name="line_dr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
|
||||
<tree string="Supplier Invoices and Outstanding transactions" editable="bottom">
|
||||
<field name="move_line_id" required="1" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
|
||||
<tree string="Credits" editable="bottom">
|
||||
<field name="move_line_id" required="1"/>
|
||||
<field name="move_line_id"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="date_original"/>
|
||||
<field name="amount_original"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group col="2" colspan="3">
|
||||
|
@ -232,26 +185,27 @@
|
|||
<field name="narration" colspan="2" nolabel="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<group col="4" colspan="1">
|
||||
<separator string="Payment Options" colspan="4"/>
|
||||
<field name="payment_option" required="1" colspan="4"/>
|
||||
<field name="currency_rate_difference" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="company_currency" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}" nolabel="1"/><newline/>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Payment Options" colspan="2"/>
|
||||
<field name="payment_option" required="1"/>
|
||||
<field name="writeoff_amount"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="currency_id2" nolabel="1" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/><newline/>
|
||||
<field name="writeoff_acc_id"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')], 'required':[('payment_option','=','with_writeoff')]}"
|
||||
domain="[('type','=','other')]" colspan="4"/>
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="comment"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}" colspan="4"/>
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
|
||||
<field name="exchange_acc_id"
|
||||
attrs="{'invisible':[('currency_id','=',False)]}"
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="analytic_id"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"
|
||||
groups="analytic.group_analytic_accounting" colspan="4"/>
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
</group>
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<group col="4" colspan="1">
|
||||
<group col="2" colspan="1">
|
||||
<field name="number"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
@ -318,88 +272,56 @@
|
|||
id="menu_action_vendor_payment" parent="account.menu_finance_payables"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_vendor_receipt_form">
|
||||
<field name="name">voucher.form.customer.payment</field>
|
||||
<field name="name">account.voucher.receipt.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Customer Payment">
|
||||
<group col="12" colspan="4">
|
||||
<field name="partner_id"
|
||||
colspan="4"
|
||||
required="1"
|
||||
invisible="context.get('line_type', False)"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
string="Customer"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" invisible="context.get('line_type', False)" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)" string="Customer"/>
|
||||
<field name="amount"
|
||||
invisible="context.get('line_type', False)"
|
||||
string="Paid Amount"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id"
|
||||
domain="[('type','in',['bank', 'cash'])]"
|
||||
invisible="context.get('line_type', False)"
|
||||
widget="selection"
|
||||
select="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"
|
||||
string="Payment Method"
|
||||
colspan="4"/>
|
||||
<field name="amount"
|
||||
colspan="1"
|
||||
invisible="context.get('line_type', False)"
|
||||
string="Paid Amount"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="currency_id" nolabel="1" invisible="1"/>
|
||||
<field name="date"
|
||||
colspan="4"
|
||||
select="1"
|
||||
invisible="context.get('line_type', False)"
|
||||
on_change="onchange_date(partner_id, journal_id, amount,
|
||||
currency_id, type, date, context)"/>
|
||||
<field name="reference" colspan="4" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
|
||||
<field name="name" colspan="4" invisible="context.get('line_type', False)"/>
|
||||
<field name="company_id" colspan="4" widget="selection" groups="base.group_multi_company"/>
|
||||
<field name="account_id" colspan="4"
|
||||
widget="selection" select="1"
|
||||
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"
|
||||
string="Payment Method"/>
|
||||
<field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
|
||||
<field name="name" colspan="2" invisible="context.get('line_type', False)"/>
|
||||
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
|
||||
<field name="account_id"
|
||||
widget="selection"
|
||||
invisible="True"/>
|
||||
<field name="pre_line" colspan="4" invisible="1"/>
|
||||
<field name="type" colspan="4" invisible="True"/>
|
||||
<field name="pre_line" invisible="1"/>
|
||||
<field name="type" invisible="True"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Payment Information">
|
||||
<field name="line_cr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, date, context)">
|
||||
<field name="line_cr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)">
|
||||
<tree string="Invoices and outstanding transactions" editable="bottom">
|
||||
<field name="move_line_id" required="1" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]" invisible="1"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="line_dr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, date, context)">
|
||||
<field name="line_dr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)">
|
||||
<tree string="Credits" editable="bottom">
|
||||
<field name="move_line_id" required="1" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]" invisible="1"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="amount_original" readonly="1" invisible="1"/>
|
||||
<field name="amount_unreconciled" readonly="1"/>
|
||||
<field name="amount" on_change="onchange_amount(amount)"/>
|
||||
<field name="amount_in_voucher_currency" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="voucher_currency_id" readonly="1" groups="base.group_no_one"/>
|
||||
<field name="amount_in_company_currency" readonly="1" invisible="1"/>
|
||||
<field name="company_currency_id" readonly="1" invisible="1"/>
|
||||
<field name="move_line_id"/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original"/>
|
||||
<field name="amount_original"/>
|
||||
<field name="amount" sum="Payment"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group col="2" colspan="3">
|
||||
|
@ -407,25 +329,24 @@
|
|||
<field name="narration" colspan="2" nolabel="1"/>
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<group col="4" colspan="1">
|
||||
<separator string="Payment Options" colspan="4"/>
|
||||
<field name="payment_option" required="1" colspan="4"/>
|
||||
<field name="currency_rate_difference" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="company_currency" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}" nolabel="1"/><newline/>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Payment Options" colspan="2"/>
|
||||
<field name="payment_option" required="1"/>
|
||||
<field name="writeoff_amount"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="currency_id2" nolabel="1" attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/><newline/>
|
||||
<field name="writeoff_acc_id"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')], 'required':[('payment_option','=','with_writeoff')]}"
|
||||
domain="[('type','=','other')]" colspan="4"/>
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="comment"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}" colspan="4"/>
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="analytic_id"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"
|
||||
groups="analytic.group_analytic_accounting" colspan="4"/>
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
<field name="exchange_acc_id"
|
||||
domain="[('type','=','other')]"/>
|
||||
</group>
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<group col="4" colspan="1">
|
||||
<field name="currency_id"/>
|
||||
<field name="number"/>
|
||||
</group>
|
||||
</group>
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<form string="Sales Receipt">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)" string="Customer"/>
|
||||
<field name="date" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date, context)"/>
|
||||
<field name="date" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id" domain="[('type','in',['sale','sale_refund'])]" widget="selection" on_change="onchange_journal(journal_id, line_cr_ids, tax_id, partner_id)"/>
|
||||
<field name="number"/>
|
||||
<field name="name" colspan="2"/>
|
||||
|
@ -210,7 +210,7 @@
|
|||
<form string="Supplier Voucher">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" domain="[('supplier','=',True)]" required="1" string="Supplier" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="date" string="Bill Date" select="1" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date, context)"/>
|
||||
<field name="date" string="Bill Date" select="1" on_change="onchange_date(partner_id, journal_id, amount, currency_id, type, date)"/>
|
||||
<field name="journal_id" domain="[('type','in',['purchase','purchase_refund'])]" widget="selection" select="1" on_change="onchange_journal(journal_id, line_dr_ids, tax_id, partner_id)"/>
|
||||
<field name="number"/>
|
||||
<field name="name" colspan="2"/>
|
||||
|
|
|
@ -75,7 +75,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
|
|||
statement.currency.id, amount, context=ctx)
|
||||
|
||||
context.update({'move_line_ids': [line.id]})
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), voucher_currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), date=line_date, context=context)
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), date=line_date, context=context)
|
||||
voucher_res = { 'type':(amount < 0 and 'payment' or 'receipt'),
|
||||
'name': line.name,
|
||||
'partner_id': line.partner_id.id,
|
||||
|
|
Loading…
Reference in New Issue