[IMP] improve the account wizards code
bzr revid: mra@tinyerp.com-20100429063555-f6k66u6ymcfxxfiz
This commit is contained in:
parent
0f71b214ab
commit
3f91b61274
|
@ -55,11 +55,11 @@ class account_aged_trial_balance(osv.osv_memory):
|
|||
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults = {
|
||||
'company_id' : _get_company,
|
||||
'period_length' : 30,
|
||||
'company_id': _get_company,
|
||||
'period_length': 30,
|
||||
'date1' : time.strftime('%Y-%m-%d'),
|
||||
'result_selection' : 'all',
|
||||
'direction_selection' : 'past',
|
||||
'result_selection': 'all',
|
||||
'direction_selection': 'past',
|
||||
}
|
||||
|
||||
def calc_dates(self, cr, uid, ids, context=None):
|
||||
|
@ -103,4 +103,5 @@ class account_aged_trial_balance(osv.osv_memory):
|
|||
}
|
||||
|
||||
account_aged_trial_balance()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
#
|
||||
##############################################################################
|
||||
import time
|
||||
import netsvc
|
||||
|
||||
import netsvc
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class account_automatic_reconcile(osv.osv_memory):
|
||||
|
||||
_name = 'account.automatic.reconcile'
|
||||
_description = 'Automatic Reconcile'
|
||||
|
||||
|
@ -240,4 +239,5 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
}
|
||||
|
||||
account_automatic_reconcile()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -18,7 +18,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
|
@ -40,7 +39,7 @@ class account_central_journal(osv.osv_memory):
|
|||
period_id = datas['form']['period_id']
|
||||
journal_id = datas['form']['journal_id']
|
||||
|
||||
if type(period_id)==type([]):
|
||||
if isinstance(period_id, list):
|
||||
ids_final = []
|
||||
for journal in journal_id:
|
||||
for period in period_id:
|
||||
|
@ -58,6 +57,4 @@ class account_central_journal(osv.osv_memory):
|
|||
|
||||
account_central_journal()
|
||||
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -71,4 +71,4 @@ class account_change_currency(osv.osv_memory):
|
|||
|
||||
account_change_currency()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -38,7 +38,7 @@ class account_chart(osv.osv_memory):
|
|||
], 'Target Moves', required = True),
|
||||
|
||||
}
|
||||
def _get_defaults(self, cr, uid, context={}):
|
||||
def _get_defaults(self, cr, uid, context=None):
|
||||
"""Return default Fiscalyear value"""
|
||||
fiscalyear_obj = self.pool.get('account.fiscalyear')
|
||||
fiscalyear = fiscalyear_obj.find(cr, uid)
|
||||
|
@ -64,10 +64,10 @@ class account_chart(osv.osv_memory):
|
|||
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']],context=context)[0]['code']
|
||||
return result
|
||||
|
||||
|
||||
_defaults = {
|
||||
'fiscalyear': _get_defaults,
|
||||
'target_move': lambda * a: 'all'
|
||||
'target_move': 'all'
|
||||
}
|
||||
account_chart()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -140,5 +140,4 @@ class account_compare_account_balance_report(osv.osv_memory):
|
|||
}
|
||||
account_compare_account_balance_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -35,7 +35,7 @@ class account_fiscalyear_close_state(osv.osv_memory):
|
|||
'sure': fields.boolean('Check this box', required=False)
|
||||
}
|
||||
|
||||
def data_save(self, cr, uid, ids, context={}):
|
||||
def data_save(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
This function close account fiscalyear
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
|
|
@ -30,7 +30,7 @@ class account_general_journal(osv.osv_memory):
|
|||
'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
|
||||
}
|
||||
|
||||
def check_data(self, cr, uid, ids, context={}):
|
||||
def check_data(self, cr, uid, ids, context=None):
|
||||
obj_jperiod = self.pool.get('account.journal.period')
|
||||
datas = {}
|
||||
datas['ids'] = []
|
||||
|
|
|
@ -34,7 +34,7 @@ class account_invoice_refund(osv.osv_memory):
|
|||
'description': fields.char('Description', size=150, required=True),
|
||||
}
|
||||
|
||||
def compute_refund(self, cr, uid, ids, mode, context={}):
|
||||
def compute_refund(self, cr, uid, ids, mode, context=None):
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
|
@ -46,7 +46,11 @@ class account_invoice_refund(osv.osv_memory):
|
|||
account_m_line_obj = self.pool.get('account.move.line')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
act_obj = self.pool.get('ir.actions.act_window')
|
||||
for form in self.read(cr, uid, ids,context=context):
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
for form in self.read(cr, uid, ids, context=context):
|
||||
created_inv = []
|
||||
date = False
|
||||
period = False
|
||||
|
@ -171,7 +175,6 @@ class account_invoice_refund(osv.osv_memory):
|
|||
id = mod_obj.read(cr, uid, result, ['res_id'],context=context)['res_id']
|
||||
result = act_obj.read(cr, uid, id,context=context)
|
||||
result['res_id'] = created_inv
|
||||
|
||||
return result
|
||||
|
||||
def invoice_refund(self, cr, uid, ids, context={}):
|
||||
|
|
|
@ -34,29 +34,29 @@ class account_move_bank_reconcile(osv.osv_memory):
|
|||
}
|
||||
|
||||
def action_open_window(self, cr, uid, ids, context={}):
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: account move bank reconcile’s ID or list of IDs
|
||||
@return: dictionary of Open account move line on given journal_id.
|
||||
"""
|
||||
for data in self.read(cr, uid, ids,context=context):
|
||||
cr.execute('select default_credit_account_id \
|
||||
from account_journal where id=%s', (data['journal_id'],))
|
||||
account_id = cr.fetchone()[0]
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Error'), _('You have to define \
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: account move bank reconcile’s ID or list of IDs
|
||||
@return: dictionary of Open account move line on given journal_id.
|
||||
"""
|
||||
data = self.read(cr, uid, ids,context=context)[0]
|
||||
cr.execute('select default_credit_account_id \
|
||||
from account_journal where id=%s', (data['journal_id'],))
|
||||
account_id = cr.fetchone()[0]
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Error'), _('You have to define \
|
||||
the bank account\nin the journal definition for reconciliation.'))
|
||||
return {
|
||||
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id),
|
||||
'name': _('Standard Encoding'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': False,
|
||||
'context': "{'journal_id': %d}" % (data['journal_id'],),
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
return {
|
||||
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id),
|
||||
'name': _('Standard Encoding'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': False,
|
||||
'context': "{'journal_id': %d}" % (data['journal_id'],),
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
account_move_bank_reconcile()
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ class account_move_journal(osv.osv_memory):
|
|||
'search_view_id': res['res_id']
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'period_id': _get_period
|
||||
}
|
||||
|
|
|
@ -71,5 +71,4 @@ class account_move_line_select(osv.osv_memory):
|
|||
|
||||
account_move_line_select()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -23,15 +23,12 @@ from osv import fields, osv
|
|||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
|
||||
class account_move_line_unreconcile_select(osv.osv_memory):
|
||||
|
||||
_name = "account.move.line.unreconcile.select"
|
||||
_description = "Unreconciliation"
|
||||
_columns ={
|
||||
'account_id': fields.many2one('account.account','Account',required=True),
|
||||
}
|
||||
|
||||
def action_open_window(self, cr, uid, ids, context={}):
|
||||
data = self.read(cr, uid, ids, context=context)[0]
|
||||
return {
|
||||
|
@ -46,6 +43,4 @@ class account_move_line_unreconcile_select(osv.osv_memory):
|
|||
|
||||
account_move_line_unreconcile_select()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -18,12 +18,10 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class account_open_closed_fiscalyear(osv.osv_memory):
|
||||
|
||||
_name = "account.open.closed.fiscalyear"
|
||||
_description = "Choose Fiscal Year"
|
||||
_columns = {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from tools.translate import _
|
||||
|
@ -58,13 +57,13 @@ class account_partner_balance(osv.osv_memory):
|
|||
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults={
|
||||
'state' : 'none',
|
||||
'date1' : time.strftime('%Y-01-01'),
|
||||
'date2' : time.strftime('%Y-%m-%d'),
|
||||
'result_selection' : 'all',
|
||||
'soldeinit' : True,
|
||||
'company_id' : _get_company,
|
||||
'fiscalyear' : False,
|
||||
'state' : 'none',
|
||||
'date1' : time.strftime('%Y-01-01'),
|
||||
'date2' : time.strftime('%Y-%m-%d'),
|
||||
'result_selection' : 'all',
|
||||
'soldeinit' : True,
|
||||
'company_id' : _get_company,
|
||||
'fiscalyear' : False,
|
||||
}
|
||||
|
||||
def check_state(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -32,7 +32,7 @@ class account_period_close(osv.osv_memory):
|
|||
'sure': fields.boolean('Check this box'),
|
||||
}
|
||||
|
||||
def data_save(self, cr, uid, ids, context={}):
|
||||
def data_save(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
This function close period
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
@ -41,7 +41,7 @@ class account_period_close(osv.osv_memory):
|
|||
"""
|
||||
|
||||
mode = 'done'
|
||||
for form in self.read(cr, uid, ids,context=context):
|
||||
for form in self.read(cr, uid, ids, context=context):
|
||||
if form['sure']:
|
||||
for id in context['active_ids']:
|
||||
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
|
||||
|
|
|
@ -34,10 +34,10 @@ class account_print_journal(osv.osv_memory):
|
|||
}
|
||||
|
||||
_defaults = {
|
||||
'sort_selection': lambda *a: 'date',
|
||||
}
|
||||
'sort_selection': lambda *a: 'date',
|
||||
}
|
||||
|
||||
def check_data(self, cr, uid, ids, context={}):
|
||||
def check_data(self, cr, uid, ids, context=None):
|
||||
obj_jperiod = self.pool.get('account.journal.period')
|
||||
datas = {}
|
||||
datas['ids'] = []
|
||||
|
|
|
@ -43,7 +43,7 @@ class account_vat_declaration(osv.osv_memory):
|
|||
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults = {
|
||||
'based_on': lambda *a: 'invoices',
|
||||
'based_on': 'invoices',
|
||||
'company_id': _get_company
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue