diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index 96412077840..6f3675392e0 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -60,6 +60,7 @@ module named account_voucher.
'wizard/account_period_close_view.xml',
'wizard/account_fiscalyear_close_state.xml',
'wizard/account_chart_view.xml',
+ 'wizard/account_tax_chart_view.xml',
'wizard/account_move_journal_view.xml',
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_open_closed_fiscalyear_view.xml',
diff --git a/addons/account/account.py b/addons/account/account.py
index eefe815bf97..f132c933821 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -835,7 +835,7 @@ class account_period(osv.osv):
'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True)
}
_defaults = {
- 'state': lambda *a: 'draft',
+ 'state': 'draft',
}
_order = "date_start"
@@ -883,13 +883,10 @@ class account_period(osv.osv):
return ids
def action_draft(self, cr, uid, ids, *args):
- users_roles = self.pool.get('res.users').browse(cr, uid, uid).roles_id
- for role in users_roles:
- if role.name=='Period':
- mode = 'draft'
- for id in ids:
- cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
- cr.execute('update account_period set state=%s where id=%s', (mode, id))
+ mode = 'draft'
+ for id in ids:
+ cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
+ cr.execute('update account_period set state=%s where id=%s', (mode, id))
return True
def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=80):
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 270384a1d9f..32403f658fc 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -201,6 +201,7 @@ class account_bank_statement(osv.osv):
res_users_obj = self.pool.get('res.users')
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
+ account_analytic_line_obj = self.pool.get('account.analytic.line')
account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
obj_seq = self.pool.get('ir.sequence')
@@ -222,6 +223,11 @@ class account_bank_statement(osv.osv):
raise osv.except_osv(_('Configuration Error !'),
_('Please verify that an account is defined in the journal.'))
+ if not st.name == '/':
+ next_number = st.name
+ else:
+ next_number = obj_seq.get(cr, uid, 'account.bank.statement')
+
for line in st.move_line_ids:
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
@@ -230,14 +236,18 @@ class account_bank_statement(osv.osv):
# In line we get reconcile_id on bank.ste.rec.
# in bank stat.rec we get line_new_ids on bank.stat.rec.line
for move in st.line_ids:
- context.update({'date':move.date})
+ if move.analytic_account_id:
+ if not st.journal_id.analytic_journal_id:
+ raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,))
+
+ context.update({'date': move.date})
move_id = account_move_obj.create(cr, uid, {
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'date': move.date,
}, context=context)
account_bank_statement_line_obj.write(cr, uid, [move.id], {
- 'move_ids': [(4,move_id, False)]
+ 'move_ids': [(4, move_id, False)]
})
if not move.amount:
continue
@@ -268,6 +278,7 @@ class account_bank_statement(osv.osv):
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'currency_id': st.currency.id,
+ 'analytic_account_id': move.analytic_account_id and move.analytic_account_id.id or False
}
amount = res_currency_obj.compute(cr, uid, st.currency.id,
@@ -289,7 +300,28 @@ class account_bank_statement(osv.osv):
account=acc_cur)
val['amount_currency'] = amount_cur
- torec.append(account_move_line_obj.create(cr, uid, val , context=context))
+ move_line_id = account_move_line_obj.create(cr, uid, val , context=context)
+ torec.append(move_line_id)
+
+ if move.analytic_account_id:
+ anal_val = {}
+ amt = (val['credit'] or 0.0) - (val['debit'] or 0.0)
+ anal_val = {
+ 'name': val['name'],
+ 'ref': val['ref'],
+ 'date': val['date'],
+ 'amount': amt,
+ 'account_id': val['analytic_account_id'],
+ 'currency_id': val['currency_id'],
+ 'general_account_id': val['account_id'],
+ 'journal_id': st.journal_id.analytic_journal_id.id,
+ 'period_id': val['period_id'],
+ 'user_id': uid,
+ 'move_id': move_line_id
+ }
+ if val.get('amount_currency', False):
+ anal_val['amount_currency'] = val['amount_currency']
+ account_analytic_line_obj.create(cr, uid, anal_val, context=context)
if move.reconcile_id and move.reconcile_id.line_new_ids:
for newline in move.reconcile_id.line_new_ids:
@@ -367,17 +399,11 @@ class account_bank_statement(osv.osv):
account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
else:
account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context)
-
- if st.journal_id.entry_posted:
- account_move_obj.write(cr, uid, [move_id], {'state': 'posted'})
+ move_name = next_number + ' - ' + str(move.sequence)
+ account_move_obj.write(cr, uid, [move_id], {'name': move_name, 'state': 'posted'}) # Bank statements will not consider boolean on journal entry_posted
self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st.name)
done.append(st.id)
-
- next_number = obj_seq.get(cr, uid, 'account.bank.statement')
- if not st.name == '/':
- next_number = st.name + '/' + next_number[-1:]
- account_move_obj.write(cr, uid, [move_id], {'state': 'posted', 'name': next_number})
self.write(cr, uid, [st.id], {'name': next_number}, context=context)
self.write(cr, uid, done, {'state':'confirm'}, context=context)
@@ -397,28 +423,15 @@ class account_bank_statement(osv.osv):
return True
def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
- if not journal_id:
- return {'value': {'currency': False}}
-
account_journal_obj = self.pool.get('account.journal')
res_users_obj = self.pool.get('res.users')
- res_currency_obj = self.pool.get('res.currency')
-
cursor.execute('SELECT balance_end_real \
FROM account_bank_statement \
- WHERE journal_id = %s \
- ORDER BY date DESC,id DESC LIMIT 1', (journal_id,))
+ WHERE journal_id = %s AND NOT state = %s \
+ ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cursor.fetchone()
balance_start = res and res[0] or 0.0
-
- currency_id = account_journal_obj.browse(cursor, user, journal_id,
- context=context).currency.id
- if not currency_id:
- currency_id = res_users_obj.browse(cursor, user, user,
- context=context).company_id.currency_id.id
- currency = res_currency_obj.name_get(cursor, user, [currency_id],
- context=context)[0]
- return {'value': {'balance_start': balance_start, 'currency': currency}}
+ return {'value': {'balance_start': balance_start}}
def unlink(self, cr, uid, ids, context=None):
stat = self.read(cr, uid, ids, ['state'])
@@ -629,6 +642,26 @@ class account_bank_statement_line(osv.osv):
else:
account_id = part.property_account_receivable.id
res['value']['account_id'] = account_id
+
+ if not line or (line and not line[0].amount):
+ res_users_obj = self.pool.get('res.users')
+ res_currency_obj = self.pool.get('res.currency')
+ company_currency_id = res_users_obj.browse(cursor, user, user,
+ context=context).company_id.currency_id.id
+ if not currency_id:
+ currency_id = company_currency_id
+
+ cursor.execute('SELECT sum(debit-credit) \
+ FROM account_move_line \
+ WHERE (reconcile_id is null) \
+ AND partner_id = %s \
+ AND account_id=%s', (partner_id, account_id))
+ pgres = cursor.fetchone()
+ balance = pgres and pgres[0] or 0.0
+
+ balance = res_currency_obj.compute(cursor, user, company_currency_id,
+ currency_id, balance, context=context)
+ res['value']['amount'] = balance
return res
def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
@@ -669,6 +702,7 @@ class account_bank_statement_line(osv.osv):
select=True, required=True, ondelete='cascade'),
'reconcile_id': fields.many2one('account.bank.statement.reconcile',
'Reconcile'),
+ 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'move_ids': fields.many2many('account.move',
'account_bank_statement_line_move_rel', 'move_id','statement_id',
'Moves'),
diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml
index 41d0344de92..db70d5e0e5a 100644
--- a/addons/account/account_invoice_view.xml
+++ b/addons/account/account_invoice_view.xml
@@ -500,7 +500,7 @@
-
+
diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml
index 3cb21315350..24f4bb795a2 100644
--- a/addons/account/account_menuitem.xml
+++ b/addons/account/account_menuitem.xml
@@ -3,8 +3,8 @@
-
-
+
+
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index bab05321f4d..c6e24e07842 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -104,7 +104,7 @@
-
+
@@ -242,8 +242,8 @@
-
+
@@ -520,6 +520,7 @@
+
@@ -668,7 +669,6 @@
-
@@ -711,9 +711,9 @@
-
-
+
+
@@ -858,11 +858,13 @@
Chart of Taxes is a tree view reflecting the structure of the Tax Cases (or tax codes) and shows the current tax situation. The tax chart represents the amount of each area of the tax declaration for your country. It’s presented in a hierarchical structure, which can be modified to fit your needs.
+
+
@@ -461,12 +461,14 @@
Sale Journal
account.journal
-
+
+ %(year)s/
Purchase Journal
account.journal
-
+
+ %(year)s/
-
+
Journal Items
account.move.journal
form
@@ -67,10 +67,10 @@
diff --git a/addons/account/wizard/account_tax_chart.py b/addons/account/wizard/account_tax_chart.py
new file mode 100644
index 00000000000..5b5feaf480c
--- /dev/null
+++ b/addons/account/wizard/account_tax_chart.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+
+class account_tax_chart(osv.osv_memory):
+ """
+ For Chart of taxes
+ """
+ _name = "account.tax.chart"
+ _description = "Account tax chart"
+ _columns = {
+ 'period_id': fields.many2one('account.period', \
+ 'Period', \
+ ),
+ 'target_move': fields.selection([('all', 'All Entries'),
+ ('posted', 'All Posted Entries')], 'Target Moves', required=True),
+ }
+
+ def _get_period(self, cr, uid, context=None):
+ """Return default period value"""
+ return self.pool.get('account.period').find(cr, uid)
+
+ def account_tax_chart_open_window(self, cr, uid, ids, context=None):
+ """
+ Opens chart of Accounts
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of account chart’s IDs
+ @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ period_obj = self.pool.get('account.period')
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids, [], context=context)[0]
+ result = mod_obj._get_id(cr, uid, 'account', 'action_tax_code_tree')
+ id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id']
+ result = act_obj.read(cr, uid, [id], context=context)[0]
+ if data['period_id']:
+ fiscalyear_id = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['fiscalyear_id'][0]
+ result['context'] = str({'period_id': data['period_id'], \
+ 'fiscalyear_id': fiscalyear_id, \
+ 'state': data['target_move']})
+ else:
+ result['context'] = str({'state': data['target_move']})
+
+ if data['period_id']:
+ result['name'] += ':' + self.pool.get('account.period').read(cr, uid, [data['period_id']], context=context)[0]['code']
+ return result
+
+ _defaults = {
+ 'period_id': _get_period,
+ 'target_move': 'all'
+ }
+
+account_tax_chart()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_tax_chart_view.xml b/addons/account/wizard/account_tax_chart_view.xml
new file mode 100644
index 00000000000..f60ad394857
--- /dev/null
+++ b/addons/account/wizard/account_tax_chart_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ account.tax.chart.form
+ account.tax.chart
+ form
+
+
+
+
+
+
+ Chart of Taxes
+ account.tax.chart
+ form
+ tree,form
+ [('parent_id','=',False)]
+
+ Chart of Taxes is a tree view reflecting the structure of the Tax Cases (or tax codes) and shows the current tax situation. The tax chart represents the amount of each area of the tax declaration for your country. It’s presented in a hierarchical structure, which can be modified to fit your needs.
+ new
+
+
+
+
+
+
diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py
index e8a02320533..4cc44433ff8 100644
--- a/addons/account_voucher/voucher.py
+++ b/addons/account_voucher/voucher.py
@@ -44,6 +44,9 @@ class account_move_line(osv.osv):
account_move_line()
class account_voucher(osv.osv):
+ def _get_type(self, cr, uid, ids, context={}):
+ return context.get('type')
+
def _get_period(self, cr, uid, context={}):
if context.get('period_id', False):
return context.get('period_id')
@@ -81,6 +84,12 @@ class account_voucher(osv.osv):
_order = "date desc, id desc"
_rec_name = 'number'
_columns = {
+ 'type':fields.selection([
+ ('sale','Sale'),
+ ('purchase','Purchase'),
+ ('payment','Payment'),
+ ('receipt','Receipt'),
+ ],'Type'),
'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}),
'date':fields.date('Date', readonly=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)]}),
@@ -88,9 +97,9 @@ class account_voucher(osv.osv):
'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',
- domain=[('type','=','cr')], context={'default_type':'cr'}),
+ domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}),
'line_dr_ids':fields.one2many('account.voucher.line','voucher_id','Debits',
- domain=[('type','=','dr')], context={'default_type':'dr'}),
+ 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('Narration', readonly=True, states={'draft':[('readonly',False)]}),
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
@@ -110,7 +119,7 @@ class account_voucher(osv.osv):
'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Payment or Receipt transaction number, i.e. Bank cheque number or payorder number or Wire transfer number or Acknowledge number."),
'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'),
'move_id':fields.many2one('account.move', 'Account Entry'),
- 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True, states={'draft':[('readonly',False)]}),
+ 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}),
'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'),
'pay_now':fields.selection([
@@ -119,11 +128,14 @@ class account_voucher(osv.osv):
],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}),
'pre_line':fields.boolean('Previous Payments ?', required=False),
+ 'date_due': fields.date('Due Date'),
+ 'term_id':fields.many2one('account.payment.term', 'Term', required=False),
}
_defaults = {
'period_id': _get_period,
'journal_id':_get_journal,
'currency_id': _get_currency,
+ 'type':_get_type,
'state': lambda *a: 'draft',
'pay_now':lambda *a: 'pay_later',
'name': lambda *a: '',
@@ -196,9 +208,23 @@ class account_voucher(osv.osv):
return {
'value':res
}
-
- def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, context={}):
- """
+
+ def onchange_term_id(self, cr, uid, ids, term_id, amount):
+ term_pool = self.pool.get('account.payment.term')
+ terms = False
+ due_date = False
+ default = {'date_due':False}
+ if term_id and amount:
+ terms = term_pool.compute(cr, uid, term_id, amount)
+ if terms:
+ due_date = terms[-1][0]
+ default.update({
+ 'date_due':due_date
+ })
+ return {'value':default}
+
+ def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}):
+ """price
Returns a dict that contains new values and context
@param partner_id: latest value from user input for field partner_id
@@ -215,33 +241,46 @@ class account_voucher(osv.osv):
partner_pool = self.pool.get('res.partner')
journal_pool = self.pool.get('account.journal')
default = {
- 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': 0},
+ 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False},
}
- # TODO: improve this if possible !
if not partner_id:
- if ids:
- line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])])
- if line_ids:
- line_pool.unlink(cr, uid, line_ids)
+ return default
+
+ 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
journal = journal_pool.browse(cr, uid, journal_id)
partner = partner_pool.browse(cr, uid, partner_id)
account_id = False
+ term_id = False
if journal.type in ('sale','sale_refund'):
account_id = partner.property_account_receivable.id
elif journal.type in ('purchase', 'purchase_refund','expense'):
+ term_id = partner.property_payment_term.id
+ if term_id:
+ vals = self.onchange_term_id(cr, uid, ids, term_id, price)
+ default['value'].update(vals.get('value'))
account_id = partner.property_account_payable.id
else:
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
default['value'].update({
- 'account_id':account_id
+ 'account_id':account_id,
+ 'term_id':term_id
})
if journal.type not in ('cash', 'bank'):
return default
-
- ids = move_line_pool.search(cr, uid, [('account_id.type','in', ('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context)
+
+ account_type = 'receivable'
+ if ttype == 'payment':
+ account_type = 'payable'
+ else:
+ account_type = 'receivable'
+
+ ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context)
moves = move_line_pool.browse(cr, uid, ids)
total_credit = price or 0.0
total_debit = 0.0
@@ -275,7 +314,11 @@ class account_voucher(osv.osv):
default['value']['line_cr_ids'].append(rs)
else:
default['value']['line_dr_ids'].append(rs)
+
+ if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0:
default['value']['pre_line'] = 1
+ elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
+ default['value']['pre_line'] = 1
return default
@@ -296,11 +339,10 @@ class account_voucher(osv.osv):
}
}
- # TODO
def onchange_journal(self, cr, uid, ids, journal_id):
return {}
- def proforma_voucher(self, cr, uid, ids, context={}):
+ def proforma_voucher(self, cr, uid, ids):
self.action_move_line_create(cr, uid, ids)
return True
@@ -352,6 +394,14 @@ class account_voucher(osv.osv):
}
def action_move_line_create(self, cr, uid, ids, *args):
+
+ def _get_payment_term_lines(term_id, amount):
+ term_pool = self.pool.get('account.payment.term')
+ if term_id and amount:
+ terms = term_pool.compute(cr, uid, term_id, amount)
+ return terms
+ return False
+
move_pool = self.pool.get('account.move')
move_line_pool = self.pool.get('account.move.line')
analytic_pool = self.pool.get('account.analytic.line')
@@ -380,27 +430,49 @@ class account_voucher(osv.osv):
}
move_id = move_pool.create(cr, uid, move)
company_currency = inv.account_id.company_id.currency_id.id
-
+
#create the first line manually
debit = 0.0
credit = 0.0
- # TODO: to improve to select debit or credit
- if True:
+ # TODO: is there any other alternative then the voucher type ??
+ if inv.type in ('purchase', 'payment'):
+ credit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount)
+ elif inv.type in ('sale', 'receipt'):
debit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount)
- move_line = {
- 'name':inv.name or '/',
- 'debit':debit,
- 'credit':credit,
- 'account_id':inv.account_id.id,
- 'move_id':move_id ,
- 'journal_id':inv.journal_id.id,
- 'period_id':inv.period_id.id,
- 'partner_id':inv.partner_id.id,
- 'currency_id':inv.currency_id.id,
- 'date':inv.date
- }
-
- master_line = move_line_pool.create(cr, uid, move_line)
+
+ if inv.type == 'purchase' and inv.term_id and _get_payment_term_lines(inv.term_id.id, credit or debit):
+ terms = _get_payment_term_lines(inv.term_id.id, credit or debit)
+ for term in terms:
+ due_date = term[0]
+ amount = term[1]
+ move_line = {
+ 'name':inv.name or '/',
+ 'debit':0.0,
+ 'credit':amount,
+ 'date_maturity':due_date,
+ 'account_id':inv.account_id.id,
+ 'move_id':move_id ,
+ 'journal_id':inv.journal_id.id,
+ 'period_id':inv.period_id.id,
+ 'partner_id':inv.partner_id.id,
+ 'currency_id':inv.currency_id.id,
+ 'date':inv.date
+ }
+ master_line = move_line_pool.create(cr, uid, move_line)
+ else:
+ move_line = {
+ 'name':inv.name or '/',
+ 'debit':debit,
+ 'credit':credit,
+ 'account_id':inv.account_id.id,
+ 'move_id':move_id ,
+ 'journal_id':inv.journal_id.id,
+ 'period_id':inv.period_id.id,
+ 'partner_id':inv.partner_id.id,
+ 'currency_id':inv.currency_id.id,
+ 'date':inv.date
+ }
+ master_line = move_line_pool.create(cr, uid, move_line)
rec_list_ids = []
line_total = debit - credit
@@ -547,9 +619,9 @@ class account_voucher_line(osv.osv):
return res
_columns = {
- 'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1),
+ 'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1, ondelete='cascade'),
'name':fields.char('Description', size=256),
- 'account_id':fields.many2one('account.account','Account', required=True, domain=[('type','<>','view')]),
+ 'account_id':fields.many2one('account.account','Account', required=True),
'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
'amount':fields.float('Amount'),
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Cr/Dr'),
@@ -616,7 +688,11 @@ class account_voucher_line(osv.osv):
elif journal.type in ('purchase', 'expense', 'sale_refund'):
account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False
elif partner_id:
- account_id = partner_pool.browse(cr, user, partner_id, context=context).property_account_receivable.id
+ partner = partner_pool.browse(cr, user, partner_id, context=context)
+ if context.get('type') == 'payment':
+ account_id = partner.property_account_payable.id
+ elif context.get('type') == 'receipt':
+ account_id = partner.property_account_receivable.id
if (not account_id) and 'account_id' in fields_list:
raise osv.except_osv(_('Invalid Error !'), _('Please change partner and try again !'))
diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml
index 8044093e7fb..4ffba531dc4 100644
--- a/addons/account_voucher/voucher_payment_receipt_view.xml
+++ b/addons/account_voucher/voucher_payment_receipt_view.xml
@@ -8,33 +8,57 @@