diff --git a/addons/account/account.py b/addons/account/account.py index b050f43ad4e..5fc97a13697 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1027,6 +1027,33 @@ class account_move(osv.osv): _description = "Account Entry" _order = 'id desc' + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): + """ + Returns a list of tupples containing id, name, as internally it is called {def name_get} + result format : {[(id, name), (id, name), ...]} + + @param cr: A database cursor + @param user: ID of the user currently logged in + @param name: name to search + @param args: other arguments + @param operator: default operator is 'ilike', it can be changed + @param context: context arguments, like lang, time zone + @param limit: Returns first 'n' ids of complete result, default is 80. + + @return: Returns a list of tupples containing id and name + """ + + if not args: + args=[] + if not context: + context={} + ids = [] + + if name: + ids += self.search(cr, user, [('state','=','draft'), ('id','=',name)], limit=limit) + + return self.name_get(cr, user, ids, context=context) + def name_get(self, cursor, user, ids, context=None): if not len(ids): return [] @@ -2205,7 +2232,6 @@ class account_add_tmpl_wizard(osv.osv_memory): def _get_def_cparent(self, cr, uid, context): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') - #print "Searching for ",context tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) if not tids or not tids[0]['parent_id']: return False @@ -2247,7 +2273,6 @@ class account_add_tmpl_wizard(osv.osv_memory): # 'tax_ids': [(6,0,tax_ids)], todo!! 'company_id': company_id, } - # print "Creating:", vals new_account = acc_obj.create(cr, uid, vals) return {'type':'state', 'state': 'end' } diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index d3dd4f1ee78..d122da7d19e 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -407,7 +407,7 @@ class account_move_line(osv.osv): 'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')), 'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')), 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2), - 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2), + 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", help="The move of this entry line.", select=2), 'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Narration'), 'ref': fields.char('Ref.', size=64), 'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1), @@ -560,7 +560,7 @@ class account_move_line(osv.osv): #if jt in ('sale', 'purchase_refund', 'bank', 'cash'): if jt in ('sale', 'purchase_refund'): val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2) - elif jt in ('purchase', 'sale_refund', 'expense'): + elif jt in ('purchase', 'sale_refund', 'expense', 'bank', 'cash'): val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1) if val.get('account_id', False): @@ -798,30 +798,30 @@ 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 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) @@ -882,20 +882,29 @@ class account_move_line(osv.osv): attrs = [] if field == 'debit': attrs.append('sum="Total debit"') + elif field == 'credit': attrs.append('sum="Total credit"') + elif field == 'account_tax_id': attrs.append('domain="[(\'parent_id\',\'=\',False)]"') attrs.append("context=\"{'journal_id':journal_id}\"") + 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 == 'journal_id': attrs.append("context=\"{'journal_id':journal_id}\"") + elif field == 'statement_id': attrs.append("domain=\"[('state','!=','confirm'),('journal_id.type','=','bank')]\"") - + + elif field == 'date': + attrs.append('on_change="onchange_date(date)"') + if field in ('amount_currency', 'currency_id'): attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"') diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index daf4ebcac26..68e9cc3ba7e 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1048,7 +1048,7 @@ - + Entry Lines @@ -1058,9 +1058,10 @@ - + + @@ -1073,8 +1074,8 @@ - - + + @@ -1377,29 +1378,29 @@ --> - - Journal Items - account.move.line - form - tree,form,graph - - - [('journal_id.type', 'in', ['sale', 'purchase_refund'])] - + + + + + + + + + - + - - Journal Items - account.move.line - form - tree,form,graph - - - [('journal_id.type', 'in', ['purchase', 'sale_refund'])] - + + + + + + + + + - + Entry Lines @@ -2416,22 +2417,22 @@ id="menu_action_account_fiscal_position_form_template" parent="account_template_folder" sequence="20"/> - - Journal Items - account.move.line - form - tree,form,graph - - - + + + + + + + + - + + + + + + + diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index fa4f24effc1..5af4787c6a6 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -48,7 +48,6 @@ - !record {model: account.move.journal, id: account_move_journal_0}: journal_id: account.sales_journal - period_id: account_period_jan11 - I clicked on Open Journal Button to check the entries diff --git a/addons/account/wizard/account_journal_select_view.xml b/addons/account/wizard/account_journal_select_view.xml index f5df24fa585..348218dd04d 100644 --- a/addons/account/wizard/account_journal_select_view.xml +++ b/addons/account/wizard/account_journal_select_view.xml @@ -8,11 +8,11 @@ form
-