[IMP] account,point_of_sale:-improvements in the account.bank.statement and code cleaning

bzr revid: mtr@mtr-20101021070855-tkvwmvmywbgyof2f
This commit is contained in:
HMO(Openerp), MTR(OpenERP) 2010-10-21 12:38:55 +05:30 committed by mtr
parent 60d218eb27
commit 7f62b37258
2 changed files with 41 additions and 31 deletions

View File

@ -242,7 +242,7 @@ class account_cash_statement(osv.osv):
def create(self, cr, uid, vals, context=None):
sql = [
('journal_id', '=', vals['journal_id']),
('journal_id', '=', vals.get('journal_id', False)),
('state', '=', 'open')
]
open_jrnl = self.search(cr, uid, sql)
@ -317,34 +317,35 @@ class account_cash_statement(osv.osv):
else:
return True
def _user_allow(self, cr, uid, ids, statement, context={}):
def _user_allow(self, cr, uid, statement_id, context=None):
return True
def button_open(self, cr, uid, ids, context=None):
""" Changes statement state to Running.
@return: True
"""
cash_pool = self.pool.get('account.cashbox.line')
if context is None:
context = {}
statement_pool = self.pool.get('account.bank.statement')
statement = statement_pool.browse(cr, uid, ids[0])
vals = {}
for statement in statement_pool.browse(cr, uid, ids, context=context):
vals = {}
if not self._user_allow(cr, uid, ids, statement, context={}):
raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name)))
if not self._user_allow(cr, uid, statement.id, context=context):
raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name)))
if statement.name and statement.name == '/':
number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement')
vals.update({
'name': number
})
if statement.name and statement.name == '/':
number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement')
vals.update({
'name': number
'date':time.strftime("%Y-%m-%d %H:%M:%S"),
'state':'open',
})
vals.update({
'date':time.strftime("%Y-%m-%d %H:%M:%S"),
'state':'open',
})
return self.write(cr, uid, ids, vals)
self.write(cr, uid, [statement.id], vals)
return True
def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None):
if journal_type == 'bank':
@ -381,4 +382,4 @@ class account_cash_statement(osv.osv):
account_cash_statement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,13 +28,13 @@ class account_journal(osv.osv):
_inherit = 'account.journal'
_columns = {
'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
'special_journal':fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
'special_journal': fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
'journal_users': fields.many2many('res.users','pos_journal_users','journal_id','user_id','Users'),
}
_defaults = {
'check_dtls': lambda *a:False,
'auto_cash': lambda *a:True,
'check_dtls': False,
'auto_cash': True,
}
account_journal()
@ -42,7 +42,9 @@ class account_cash_statement(osv.osv):
_inherit = 'account.bank.statement'
def _equal_balance(self, cr, uid, cash_id, context={}):
def _equal_balance(self, cr, uid, cash_id, context=None):
if context is None:
context = {}
statement = self.browse(cr, uid, cash_id, context=context)
if not statement.journal_id.check_dtls:
return True
@ -52,9 +54,12 @@ class account_cash_statement(osv.osv):
else:
return True
def _user_allow(self, cr, uid, ids, statement, context={}):
def _user_allow(self, cr, uid, statement_id, context=None):
if context is None:
context = {}
res = False
uids = []
statement = self.browse(cr, uid, statement_id, context=context)
for user in statement.journal_id.journal_users:
uids.append(user.id)
@ -63,25 +68,29 @@ class account_cash_statement(osv.osv):
return res
def _get_cash_open_box_lines(self, cr, uid, context={}):
def _get_cash_open_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
res = super(account_cash_statement,self)._get_cash_open_box_lines(cr, uid, context)
curr = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50]
for rs in curr:
dct = {
'pieces':rs,
'number':0
'pieces': rs,
'number': 0
}
res.append(dct)
res.sort()
return res
def _get_default_cash_close_box_lines(self, cr, uid, context={}):
def _get_default_cash_close_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
res = super(account_cash_statement,self)._get_default_cash_close_box_lines(cr, uid, context)
curr = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50]
for rs in curr:
dct = {
'pieces':rs,
'number':0
'pieces': rs,
'number': 0
}
res.append(dct)
res.sort()
@ -89,4 +98,4 @@ class account_cash_statement(osv.osv):
account_cash_statement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: