diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 2522e53b2a0..9b4af85164e 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -100,6 +100,57 @@ class account_move_line(osv.osv):
return query
+ def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
+ """
+ This function returns the residual amount on a receivable or payable account.move.line.
+ By default, it returns an amount in the currency of this journal entry (maybe different
+ of the company currency), but if you pass 'residual_in_company_currency' = True in the
+ context then the returned amount will be in company currency.
+ """
+ res = {}
+ if context is None:
+ context = {}
+ cur_obj = self.pool.get('res.currency')
+ for move_line in self.browse(cr, uid, ids, context=context):
+ res[move_line.id] = {
+ 'amount_residual': 0.0,
+ 'amount_residual_currency': 0.0,
+ }
+
+ if move_line.reconcile_id:
+ continue
+ if not move_line.account_id.type in ('payable', 'receivable'):
+ #this function does not suport to be used on move lines not related to payable or receivable accounts
+ continue
+
+ if move_line.currency_id:
+ move_line_total = move_line.amount_currency
+ sign = move_line.amount_currency < 0 and -1 or 1
+ else:
+ move_line_total = move_line.debit - move_line.credit
+ sign = (move_line.debit - move_line.credit) < 0 and -1 or 1
+ line_total_in_company_currency = move_line.debit - move_line.credit
+ context_unreconciled = context.copy()
+ if move_line.reconcile_partial_id:
+ for payment_line in move_line.reconcile_partial_id.line_partial_ids:
+ if payment_line.id == move_line.id:
+ continue
+ if payment_line.currency_id and move_line.currency_id and payment_line.currency_id.id == move_line.currency_id.id:
+ move_line_total += payment_line.amount_currency
+ else:
+ if move_line.currency_id:
+ context_unreconciled.update({'date': payment_line.date})
+ amount_in_foreign_currency = cur_obj.compute(cr, uid, move_line.company_id.currency_id.id, move_line.currency_id.id, (payment_line.debit - payment_line.credit), round=False, context=context_unreconciled)
+ move_line_total += amount_in_foreign_currency
+ else:
+ move_line_total += (payment_line.debit - payment_line.credit)
+ line_total_in_company_currency += (payment_line.debit - payment_line.credit)
+
+ result = move_line_total
+ res[move_line.id]['amount_residual_currency'] = sign * (move_line.currency_id and self.pool.get('res.currency').round(cr, uid, move_line.currency_id, result) or result)
+ res[move_line.id]['amount_residual'] = sign * line_total_in_company_currency
+ return res
+
def default_get(self, cr, uid, fields, context=None):
data = self._default_get(cr, uid, fields, context=context)
for f in data.keys():
@@ -433,6 +484,8 @@ class account_move_line(osv.osv):
'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
+ 'amount_residual_currency': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
+ 'amount_residual': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1),
@@ -676,6 +729,7 @@ class account_move_line(osv.osv):
company_list.append(line.company_id.id)
for line in self.browse(cr, uid, ids, context=context):
+ company_currency_id = line.company_id.currency_id
if line.reconcile_id:
raise osv.except_osv(_('Warning'), _('Already Reconciled!'))
if line.reconcile_partial_id:
@@ -688,8 +742,7 @@ class account_move_line(osv.osv):
else:
unmerge.append(line.id)
total += (line.debit or 0.0) - (line.credit or 0.0)
-
- if not total:
+ if self.pool.get('res.currency').is_zero(cr, uid, company_currency_id, total):
res = self.reconcile(cr, uid, merges+unmerge, context=context)
return res
r_id = move_rec_obj.create(cr, uid, {
@@ -771,6 +824,19 @@ class account_move_line(osv.osv):
libelle = context['comment']
else:
libelle = _('Write-Off')
+
+ cur_obj = self.pool.get('res.currency')
+ cur_id = False
+ amount_currency_writeoff = 0.0
+ if context.get('company_currency_id',False) != context.get('currency_id',False):
+ cur_id = context.get('currency_id',False)
+ for line in unrec_lines:
+ if line.currency_id and line.currency_id.id == context.get('currency_id',False):
+ amount_currency_writeoff += line.amount_currency
+ else:
+ tmp_amount = cur_obj.compute(cr, uid, line.account_id.company_id.currency_id.id, context.get('currency_id',False), abs(line.debit-line.credit), context={'date': line.date})
+ amount_currency_writeoff += (line.debit > 0) and tmp_amount or -tmp_amount
+
writeoff_lines = [
(0, 0, {
'name': libelle,
@@ -779,8 +845,8 @@ class account_move_line(osv.osv):
'account_id': account_id,
'date': date,
'partner_id': partner_id,
- 'currency_id': account.currency_id.id or False,
- 'amount_currency': account.currency_id.id and -currency or 0.0
+ 'currency_id': cur_id or (account.currency_id.id or False),
+ 'amount_currency': amount_currency_writeoff and -1 * amount_currency_writeoff or (account.currency_id.id and -1 * currency or 0.0)
}),
(0, 0, {
'name': libelle,
@@ -789,7 +855,9 @@ class account_move_line(osv.osv):
'account_id': writeoff_acc_id,
'analytic_account_id': context.get('analytic_id', False),
'date': date,
- 'partner_id': partner_id
+ 'partner_id': partner_id,
+ 'currency_id': cur_id or (account.currency_id.id or False),
+ 'amount_currency': amount_currency_writeoff and amount_currency_writeoff or (account.currency_id.id and currency or 0.0)
})
]
@@ -802,6 +870,8 @@ class account_move_line(osv.osv):
})
writeoff_line_ids = self.search(cr, uid, [('move_id', '=', writeoff_move_id), ('account_id', '=', account_id)])
+ if account_id == writeoff_acc_id:
+ writeoff_line_ids = [writeoff_line_ids[1]]
ids += writeoff_line_ids
r_id = move_rec_obj.create(cr, uid, {
@@ -1283,4 +1353,4 @@ class account_move_line(osv.osv):
account_move_line()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/i18n/fr.po b/addons/account/i18n/fr.po
index e3232286a80..03056b8d204 100644
--- a/addons/account/i18n/fr.po
+++ b/addons/account/i18n/fr.po
@@ -489,7 +489,7 @@ msgstr "Date de création"
#. module: account
#: selection:account.journal,type:0
msgid "Purchase Refund"
-msgstr "Remboursement d'achat"
+msgstr "Avoir fournisseur"
#. module: account
#: selection:account.journal,type:0
@@ -1632,7 +1632,7 @@ msgstr "Compte fournisseurs débiteurs"
#: field:account.tax,account_paid_id:0
#: field:account.tax.template,account_paid_id:0
msgid "Refund Tax Account"
-msgstr "Compte de taxe à payer"
+msgstr "Compte de taxe pour avoirs"
#. module: account
#: view:account.bank.statement:0
@@ -9899,7 +9899,7 @@ msgstr "Rechercher une facture"
#: view:account.invoice.report:0
#: model:ir.actions.act_window,name:account.action_account_invoice_refund
msgid "Refund"
-msgstr "Rembourser"
+msgstr "Créer un avoir"
#. module: account
#: field:wizard.multi.charts.accounts,bank_accounts_id:0
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index f094e1c5f3b..f9bf0b26efc 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -88,32 +88,14 @@ class account_invoice(osv.osv):
return [('none', _('Free Reference'))]
def _amount_residual(self, cr, uid, ids, name, args, context=None):
- res = {}
- if context is None:
- context = {}
-
- cur_obj = self.pool.get('res.currency')
- data_inv = self.browse(cr, uid, ids, context=context)
- for inv in data_inv:
- if inv.reconciled:
- res[inv.id] = 0.0
- continue
- inv_total = inv.amount_total
- context_unreconciled = context.copy()
- for lines in inv.move_lines:
- if lines.currency_id and lines.currency_id.id == inv.currency_id.id:
- if inv.type in ('out_invoice','in_refund'):
- inv_total += lines.amount_currency
- else:
- inv_total -= lines.amount_currency
- else:
- context_unreconciled.update({'date': lines.date})
- amount_in_invoice_currency = cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id,abs(lines.debit-lines.credit),round=False,context=context_unreconciled)
- inv_total -= amount_in_invoice_currency
-
- result = inv_total
- res[inv.id] = self.pool.get('res.currency').round(cr, uid, inv.currency_id, result)
- return res
+ result = {}
+ for invoice in self.browse(cr, uid, ids, context=context):
+ result[invoice.id] = 0.0
+ if invoice.move_id:
+ for m in invoice.move_id.line_id:
+ if m.account_id.type in ('receivable','payable'):
+ result[invoice.id] = m.amount_residual_currency
+ return result
# Give Journal Items related to the payment reconciled to this invoice
# Return ids of partial and total payments related to the selected invoices
diff --git a/addons/account/report/common_report_header.py b/addons/account/report/common_report_header.py
index 809cb38e879..48e26e839d3 100644
--- a/addons/account/report/common_report_header.py
+++ b/addons/account/report/common_report_header.py
@@ -64,8 +64,8 @@ class common_report_header(object):
def _get_target_move(self, data):
if data.get('form', False) and data['form'].get('target_move', False):
if data['form']['target_move'] == 'all':
- return 'All Entries'
- return 'All Posted Entries'
+ return _('All Entries')
+ return _('All Posted Entries')
return ''
def _get_end_date(self, data):
@@ -94,10 +94,10 @@ class common_report_header(object):
def _get_filter(self, data):
if data.get('form', False) and data['form'].get('filter', False):
if data['form']['filter'] == 'filter_date':
- return 'Date'
+ return _('Date')
elif data['form']['filter'] == 'filter_period':
- return 'Periods'
- return 'No Filter'
+ return _('Periods')
+ return _('No Filter')
def _sum_debit_period(self, period_id, journal_id=None):
journals = journal_id or self.journal_ids
diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml
index 5f429270e29..39ed61cc253 100644
--- a/addons/account/security/account_security.xml
+++ b/addons/account/security/account_security.xml
@@ -16,98 +16,98 @@
Account Entry
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Entry lines
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Journal Period
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Journal multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Analytic journal multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Analytic journal multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Period multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Fiscal year multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Account multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Tax multi-company
- ['|',('company_id','=',False),('company_id','=',user.company_id.id)]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Tax code multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Invoice multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Account fiscal Mapping company rule
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Account model company rule
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py
index 47f9ac9c2c8..d915a1cd34b 100644
--- a/addons/account/wizard/account_change_currency.py
+++ b/addons/account/wizard/account_change_currency.py
@@ -72,7 +72,7 @@ class account_change_currency(osv.osv_memory):
new_price = (line.price_unit / old_rate ) * rate
obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price})
obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_change_currency()
diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py
index 42383341828..6190f792c7f 100644
--- a/addons/account/wizard/account_fiscalyear_close.py
+++ b/addons/account/wizard/account_fiscalyear_close.py
@@ -215,7 +215,7 @@ class account_fiscalyear_close(osv.osv_memory):
cr.execute('UPDATE account_fiscalyear ' \
'SET end_journal_period_id = %s ' \
'WHERE id = %s', (ids[0], old_fyear.id))
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_fiscalyear_close()
diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py
index 9a559d039da..abf054746ce 100644
--- a/addons/account/wizard/account_fiscalyear_close_state.py
+++ b/addons/account/wizard/account_fiscalyear_close_state.py
@@ -57,7 +57,7 @@ class account_fiscalyear_close_state(osv.osv_memory):
fy_pool = self.pool.get('account.fiscalyear')
fy_code = fy_pool.browse(cr, uid, fy_id, context=context).code
fy_pool.log(cr, uid, fy_id, "Fiscal year '%s' is closed, no more modification allowed." % (fy_code))
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_fiscalyear_close_state()
diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py
index 2e7a519aa34..7adcb908a34 100644
--- a/addons/account/wizard/account_invoice_state.py
+++ b/addons/account/wizard/account_invoice_state.py
@@ -43,7 +43,7 @@ class account_invoice_confirm(osv.osv_memory):
if record['state'] not in ('draft','proforma','proforma2'):
raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state!"))
wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_invoice_confirm()
@@ -67,7 +67,7 @@ class account_invoice_cancel(osv.osv_memory):
if record['state'] in ('cancel','paid'):
raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state!"))
wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_invoice_cancel()
diff --git a/addons/account/wizard/account_open_closed_fiscalyear.py b/addons/account/wizard/account_open_closed_fiscalyear.py
index 582bbc36619..541e7b2cbdb 100644
--- a/addons/account/wizard/account_open_closed_fiscalyear.py
+++ b/addons/account/wizard/account_open_closed_fiscalyear.py
@@ -42,7 +42,7 @@ class account_open_closed_fiscalyear(osv.osv_memory):
ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
if ids_move:
cr.execute('delete from account_move where id IN %s', (tuple(ids_move),))
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_open_closed_fiscalyear()
diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py
index 3b3acecc389..5b7589d7830 100644
--- a/addons/account/wizard/account_period_close.py
+++ b/addons/account/wizard/account_period_close.py
@@ -50,7 +50,7 @@ class account_period_close(osv.osv_memory):
# Log message for Period
for period_id, name in period_pool.name_get(cr, uid, [id]):
period_pool.log(cr, uid, period_id, "Period '%s' is closed, no more modification allowed for this period." % (name))
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_period_close()
diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py
index f89ffb47a76..8131f6a9668 100644
--- a/addons/account/wizard/account_reconcile.py
+++ b/addons/account/wizard/account_reconcile.py
@@ -101,7 +101,7 @@ class account_move_line_reconcile(osv.osv_memory):
context.update({'stop_reconcile': True})
account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id,
period_id, journal_id, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_move_line_reconcile()
@@ -145,7 +145,7 @@ class account_move_line_reconcile_writeoff(osv.osv_memory):
if context is None:
context = {}
account_move_line_obj.reconcile_partial(cr, uid, context['active_ids'], 'manual', context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
def trans_rec_reconcile(self, cr, uid, ids, context=None):
account_move_line_obj = self.pool.get('account.move.line')
@@ -169,7 +169,7 @@ class account_move_line_reconcile_writeoff(osv.osv_memory):
context.update({'stop_reconcile': True})
account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id,
period_id, journal_id, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_move_line_reconcile_writeoff()
diff --git a/addons/account/wizard/account_reconcile_partner_process.py b/addons/account/wizard/account_reconcile_partner_process.py
index 9f91d1ec2d2..7cfeff70891 100644
--- a/addons/account/wizard/account_reconcile_partner_process.py
+++ b/addons/account/wizard/account_reconcile_partner_process.py
@@ -83,7 +83,7 @@ class account_partner_reconcile_process(osv.osv_memory):
res_partner_obj.write(cr, uid, partner_id[0], {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context)
#TODO: we have to find a way to update the context of the current tab (we could open a new tab with the context but it's not really handy)
#TODO: remove that comments when the client side dev is done
- return {}
+ return {'type': 'ir.actions.act_window_close'}
_columns = {
'to_reconcile': fields.float('Remaining Partners', readonly=True, help='This is the remaining partners for who you should check if there is something to reconcile or not. This figure already count the current partner as reconciled.'),
diff --git a/addons/account/wizard/account_report_account_balance.py b/addons/account/wizard/account_report_account_balance.py
index 1c3743bf3c7..a72d58dd904 100644
--- a/addons/account/wizard/account_report_account_balance.py
+++ b/addons/account/wizard/account_report_account_balance.py
@@ -19,8 +19,6 @@
#
##############################################################################
-from lxml import etree
-
from osv import osv
class account_balance_report(osv.osv_memory):
@@ -38,4 +36,4 @@ class account_balance_report(osv.osv_memory):
account_balance_report()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_report_aged_partner_balance.py b/addons/account/wizard/account_report_aged_partner_balance.py
index 5cb5d52c413..59784e6e15d 100644
--- a/addons/account/wizard/account_report_aged_partner_balance.py
+++ b/addons/account/wizard/account_report_aged_partner_balance.py
@@ -22,8 +22,6 @@
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
-from lxml import etree
-
from osv import osv, fields
from tools.translate import _
diff --git a/addons/account/wizard/account_report_balance_sheet.py b/addons/account/wizard/account_report_balance_sheet.py
index 174c172fdaa..b69c6d65d71 100644
--- a/addons/account/wizard/account_report_balance_sheet.py
+++ b/addons/account/wizard/account_report_balance_sheet.py
@@ -19,8 +19,6 @@
#
##############################################################################
-from lxml import etree
-
from osv import osv, fields
from tools.translate import _
@@ -86,4 +84,4 @@ class account_bs_report(osv.osv_memory):
account_bs_report()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_report_profit_loss.py b/addons/account/wizard/account_report_profit_loss.py
index 444d91fa8fd..c526550e789 100644
--- a/addons/account/wizard/account_report_profit_loss.py
+++ b/addons/account/wizard/account_report_profit_loss.py
@@ -19,8 +19,6 @@
#
##############################################################################
-from lxml import etree
-
from osv import osv, fields
class account_pl_report(osv.osv_memory):
@@ -60,4 +58,4 @@ class account_pl_report(osv.osv_memory):
account_pl_report()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_state_open.py b/addons/account/wizard/account_state_open.py
index 2a03a80aefa..81705771d67 100644
--- a/addons/account/wizard/account_state_open.py
+++ b/addons/account/wizard/account_state_open.py
@@ -37,7 +37,7 @@ class account_state_open(osv.osv_memory):
raise osv.except_osv(_('Warning'), _('Invoice is already reconciled'))
wf_service = netsvc.LocalService("workflow")
res = wf_service.trg_validate(uid, 'account.invoice', context['active_ids'][0], 'open_test', cr)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_state_open()
diff --git a/addons/account/wizard/account_unreconcile.py b/addons/account/wizard/account_unreconcile.py
index 3a067b4a598..0e6c38f9d7c 100644
--- a/addons/account/wizard/account_unreconcile.py
+++ b/addons/account/wizard/account_unreconcile.py
@@ -31,7 +31,7 @@ class account_unreconcile(osv.osv_memory):
context = {}
if context.get('active_ids', False):
obj_move_line._remove_move_reconcile(cr, uid, context['active_ids'], context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_unreconcile()
@@ -46,7 +46,7 @@ class account_unreconcile_reconcile(osv.osv_memory):
rec_ids = context['active_ids']
if rec_ids:
obj_move_reconcile.unlink(cr, uid, rec_ids, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
account_unreconcile_reconcile()
diff --git a/addons/account/wizard/account_validate_account_move.py b/addons/account/wizard/account_validate_account_move.py
index f840d2b5532..ddcfa2c5353 100644
--- a/addons/account/wizard/account_validate_account_move.py
+++ b/addons/account/wizard/account_validate_account_move.py
@@ -38,7 +38,7 @@ class validate_account_move(osv.osv_memory):
if not ids_move:
raise osv.except_osv(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
obj_move.button_validate(cr, uid, ids_move, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
validate_account_move()
@@ -60,7 +60,7 @@ class validate_account_move_lines(osv.osv_memory):
if not move_ids:
raise osv.except_osv(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state'))
obj_move.button_validate(cr, uid, move_ids, context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
validate_account_move_lines()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py
index 0581197aaca..1cd3022f60b 100644
--- a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py
+++ b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py
@@ -53,7 +53,7 @@ class analytic_plan_create_model(osv.osv_memory):
'target': 'new',
}
else:
- return {}
+ return {'type': 'ir.actions.act_window_close'}
analytic_plan_create_model()
diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py
index 784dd9367c7..c37a93b4be4 100644
--- a/addons/account_anglo_saxon/invoice.py
+++ b/addons/account_anglo_saxon/invoice.py
@@ -21,7 +21,7 @@
#
##############################################################################
-from osv import fields, osv
+from osv import osv
class account_invoice_line(osv.osv):
_inherit = "account.invoice.line"
diff --git a/addons/account_budget/security/account_budget_security.xml b/addons/account_budget/security/account_budget_security.xml
index 1fbcd82e86c..1d737d5ddd8 100644
--- a/addons/account_budget/security/account_budget_security.xml
+++ b/addons/account_budget/security/account_budget_security.xml
@@ -6,21 +6,21 @@
Budget post multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Budget multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Budget lines multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
diff --git a/addons/account_coda/security/account_security.xml b/addons/account_coda/security/account_security.xml
index b8fdd32ebe6..3035c8e608b 100644
--- a/addons/account_coda/security/account_security.xml
+++ b/addons/account_coda/security/account_security.xml
@@ -5,7 +5,7 @@
Account Coda model company rule
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
diff --git a/addons/account_payment/security/account_payment_security.xml b/addons/account_payment/security/account_payment_security.xml
index 5977ea36365..dcd2826a65f 100644
--- a/addons/account_payment/security/account_payment_security.xml
+++ b/addons/account_payment/security/account_payment_security.xml
@@ -10,7 +10,7 @@
Payment Mode company rule
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py
index b8328aee333..eb0d8b21926 100644
--- a/addons/account_payment/wizard/account_payment_order.py
+++ b/addons/account_payment/wizard/account_payment_order.py
@@ -65,7 +65,7 @@ class payment_order_create(osv.osv_memory):
data = self.read(cr, uid, ids, [], context=context)[0]
line_ids = data['entries']
if not line_ids:
- return {}
+ return {'type': 'ir.actions.act_window_close'}
payment = order_obj.browse(cr, uid, context['active_id'], context=context)
t = None
@@ -90,7 +90,7 @@ class payment_order_create(osv.osv_memory):
'date': date_to_pay,
'currency': line.invoice and line.invoice.currency_id.id or False,
}, context=context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
def search_entries(self, cr, uid, ids, context=None):
line_obj = self.pool.get('account.move.line')
diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py
index 6627ffaa614..ca9311b1f88 100644
--- a/addons/account_payment/wizard/account_payment_pay.py
+++ b/addons/account_payment/wizard/account_payment_pay.py
@@ -37,7 +37,7 @@ class account_payment_make_payment(osv.osv_memory):
# obj_act = self.pool.get('ir.actions.act_window')
# order = obj_payment_order.browse(cr, uid, context['active_id'], context)
obj_payment_order.set_done(cr, uid, [context['active_id']], context)
- return {}
+ return {'type': 'ir.actions.act_window_close'}
# t = order.mode and order.mode.type.code or 'manual'
# if t == 'manual':
# obj_payment_order.set_done(cr,uid,context['active_id'],context)
diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py
index f99189a8444..340ab4bcb03 100644
--- a/addons/account_payment/wizard/account_payment_populate_statement.py
+++ b/addons/account_payment/wizard/account_payment_populate_statement.py
@@ -65,7 +65,7 @@ class account_payment_populate_statement(osv.osv_memory):
data = self.read(cr, uid, ids, [], context=context)[0]
line_ids = data['lines']
if not line_ids:
- return {}
+ return {'type': 'ir.actions.act_window_close'}
statement = statement_obj.browse(cr, uid, context['active_id'], context=context)
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index ba5264d759b..12c8383445c 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -27,25 +27,6 @@ from osv import osv, fields
import decimal_precision as dp
from tools.translate import _
-class account_move_line(osv.osv):
- _inherit = 'account.move.line'
-
- def _unreconciled(self, cr, uid, ids, prop, unknow_none, context=None):
- res = {}
- for line in self.browse(cr, uid, ids, context=context):
- res[line.id] = line.debit - line.credit
- if line.reconcile_partial_id:
- res[line.id] = 0
- for partial in line.reconcile_partial_id.line_partial_ids:
- res[line.id] += partial.debit - partial.credit
- res[line.id] = abs(res[line.id])
- return res
-
- _columns = {
- 'amount_unreconciled': fields.function(_unreconciled, method=True, string='Unreconciled Amount'),
- }
-
-account_move_line()
class account_voucher(osv.osv):
@@ -165,6 +146,8 @@ class account_voucher(osv.osv):
return abs(amount - abs(credit - debit))
def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount):
+ if not line_dr_ids and not line_cr_ids:
+ return {'value':{}}
line_dr_ids = [x[2] for x in line_dr_ids]
line_cr_ids = [x[2] for x in line_cr_ids]
return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}}
@@ -491,31 +474,32 @@ class account_voucher(osv.osv):
continue
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_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':currency_pool.compute(cr, uid, company_currency, currency_id, original_amount, context=context_multi_currency),
+ 'amount_original': currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, line.currency_id and abs(line.amount_currency) or original_amount, context=context_multi_currency),
'date_original':line.date,
'date_due':line.date_maturity,
- 'amount_unreconciled':currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled, context=context_multi_currency)
+ 'amount_unreconciled': amount_unreconciled,
+
}
+
if line.credit:
- amount = min(line.amount_unreconciled, total_debit)
- rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount, context=context_multi_currency)
+ amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency))
+ rs['amount'] = amount
total_debit -= amount
else:
- amount = min(line.amount_unreconciled, total_credit)
- rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount, context=context_multi_currency)
+ amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency))
+ rs['amount'] = amount
total_credit -= amount
default['value']['line_ids'].append(rs)
@@ -687,6 +671,7 @@ 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
move_line = {
'name': inv.name or '/',
'debit': debit,
@@ -701,9 +686,7 @@ class account_voucher(osv.osv):
'date': inv.date,
'date_maturity': inv.date_due
}
- if (debit == 0.0 or credit == 0.0 or debit+credit > 0) and (debit > 0.0 or credit > 0.0):
- master_line = move_line_pool.create(cr, uid, move_line)
-
+ move_line_pool.create(cr, uid, move_line)
rec_list_ids = []
line_total = debit - credit
if inv.type == 'sale':
@@ -712,9 +695,14 @@ class account_voucher(osv.osv):
line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, 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
- amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
+ #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
+ else:
+ amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
move_line = {
'journal_id': inv.journal_id.id,
'period_id': inv.period_id.id,
@@ -753,9 +741,9 @@ class account_voucher(osv.osv):
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 <> current_currency and sign * line.amount or 0.0
- master_line = move_line_pool.create(cr, uid, move_line)
+ voucher_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_ids = [voucher_line, line.move_line_id.id]
rec_list_ids.append(rec_ids)
if not currency_pool.is_zero(cr, uid, inv.currency_id, line_total):
@@ -764,7 +752,6 @@ class account_voucher(osv.osv):
if inv.payment_option == 'with_writeoff':
account_id = inv.writeoff_acc_id.id
elif inv.type in ('sale', 'receipt'):
-# if inv.journal_id.type in ('sale','sale_refund', 'cash', 'bank'):
account_id = inv.partner_id.property_account_receivable.id
else:
account_id = inv.partner_id.property_account_payable.id
@@ -776,12 +763,11 @@ class account_voucher(osv.osv):
'date': inv.date,
'credit': diff > 0 and diff or 0.0,
'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,
+ #'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_pool.create(cr, uid, move_line)
-
self.write(cr, uid, [inv.id], {
'move_id': move_id,
'state': 'posted',
@@ -817,6 +803,8 @@ class account_voucher_line(osv.osv):
currency_pool = self.pool.get('res.currency')
rs_data = {}
for line in self.browse(cr, uid, ids, context=context):
+ 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.id
@@ -826,13 +814,15 @@ class account_voucher_line(osv.osv):
res['amount_original'] = 0.0
res['amount_unreconciled'] = 0.0
+ elif move_line.currency_id:
+ res['amount_original'] = currency_pool.compute(cr, uid, move_line.currency_id.id, voucher_currency, move_line.amount_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)
+ res['amount_original'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.credit, context=ctx)
else:
- res['amount_original'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.debit)
+ res['amount_original'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.debit, context=ctx)
if move_line:
- res['amount_unreconciled'] = currency_pool.compute(cr, uid, company_currency, voucher_currency, move_line.amount_unreconciled)
+ 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)
rs_data[line.id] = res
return rs_data
diff --git a/addons/account_voucher/report/account_voucher_sales_receipt.py b/addons/account_voucher/report/account_voucher_sales_receipt.py
index cef854aa953..06511c9a118 100644
--- a/addons/account_voucher/report/account_voucher_sales_receipt.py
+++ b/addons/account_voucher/report/account_voucher_sales_receipt.py
@@ -17,11 +17,8 @@
# along with this program. If not, see .
#
##############################################################################
-import time
from osv import fields, osv
-import pooler
-from tools import config
import tools
class sale_receipt_report(osv.osv):
diff --git a/addons/account_voucher/security/account_voucher_security.xml b/addons/account_voucher/security/account_voucher_security.xml
index df4e58484b5..d368ab858ed 100644
--- a/addons/account_voucher/security/account_voucher_security.xml
+++ b/addons/account_voucher/security/account_voucher_security.xml
@@ -5,13 +5,13 @@
Voucher multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
Voucher Line multi-company
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('company_id.child_ids','child_of',[user.company_id.id])]
diff --git a/addons/account_voucher/test/sales_receipt.yml b/addons/account_voucher/test/sales_receipt.yml
index a1793527f67..d3fd720ec6d 100644
--- a/addons/account_voucher/test/sales_receipt.yml
+++ b/addons/account_voucher/test/sales_receipt.yml
@@ -3,7 +3,7 @@
-
!record {model: account.voucher, id: account_voucher_seagate_0}:
account_id: account.a_recv
- amount: 0.0
+ amount: 30000.0
company_id: base.main_company
currency_id: base.EUR
journal_id: account.sales_journal
@@ -13,7 +13,6 @@
type: cr
partner_id: base.res_partner_seagate
period_id: account.period_9
- tax_amount: 0.0
type: sale
-
diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml
index 3a3e996975f..e73354eb59a 100644
--- a/addons/account_voucher/voucher_payment_receipt_view.xml
+++ b/addons/account_voucher/voucher_payment_receipt_view.xml
@@ -89,13 +89,13 @@