diff --git a/addons/account/account.py b/addons/account/account.py
index 1178712362e..61851b30f1f 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -248,59 +248,59 @@ class account_account(osv.osv):
def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
query='', query_params=()):
- """ compute the balance, debit and/or credit for the provided
- account ids
- Arguments:
- `ids`: account ids
- `field_names`: the fields to compute (a list of any of
- 'balance', 'debit' and 'credit')
- `arg`: unused fields.function stuff
- `query`: additional query filter (as a string)
- `query_params`: parameters for the provided query string
- (__compute will handle their escaping) as a
- tuple
- """
- mapping = {
- 'balance': "COALESCE(SUM(l.debit),0) " \
- "- COALESCE(SUM(l.credit), 0) as balance",
- 'debit': "COALESCE(SUM(l.debit), 0) as debit",
- 'credit': "COALESCE(SUM(l.credit), 0) as credit"
- }
- #get all the necessary accounts
- children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
- #compute for each account the balance/debit/credit from the move lines
- accounts = {}
- if children_and_consolidated:
- aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ """ compute the balance, debit and/or credit for the provided
+ account ids
+ Arguments:
+ `ids`: account ids
+ `field_names`: the fields to compute (a list of any of
+ 'balance', 'debit' and 'credit')
+ `arg`: unused fields.function stuff
+ `query`: additional query filter (as a string)
+ `query_params`: parameters for the provided query string
+ (__compute will handle their escaping) as a
+ tuple
+ """
+ mapping = {
+ 'balance': "COALESCE(SUM(l.debit),0) " \
+ "- COALESCE(SUM(l.credit), 0) as balance",
+ 'debit': "COALESCE(SUM(l.debit), 0) as debit",
+ 'credit': "COALESCE(SUM(l.credit), 0) as credit"
+ }
+ #get all the necessary accounts
+ children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
+ #compute for each account the balance/debit/credit from the move lines
+ accounts = {}
+ if children_and_consolidated:
+ aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
- wheres = [""]
- if query.strip():
- wheres.append(query.strip())
- if aml_query.strip():
- wheres.append(aml_query.strip())
- filters = " AND ".join(wheres)
- self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
- 'Filters: %s'%filters)
- # IN might not work ideally in case there are too many
- # children_and_consolidated, in that case join on a
- # values() e.g.:
- # SELECT l.account_id as id FROM account_move_line l
- # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
- # ON l.account_id = tmp.id
- # or make _get_children_and_consol return a query and join on that
- request = ("SELECT l.account_id as id, " +\
- ' , '.join(map(mapping.__getitem__, field_names)) +
- " FROM account_move_line l" \
- " WHERE l.account_id IN %s " \
- + filters +
- " GROUP BY l.account_id")
- params = (tuple(children_and_consolidated),) + query_params
- cr.execute(request, params)
- self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
- 'Status: %s'%cr.statusmessage)
+ wheres = [""]
+ if query.strip():
+ wheres.append(query.strip())
+ if aml_query.strip():
+ wheres.append(aml_query.strip())
+ filters = " AND ".join(wheres)
+ self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
+ 'Filters: %s'%filters)
+ # IN might not work ideally in case there are too many
+ # children_and_consolidated, in that case join on a
+ # values() e.g.:
+ # SELECT l.account_id as id FROM account_move_line l
+ # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
+ # ON l.account_id = tmp.id
+ # or make _get_children_and_consol return a query and join on that
+ request = ("SELECT l.account_id as id, " +\
+ ' , '.join(map(mapping.__getitem__, field_names)) +
+ " FROM account_move_line l" \
+ " WHERE l.account_id IN %s " \
+ + filters +
+ " GROUP BY l.account_id")
+ params = (tuple(children_and_consolidated),) + query_params
+ cr.execute(request, params)
+ self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
+ 'Status: %s'%cr.statusmessage)
- for res in cr.dictfetchall():
- accounts[res['id']] = res
+ for res in cr.dictfetchall():
+ accounts[res['id']] = res
# consolidate accounts with direct children
children_and_consolidated.reverse()
@@ -2539,9 +2539,9 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'account_paid_id': acc_template_ref[value['account_paid_id']],
})
- # Creating Journals
+ # Creating Journals Sales and Purchase
vals_journal={}
- data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_view')])
+ data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
data = data_pool.browse(cr, uid, data_id[0])
view_id = data.res_id
@@ -2573,6 +2573,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
vals_journal['type'] = 'purchase'
vals_journal['code'] = _('EXJ')
vals_journal['sequence_id'] = seq_id_purchase
+ vals_journal['view_id'] = view_id
if obj_multi.chart_template_id.property_account_payable:
vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index bf12bdc2087..76989d2f02c 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -183,7 +183,7 @@ class account_move_line(osv.osv):
# Compute the current move
move_id = False
partner_id = False
- if context.get('journal_id',False) and context.get('period_id',False):
+ if context.get('journal_id', False) and context.get('period_id', False):
if 'move_id' in fields:
cr.execute('select move_id \
from \
@@ -199,6 +199,7 @@ class account_move_line(osv.osv):
return data
else:
data['move_id'] = move_id
+
if 'date' in fields:
cr.execute('select date \
from \
@@ -214,7 +215,6 @@ class account_move_line(osv.osv):
period = period_obj.browse(cr, uid, context['period_id'],
context=context)
data['date'] = period.date_start
-
if not move_id:
return data
@@ -786,6 +786,31 @@ class account_move_line(osv.osv):
return j+(p and (':'+p) or '')
return False
+# def onchange_date(self, cr, user, ids, date, context={}):
+# """
+# Returns a dict that contains new values and context
+# @param cr: A database cursor
+# @param user: ID of the user currently logged in
+# @param date: latest value from user input for field date
+# @param args: other arguments
+# @param context: context arguments, like lang, time zone
+# @return: Returns a dict which contains new values, and context
+# """
+# res = {}
+# period_pool = self.pool.get('account.period')
+# pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
+# if pids:
+# res.update({
+# 'period_id':pids[0]
+# })
+# context.update({
+# 'period_id':pids[0]
+# })
+# return {
+# 'value':res,
+# 'context':context,
+# }
+
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu)
if view_type != 'tree':
@@ -848,11 +873,14 @@ class account_move_line(osv.osv):
elif field == 'credit':
attrs.append('sum="Total credit"')
elif field == 'account_tax_id':
- attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
+ attrs.append('domain="[(\'parent_id\',\'=\',False), (\'type_tax_use\',\'=\',context.get(journal_id.type, \'sale\'))]"')
elif field == 'account_id' and journal.id:
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
elif field == 'partner_id':
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
+# elif field == 'date':
+# attrs.append('on_change="onchange_date(date)"')
+
# if field.readonly:
# attrs.append('readonly="1"')
# if field.required:
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 93567fb2b5a..be650a4613f 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -269,9 +269,9 @@
-
-
-
+
+
+
@@ -283,8 +283,8 @@
-
-
+
+
@@ -295,11 +295,18 @@
form
+
+ Journal Views
+ account.journal.view
+ form
+ tree,form
+
+