diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 3f608c62e7c..d4a731fb3b7 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -1170,7 +1170,7 @@
-
+
account.move.line
form
tree,form
+ {'search_default_posted': 1}
This view is used by accountants in order to record entries massively in OpenERP. If you want to record a supplier invoice, start by recording the line of the expense account, OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account Payable".
diff --git a/addons/account/installer.py b/addons/account/installer.py
index b1be04f7c70..0301126a373 100644
--- a/addons/account/installer.py
+++ b/addons/account/installer.py
@@ -95,6 +95,25 @@ class account_installer(osv.osv_memory):
'bank_accounts_id': _get_default_accounts,
'charts': _get_default_charts
}
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ res = super(account_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+ configured_cmp = []
+ unconfigured_cmp = []
+ cmp_select = []
+ company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
+ cr.execute("SELECT company_id FROM account_account WHERE account_account.parent_id IS NULL")
+ for r in cr.fetchall():
+ configured_cmp.append(r[0])
+ unconfigured_cmp = list(set(company_ids)-set(configured_cmp))
+ if unconfigured_cmp:
+ for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp):
+ cmp_select.append((line.id,line.name))
+ for field in res['fields']:
+ if field == 'company_id':
+ res['fields'][field]['domain'] = unconfigured_cmp
+ res['fields'][field]['selection'] = cmp_select
+ return res
def on_change_tax(self, cr, uid, id, tax):
return {'value': {'purchase_tax': tax}}
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index 3f675f90a07..706b357465f 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -1312,6 +1312,7 @@ class account_invoice_line(osv.osv):
if context is None:
context = {}
company_id = context.get('company_id',False)
+ tax_obj = self.pool.get('account.tax')
if not partner_id:
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
@@ -1400,17 +1401,24 @@ class account_invoice_line(osv.osv):
if a:
result['account_id'] = a
+ tax_ids = tax_obj.search(cr, uid, [('company_id', '=', company_id)])
if type in ('out_invoice', 'out_refund'):
- taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
+ sale_taxes_def = map(lambda x: x.id, res.taxes_id)
+ sale_tax_ids = [tax for tax in tax_ids if tax in sale_taxes_def]
+ sale_taxes = tax_obj.browse(cr, uid, sale_tax_ids)
+ sale_taxes_all = sale_taxes and sale_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, sale_taxes_all)
else:
- taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
+ pur_taxes_def = map(lambda x: x.id, res.supplier_taxes_id)
+ pur_tax_ids = [tax for tax in tax_ids if tax in pur_taxes_def]
+ pur_taxes = tax_obj.browse(cr, uid, pur_tax_ids)
+ pur_taxes_all = pur_taxes and pur_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, pur_taxes_all)
+
if type in ('in_invoice', 'in_refund'):
result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} )
else:
result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id})
-
# if not name:
result['name'] = res.partner_ref
diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py
index 0c280d2edfd..8816d702118 100644
--- a/addons/account/report/account_balance_sheet.py
+++ b/addons/account/report/account_balance_sheet.py
@@ -60,6 +60,13 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header)
})
self.context = context
+ def set_context(self, objects, data, ids, report_type=None):
+ new_ids = ids
+ if (data['model'] == 'ir.ui.menu'):
+ new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or []
+ objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
+ return super(report_balancesheet_horizontal, self).set_context(objects, data, new_ids, report_type=report_type)
+
def sum_dr(self):
if self.res_bl['type'] == _('Net Profit'):
self.result_sum_dr += self.res_bl['balance']*-1
diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py
index 80065880ad9..a6936c74210 100644
--- a/addons/account/report/account_entries_report.py
+++ b/addons/account/report/account_entries_report.py
@@ -94,7 +94,7 @@ class account_entries_report(osv.osv):
return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
context=context, count=count)
- def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
+ def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
todel=[]
fiscalyear_obj = self.pool.get('account.fiscalyear')
period_obj = self.pool.get('account.period')
@@ -112,7 +112,7 @@ class account_entries_report(osv.osv):
for a in [['period_id','in','current_year'], ['period_id','in','current_period']]:
if a in domain:
domain.remove(a)
- return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
+ return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
def init(self, cr):
tools.drop_view_if_exists(cr, 'account_entries_report')
diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py
index 7c8248b8275..d9d6226904a 100644
--- a/addons/account/report/account_profit_loss.py
+++ b/addons/account/report/account_profit_loss.py
@@ -56,6 +56,13 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header):
})
self.context = context
+ def set_context(self, objects, data, ids, report_type=None):
+ new_ids = ids
+ if (data['model'] == 'ir.ui.menu'):
+ new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or []
+ objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
+ return super(report_pl_account_horizontal, self).set_context(objects, data, new_ids, report_type=report_type)
+
def final_result(self):
return self.res_pl
diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py
index f4c360cd253..e8f0e432d69 100644
--- a/addons/account/wizard/account_chart.py
+++ b/addons/account/wizard/account_chart.py
@@ -33,8 +33,9 @@ class account_chart(osv.osv_memory):
help = 'Keep empty for all open fiscal years'),
'period_from': fields.many2one('account.period', 'Start period'),
'period_to': fields.many2one('account.period', 'End period'),
- 'target_move': fields.selection([('all', 'All Entries'),
- ('posted', 'All Posted Entries')], 'Target Moves', required = True),
+ 'target_move': fields.selection([('posted', 'All Posted Entries'),
+ ('all', 'All Entries'),
+ ], 'Target Moves', required = True),
}
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, context=None):
@@ -92,7 +93,7 @@ class account_chart(osv.osv_memory):
return result
_defaults = {
- 'target_move': 'all'
+ 'target_move': 'posted'
}
account_chart()
diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py
index 72ae65f83b9..5f4616075fc 100644
--- a/addons/account/wizard/account_move_journal.py
+++ b/addons/account/wizard/account_move_journal.py
@@ -21,7 +21,7 @@
from lxml import etree
-from osv import osv
+from osv import osv, fields
from tools.translate import _
import tools
@@ -29,6 +29,15 @@ class account_move_journal(osv.osv_memory):
_name = "account.move.journal"
_description = "Move journal"
+ _columns = {
+ 'target_move': fields.selection([('posted', 'All Posted Entries'),
+ ('all', 'All Entries'),
+ ], 'Target Moves', required=True),
+ }
+
+ _defaults = {
+ 'target_move': 'posted'
+ }
def _get_period(self, cr, uid, context={}):
"""
Return default account period value
@@ -93,6 +102,8 @@ class account_move_journal(osv.osv_memory):
view = """