diff --git a/addons/account/account.py b/addons/account/account.py
index 0dc079e2891..ff5e8d4db82 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1053,12 +1053,15 @@ class account_move(osv.osv):
if not context:
context={}
ids = []
-
if name:
- ids += self.search(cr, user, [('name','=',name)], limit=limit)
- if not ids:
- ids += self.search(cr, user, [('id','=',name)], limit=limit)
+ ids += self.search(cr, user, [('name','ilike',name)]+args, limit=limit, context=context)
+
+ if not ids and name and type(name) == int:
+ ids += self.search(cr, user, [('id','=',name)]+args, limit=limit, context=context)
+ if not ids:
+ ids += self.search(cr, user, args, limit=limit, context=context)
+
return self.name_get(cr, user, ids, context=context)
def name_get(self, cursor, user, ids, context=None):
diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py
index 8cbe0d019c7..83b7623b2eb 100644
--- a/addons/account_voucher/voucher.py
+++ b/addons/account_voucher/voucher.py
@@ -20,6 +20,7 @@
##############################################################################
import time
+import netsvc
from osv import fields
from osv import osv
from tools.translate import _
@@ -101,8 +102,10 @@ class account_voucher(osv.osv):
_name = 'account.voucher'
_description = 'Accounting Voucher'
_order = "id desc"
+ _rec_name = 'number'
+
_columns = {
- 'name':fields.char('Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'name':fields.char('Name', size=256, required=False, readonly=True, states={'draft':[('readonly',False)]}),
'type': fields.selection([
('payment', 'Payment'),
('receipt', 'Receipt'),
@@ -146,6 +149,7 @@ class account_voucher(osv.osv):
'journal_id':_get_journal,
'currency_id': _get_currency,
'state': lambda *a: 'draft',
+ 'name': lambda *a: '/',
'date' : lambda *a: time.strftime('%Y-%m-%d'),
'reference_type': lambda *a: "none",
'audit': lambda *a: False,
@@ -273,7 +277,6 @@ class account_voucher(osv.osv):
})
new_line += [tax_line]
-
if new_line:
for line in new_line:
voucher_line_pool.create(dbcr, uid, line)
@@ -296,36 +299,39 @@ class account_voucher(osv.osv):
'state':voucher.state
}
self.write(dbcr, uid, ids, res)
- else:
- raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !'))
+
return True
- def write(self, cr, uid, ids, vals, context={}):
- res = super(account_voucher, self).write(cr, uid, ids, vals, context)
-
- #If there is state says that method called from the work flow signals
- if not 'state' in vals.keys():
- self.open_voucher(cr, uid, ids, context)
-
- return res
+# def write(self, cr, uid, ids, vals, context={}):
+# res = super(account_voucher, self).write(cr, uid, ids, vals, context)
+#
+# #If there is state says that method called from the work flow signals
+# if not 'state' in vals.keys():
+# self.open_voucher(cr, uid, ids, context)
+#
+# return res
def voucher_recheck(self, cr, uid, ids, context={}):
- #self.open_voucher(cr, uid, ids, context)
+# self.open_voucher(cr, uid, ids, context)
self.write(cr, uid, ids, {'state':'recheck'}, context)
return True
def proforma_voucher(self, cr, uid, ids, context={}):
- #self.open_voucher(cr, uid, ids, context)
+# self.open_voucher(cr, uid, ids, context)
self.action_move_line_create(cr, uid, ids)
self.write(cr, uid, ids, {'state':'posted'})
return True
def action_cancel_draft(self, cr, uid, ids, context={}):
+ wf_service = netsvc.LocalService("workflow")
+ for voucher_id in ids:
+ wf_service.trg_create(uid, 'account.voucher', voucher_id, cr)
self.write(cr, uid, ids, {'state':'draft'})
return True
def audit_pass(self, cr, uid, ids, context={}):
move_pool = self.pool.get('account.move')
+
result = True
audit_pass = []
for voucher in self.browse(cr, uid, ids):
@@ -381,6 +387,9 @@ class account_voucher(osv.osv):
if inv.move_id:
continue
+ if not inv.payment_ids:
+ raise osv.except_osv(_('Error !'), _('Please define lines on voucher !'))
+
journal = journal_pool.browse(cr, uid, inv.journal_id.id)
if journal.sequence_id:
name = sequence_pool.get_id(cr, uid, journal.sequence_id.id)
@@ -492,14 +501,14 @@ class account_voucher(osv.osv):
rec = {
'move_id': move_id,
- 'move_ids':[(6, 0,line_ids)]
}
-
+
message = _('Voucher ') + " '" + inv.name + "' "+ _("is confirmed")
self.log(cr, uid, inv.id, message)
self.write(cr, uid, [inv.id], rec)
-
+ move_pool.post(cr, uid, [move_id], context={})
+
return True
def _convert_ref(self, cr, uid, ref):
@@ -553,7 +562,8 @@ class account_voucher_line(osv.osv):
'voucher_id':fields.many2one('account.voucher', 'Voucher'),
'name':fields.char('Memo', size=256, required=True),
'account_id':fields.many2one('account.account','Account', required=True, domain=[('type','<>','view')]),
- 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True),
+# 'partner_id': fields.many2one('res.partner', 'Partner', change_default=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')], 'Type'),
'ref':fields.char('Reference', size=32),
@@ -599,9 +609,6 @@ class account_voucher_line(osv.osv):
elif ttype == 'cr' and type1 in ('purchase'):
account_id = partner.property_account_payable.id
- else:
- raise osv.except_osv(_('Invalid Configuration !'), _('You can not encode unbalanced entry !'))
-
if company.currency_id != currency:
balance = currency_pool.compute(cr, uid, company.currency_id.id, currency, balance)
diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml
index 3d7c2a77db5..65cce5e29c4 100644
--- a/addons/account_voucher/voucher_view.xml
+++ b/addons/account_voucher/voucher_view.xml
@@ -10,13 +10,16 @@
-
+
-
+
+
+
+
@@ -28,23 +31,24 @@
@@ -107,6 +111,7 @@
+
@@ -147,6 +152,7 @@
+
diff --git a/addons/account_voucher/voucher_workflow.xml b/addons/account_voucher/voucher_workflow.xml
index 1c9d4f28bee..961032458c9 100644
--- a/addons/account_voucher/voucher_workflow.xml
+++ b/addons/account_voucher/voucher_workflow.xml
@@ -40,6 +40,7 @@
cancel
+ True
cancel_voucher()
function
diff --git a/addons/account_voucher_payment/account_voucher_payment.py b/addons/account_voucher_payment/account_voucher_payment.py
index 4af9b1dd5ef..d8d11e85062 100755
--- a/addons/account_voucher_payment/account_voucher_payment.py
+++ b/addons/account_voucher_payment/account_voucher_payment.py
@@ -22,9 +22,9 @@
from osv import fields, osv
from tools.translate import _
-class account_invoice(osv.osv):
- _inherit = 'account.invoice'
-
+class account_move(osv.osv):
+ _inherit = 'account.move'
+
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
"""
Returns a list of ids based on search domain {args}
@@ -43,18 +43,22 @@ class account_invoice(osv.osv):
if not context:
context = {}
ttype = context.get('ttype', False)
+ partner = context.get('partner_id', False)
+ voucher = context.get('voucher', False)
+ if voucher and not partner:
+ raise osv.except_osv(_('Invalid Partner !'), _('Please select the partner !'))
+
if ttype and ttype in ('receipt'):
- args += [('type','in', ['out_invoice', 'in_refund'])]
+ args += [('journal_id.type','in', ['sale', 'purchase_refund'])]
elif ttype and ttype in ('payment'):
- args += [('type','in', ['in_invoice', 'out_refund'])]
+ args += [('journal_id.type','in', ['purchase', 'sale_refund'])]
elif ttype and ttype in('sale', 'purchase'):
raise osv.except_osv(_('Invalid action !'), _('You can not reconcile sales, purchase, or journal voucher with invoice !'))
- args += [('type','=', 'do_not_allow_search')]
-
- res = super(account_invoice, self).search(cr, user, args, offset, limit, order, context, count)
+ args += [('journal_id.type','=', 'do_not_allow_search')]
+ res = super(account_move, self).search(cr, user, args, offset, limit, order, context, count)
return res
-account_invoice()
+account_move()
class account_move_line(osv.osv):
_inherit = "account.move.line"
@@ -66,7 +70,7 @@ account_move_line()
class account_voucher(osv.osv):
_inherit = 'account.voucher'
_columns = {
- 'voucher_line_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
+ 'voucher_line_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
}
def action_move_line_create(self, cr, uid, ids, *args):
@@ -84,7 +88,10 @@ class account_voucher(osv.osv):
if inv.move_id:
continue
-
+
+ if not inv.payment_ids:
+ raise osv.except_osv(_('Error !'), _('Please define lines on voucher !'))
+
journal = journal_pool.browse(cr, uid, inv.journal_id.id)
if journal.sequence_id:
name = sequence_pool.get_id(cr, uid, journal.sequence_id.id)
@@ -125,7 +132,7 @@ class account_voucher(osv.osv):
'move_id':move_id ,
'journal_id':inv.journal_id.id,
'period_id':inv.period_id.id,
- 'partner_id':False,
+ 'partner_id':inv.partner_id.id,
'ref':ref,
'date':inv.date
}
@@ -194,9 +201,9 @@ class account_voucher(osv.osv):
move_line_id = move_line_pool.create(cr, uid, move_line)
line_ids += [move_line_id]
- if line.invoice_id and inv.type in ('payment', 'receipt'):
+ if line.move_id and inv.type in ('payment', 'receipt'):
rec_ids += [move_line_id]
- for move_line in line.invoice_id.move_id.line_id:
+ for move_line in line.move_id.line_id:
if line.account_id.id == move_line.account_id.id:
rec_ids += [move_line.id]
@@ -204,15 +211,16 @@ class account_voucher(osv.osv):
move_line_pool.reconcile_partial(cr, uid, rec_ids)
rec = {
- 'move_id': move_id,
+ 'move_id': move_id
}
message = _('Voucher ') + " '" + inv.name + "' "+ _("is confirm")
self.log(cr, uid, inv.id, message)
self.write(cr, uid, [inv.id], rec)
+ move_pool.post(cr, uid, [move_id], context={})
- return True
+ return True
account_voucher()
@@ -225,7 +233,8 @@ class account_voucher_line(osv.osv):
return data
_columns = {
- 'invoice_id' : fields.many2one('account.invoice','Invoice'),
+# 'invoice_id' : fields.many2one('account.invoice','Invoice'),
+ 'move_id' : fields.many2one('account.move','Journal Entry'),
}
def move_line_get_item(self, cr, uid, line, context={}):
@@ -235,9 +244,9 @@ class account_voucher_line(osv.osv):
def onchange_invoice_id(self, cr, uid, ids, invoice_id, currency_id):
currency_pool = self.pool.get('res.currency')
- invoice_pool = self.pool.get('account.invoice')
+ invoice_pool = self.pool.get('account.move')
res = {
- 'amount':0.0
+
}
if not invoice_id:
return {
@@ -245,15 +254,19 @@ class account_voucher_line(osv.osv):
}
else:
invoice = invoice_pool.browse(cr, uid, invoice_id)
- residual = invoice.residual
- if invoice.currency_id.id != currency_id:
- residual = currency_pool.compute(cr, uid, invoice.currency_id.id, currency_id, invoice.residual)
+ residual = invoice.amount
+
+ company_currency = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
+ currency_diff = company_currency != currency_id
- res.update({
- 'amount': residual,
- 'account_id': invoice.account_id.id,
- 'ref':invoice.number
- })
+ if currency_diff:
+ residual = currency_pool.compute(cr, uid, company_currency, currency_id, residual)
+
+ if residual > 0:
+ res.update({
+ 'amount': residual,
+ 'ref':invoice.name
+ })
return {
'value':res
diff --git a/addons/account_voucher_payment/account_voucher_payment_view.xml b/addons/account_voucher_payment/account_voucher_payment_view.xml
index 6bc1484e81e..12715782819 100755
--- a/addons/account_voucher_payment/account_voucher_payment_view.xml
+++ b/addons/account_voucher_payment/account_voucher_payment_view.xml
@@ -8,16 +8,15 @@
-
+
-
-
-
-
-
+
+
+
+
-
+
@@ -54,7 +53,7 @@
form
-
diff --git a/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py b/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py
index ef30e1af69f..d12bee51894 100644
--- a/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py
+++ b/addons/account_voucher_payment/wizard/account_voucher_unreconcile.py
@@ -52,8 +52,9 @@ class account_voucher_unreconcile(osv.osv_memory):
reconcile_pool.unlink(cr, uid, rec)
if res.remove:
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr)
+ voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context)
+# wf_service = netsvc.LocalService("workflow")
+# wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr)
return {}