diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index c538614fd0f..019af2cdef5 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -73,7 +73,6 @@ for a particular financial year and for preparation of vouchers there is a modul 'wizard/account_fiscalyear_close_state.xml', 'wizard/account_chart_view.xml', 'wizard/account_tax_chart_view.xml', - 'wizard/account_move_journal_view.xml', 'wizard/account_move_line_reconcile_select_view.xml', 'wizard/account_open_closed_fiscalyear_view.xml', 'wizard/account_move_line_unreconcile_select_view.xml', @@ -128,9 +127,11 @@ for a particular financial year and for preparation of vouchers there is a modul ], 'js': [ 'static/src/js/account_move_reconciliation.js', + 'static/src/js/account_move_line_quickadd.js', ], 'qweb' : [ "static/src/xml/account_move_reconciliation.xml", + "static/src/xml/account_move_line_quickadd.xml", ], 'css':['static/src/css/account_move_reconciliation.css' ], diff --git a/addons/account/account.py b/addons/account/account.py index cfba30856a9..30e0b784de8 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -738,7 +738,7 @@ class account_journal(osv.osv): " Select 'Opening/Closing Situation' for entries generated for new fiscal years."), 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]), 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]), - 'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), + #'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), 'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"), 'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"), 'centralisation': fields.boolean('Centralised Counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."), diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 98521eb41a8..9a67a3c9b19 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -551,6 +551,33 @@ class account_move_line(osv.osv): cur = self.pool.get('account.journal').browse(cr, uid, context['journal_id']).currency return cur and cur.id or False + def _get_period(self, cr, uid, context=None): + """ + Return default account period value + """ + account_period_obj = self.pool.get('account.period') + ids = account_period_obj.find(cr, uid, context=context) + period_id = False + if ids: + period_id = ids[0] + return period_id + + def _get_journal(self, cr, uid, context=None): + """ + Return journal based on the journal type + """ + + journal_id = False + + journal_pool = self.pool.get('account.journal') + if context.get('journal_type', False): + jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))]) + if not jids: + raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type')) + journal_id = jids[0] + return journal_id + + _defaults = { 'blocked': False, 'centralisation': 'normal', @@ -558,12 +585,12 @@ class account_move_line(osv.osv): 'date_created': fields.date.context_today, 'state': 'draft', 'currency_id': _get_currency, - 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False), + 'journal_id': _get_journal, 'credit': 0.0, 'debit': 0.0, 'amount_currency': 0.0, 'account_id': lambda self, cr, uid, c: c.get('account_id', False), - 'period_id': lambda self, cr, uid, c: c.get('period_id', False), + 'period_id': _get_period, 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) } _order = "date desc, id desc" @@ -1383,6 +1410,20 @@ class account_move_line(osv.osv): move_obj.button_validate(cr,uid, [vals['move_id']], context) return result + def list_periods(self, cr, uid, context=None): + ids = self.pool.get('account.period').search(cr,uid,[]) + return self.pool.get('account.period').name_get(cr, uid, ids, context=context) + + def list_journals(self, cr, uid, context=None): + ng = dict(self.pool.get('account.journal').name_search(cr,uid,'',[])) + ids = ng.keys() + result = [] + print ng + for journal in self.pool.get('account.journal').browse(cr, uid, ids, context=context): + result.append((journal.id,ng[journal.id],journal.type, + bool(journal.currency),bool(journal.analytic_journal_id))) + return result + account_move_line() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index fe40121eaeb..164a5fb30d7 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -489,7 +489,6 @@ - @@ -1063,76 +1062,31 @@ - account.move.line.tree account.move.line - - - + - - - - - - - - - + + + + + + + + + + - - - + + + + @@ -1302,8 +1256,8 @@ Sale Refund : Journal Items account.move.line form - tree,form - {} + tree_account_move_line_quickadd + {'journal_type':'general','view_mode':True}

@@ -1327,39 +1281,6 @@ Sale Refund : groups="group_account_user" /> - - Journal Items - account.move.journal - form - {'journal_type':'sale'} - This view is used by accountants in order to record entries massively in OpenERP. If you want to record a customer invoice, select the journal and the period in the search toolbar. Then, start by recording the entry line of the income account. OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account receivable". - - - - - Journal Items - account.move.journal - form - {'journal_type':'purchase'} - 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". - - - - - Journal Items - account.move.journal - form - {'journal_type':'bank'} - This view is used by accountants in order to record entries massively in OpenERP. Journal items are created by OpenERP if you use Bank Statements, Cash Registers, or Customer/Supplier payments. - - - Lines to reconcile account.move.line @@ -1638,6 +1559,7 @@ Sale Refund :

+ + + + + + + + + diff --git a/addons/account/test/account_validate_account_move.yml b/addons/account/test/account_validate_account_move.yml index df58da6dfea..f5dbbbc92db 100644 --- a/addons/account/test/account_validate_account_move.yml +++ b/addons/account/test/account_validate_account_move.yml @@ -32,8 +32,8 @@ import time date = self._get_date(cr, uid, {'lang': u'en_US', 'normal_view': False, 'active_model': 'ir.ui.menu', 'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'journal_id': 1, 'view_mode': False, - 'visible_id': 1, 'period_id': 6, 'tz': False, 'active_ids': [ref('menu_eaction_account_moves_sale')], - 'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')}) + 'visible_id': 1, 'period_id': 6, 'tz': False, 'active_ids': [ref('action_account_manual_account_move_line_quickadd')], + 'search_default_posted': 0, 'active_id': ref('action_account_manual_account_move_line_quickadd')}) partner = self.onchange_partner_id(cr, uid, [], False, ref('base.res_partner_12'), ref('account.cash'), debit=0, credit=2000, date=date, journal=False) account = self.onchange_account_id(cr, uid, [], account_id=ref('account.a_recv'), partner_id= ref('base.res_partner_12')) vals = { @@ -62,11 +62,11 @@ !python {model: account.move.line}: | ids = self._balance_search(cr, uid, self, 'balance', [('balance', '=', 2000.0)], None, {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False, 'visible_id': 1, - 'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')}) + 'active_ids': [ref('action_account_manual_account_move_line_quickadd')], 'search_default_posted': 0, 'active_id': ref('action_account_manual_account_move_line_quickadd')}) bal = self._balance(cr, uid, ids[0][2], 'balance', None,{'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu', 'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False, - 'visible_id': 1, 'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0, - 'active_id': ref('menu_eaction_account_moves_sale')}) + 'visible_id': 1, 'active_ids': [ref('action_account_manual_account_move_line_quickadd')], 'search_default_posted': 0, + 'active_id': ref('action_account_manual_account_move_line_quickadd')}) assert bal, 'Balance has not been computed correctly' - I check that Initially account move state is "Draft"