diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 2e332ef4542..c68ecb51fec 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -1120,7 +1120,7 @@
icon="STOCK_JUSTIFY_FILL"
id="menu_action_account_moves_all"
parent="account.menu_finance_entries"
- sequence="16"
+ sequence="1"
groups="group_account_user,group_account_manager,base.group_system"
/>
diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py
index daa4f99cc3d..e7f14555e80 100644
--- a/addons/account_voucher/voucher.py
+++ b/addons/account_voucher/voucher.py
@@ -132,7 +132,7 @@ class account_voucher(osv.osv):
'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),
+# 'term_id':fields.many2one('account.payment.term', 'Term', required=False),
}
_defaults = {
'period_id': _get_period,
@@ -280,10 +280,6 @@ class account_voucher(osv.osv):
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
@@ -294,17 +290,20 @@ 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'
-
+
ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context)
ids.reverse()
moves = move_line_pool.browse(cr, uid, ids)
- total_credit = price or 0.0
- total_debit = 0.0
+
for line in moves:
if line.credit and line.reconcile_partial_id:
continue
@@ -327,7 +326,7 @@ class account_voucher(osv.osv):
rs['amount'] = min(line.amount_unreconciled, total_debit)
total_debit -= rs['amount']
else:
- rs['amount'] = min(line.debit, total_credit)
+ rs['amount'] = min(line.amount_unreconciled, total_credit)
total_credit -= rs['amount']
default['value']['line_ids'].append(rs)
@@ -384,9 +383,20 @@ class account_voucher(osv.osv):
return True
def cancel_voucher(self, cr, uid, ids, context={}):
+ reconcile_pool = self.pool.get('account.move.reconcile')
move_pool = self.pool.get('account.move')
voucher_line_pool = self.pool.get('account.voucher.line')
+
for voucher in self.browse(cr, uid, ids):
+ recs = []
+ for line in voucher.move_ids:
+ if line.reconcile_id:
+ recs += [line.reconcile_id.id]
+ if line.reconcile_partial_id:
+ recs += [line.reconcile_partial_id.id]
+
+ reconcile_pool.unlink(cr, uid, recs)
+
if voucher.move_id:
move_pool.button_cancel(cr, uid, [voucher.move_id.id])
move_pool.unlink(cr, uid, [voucher.move_id.id])
@@ -475,54 +485,47 @@ class account_voucher(osv.osv):
if credit < 0:
debit = -credit
credit = 0.0
- 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)
+
+ 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,
+ 'date_maturity':inv.date_due
+ }
+ master_line = move_line_pool.create(cr, uid, move_line)
rec_list_ids = []
line_total = debit - credit
+
+ if inv.type == 'sale':
+ line_total = line_total - inv.tax_amount
+ elif inv.type == 'purchase':
+ line_total = line_total + inv.tax_amount
+
for line in inv.line_ids:
if not line.amount:
continue
amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, line.amount)
move_line = {
+ 'journal_id':inv.journal_id.id,
+ 'period_id':inv.period_id.id,
'name':line.name and line.name or '/',
'account_id':line.account_id.id,
'move_id':move_id,
'partner_id':inv.partner_id.id,
'currency_id':inv.currency_id.id,
'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False,
- 'quantity':1
+ 'quantity':1,
+ 'credit':0.0,
+ 'debit':0.0,
+ 'date':inv.date
}
if amount < 0:
amount = -amount
@@ -530,7 +533,7 @@ class account_voucher(osv.osv):
line.type = 'cr'
else:
line.type = 'dr'
-
+
if (line.type=='dr'):
line_total += amount
move_line['debit'] = amount
@@ -538,43 +541,16 @@ class account_voucher(osv.osv):
line_total -= amount
move_line['credit'] = amount
+ if inv.tax_id:
+ move_line.update({
+ 'account_tax_id':inv.tax_id.id,
+ })
+
master_line = move_line_pool.create(cr, uid, move_line)
if line.move_line_id.id:
rec_ids = [master_line, line.move_line_id.id]
rec_list_ids.append(rec_ids)
- if inv.tax_amount:
- amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
- name = inv.tax_id and inv.tax_id.name or '/'
- move_line = {
- 'name':name,
- '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,
- }
- if inv.journal_id.type in ('sale','purchase_refund') and amount > 0:
- line_total -= amount
- move_line['credit'] = amount
- else:
- if amount < 0:
- amount = -amount
- line_total += amount
- move_line['debit'] = amount
-
- account_id = False
- if inv.tax_id:
- if inv.journal_id.type in ('sale_refund','purchase_refund'):
- account_id = inv.tax_id.account_paid_id
- else:
- account_id = inv.tax_id.account_collected_id.id
- if not account_id:
- raise osv.except_osv(_('Invalid Error !'), _('No account defined on the related tax !'))
- move_line['account_id'] = account_id
-
- move_line_id = move_line_pool.create(cr, uid, move_line)
-
if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total):
diff = line_total
move_line = {
@@ -682,7 +658,7 @@ class account_voucher_line(osv.osv):
'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, method=True, type='float', string='Originial Amount', store=True),
- 'amount_unreconciled': fields.related('move_line_id','amount_unreconciled', type='float', relation='account.move.line', string='Open Balance', readonly="1"),
+ 'amount_unreconciled': fields.related('move_line_id','amount_unreconciled', type='float', relation='account.move.line', string='Open Balance', store=True, readonly="1"),
}
_defaults = {
'name': lambda *a: ''
diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml
index 6f207f2b649..03ebcb1e67a 100644
--- a/addons/account_voucher/voucher_payment_receipt_view.xml
+++ b/addons/account_voucher/voucher_payment_receipt_view.xml
@@ -14,7 +14,7 @@
widget="selection" select="1"
on_change="onchange_partner_id(partner_id, journal_id, amount)"
string="Payment Method"/>
-
+
-
+
+
-
@@ -171,9 +171,9 @@
+
-
diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml
index 5b4ea813ee6..81dee85874e 100644
--- a/addons/account_voucher/voucher_sales_purchase_view.xml
+++ b/addons/account_voucher/voucher_sales_purchase_view.xml
@@ -4,12 +4,11 @@
Sales Payment
- account.voucher.open
+ account.voucher
form
[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt'), ('partner_id','=',partner_id)]
{'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}
-
- new
+
account.voucher.sale.form
@@ -71,10 +70,10 @@
+
-
@@ -126,7 +125,6 @@
-
@@ -151,9 +149,9 @@
+
-