[IMP] cleaning

bzr revid: mra@mra-laptop-20100702105558-crcx44t8os32erv9
This commit is contained in:
Mustufa Rangwala 2010-07-02 16:25:58 +05:30
parent 0e61edf922
commit 83404a0425
3 changed files with 23 additions and 22 deletions

View File

@ -28,7 +28,7 @@ class res_company(osv.osv):
}
_defaults = {
'overdue_msg': lambda *a: 'Would your payment have been carried \
'overdue_msg': 'Would your payment have been carried \
out after this mail was sent, please consider the present one as \
void. Do not hesitate to contact our accounting department'
}

View File

@ -45,11 +45,11 @@ class account_invoice(osv.osv):
res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
return res
def _get_journal(self, cr, uid, context):
def _get_journal(self, cr, uid, context=None):
if context is None:
context = {}
type_inv = context.get('type', 'out_invoice')
user = self.pool.get('res.users').browse(cr, uid, uid)
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
company_id = context.get('company_id', user.company_id.id)
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'}
refund_journal = {'out_invoice': False, 'in_invoice': False, 'out_refund': True, 'in_refund': True}
@ -63,7 +63,7 @@ class account_invoice(osv.osv):
else:
return False
def _get_currency(self, cr, uid, context):
def _get_currency(self, cr, uid, context=None):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid])[0]
if user.company_id:
return user.company_id.currency_id.id
@ -81,10 +81,9 @@ class account_invoice(osv.osv):
def _get_type(self, cr, uid, context=None):
if context is None:
context = {}
type = context.get('type', 'out_invoice')
return type
return context.get('type', 'out_invoice')
def _reconciled(self, cr, uid, ids, name, args, context):
def _reconciled(self, cr, uid, ids, name, args, context=None):
res = {}
for id in ids:
res[id] = self.test_paid(cr, uid, [id])
@ -95,8 +94,11 @@ class account_invoice(osv.osv):
def _amount_residual(self, cr, uid, ids, name, args, context=None):
res = {}
data_inv = self.browse(cr, uid, ids)
cur_obj = self.pool.get('res.currency')
data_inv = self.browse(cr, uid, ids)
if context is None:
context = {}
for inv in data_inv:
debit = credit = 0.0
context.update({'date':inv.date_invoice})
@ -188,7 +190,7 @@ class account_invoice(osv.osv):
result[invoice.id] = lines
return result
def _get_invoice_from_line(self, cr, uid, ids, context={}):
def _get_invoice_from_line(self, cr, uid, ids, context=None):
move = {}
for line in self.pool.get('account.move.line').browse(cr, uid, ids):
if line.reconcile_partial_id:
@ -202,7 +204,7 @@ class account_invoice(osv.osv):
invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context)
return invoice_ids
def _get_invoice_from_reconcile(self, cr, uid, ids, context={}):
def _get_invoice_from_reconcile(self, cr, uid, ids, context=None):
move = {}
for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids):
for line in r.line_partial_ids:
@ -317,12 +319,12 @@ class account_invoice(osv.osv):
_defaults = {
'type': _get_type,
#'date_invoice': lambda *a: time.strftime('%Y-%m-%d'),
'state': lambda *a: 'draft',
'state': 'draft',
'journal_id': _get_journal,
'currency_id': _get_currency,
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'reference_type': lambda *a: 'none',
'check_total': lambda *a: 0.0,
'reference_type': 'none',
'check_total': 0.0,
'user_id': lambda s, cr, u, c: u,
}
@ -339,16 +341,15 @@ class account_invoice(osv.osv):
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0]
return super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
def create(self, cr, uid, vals, context={}):
def create(self, cr, uid, vals, context=None):
try:
res = super(account_invoice, self).create(cr, uid, vals, context)
return res
except Exception,e:
except Exception, e:
if '"journal_id" viol' in e.args[0]:
raise orm.except_orm(_('Configuration Error!'),
_('There is no Accounting Journal of type Sale/Purchase defined!'))
else:
raise
raise orm.except_orm(_('UnknownError'), str(e))
def confirm_paid(self, cr, uid, ids, context=None):
@ -1226,8 +1227,8 @@ class account_invoice_line(osv.osv):
'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True)
}
_defaults = {
'quantity': lambda *a: 1,
'discount': lambda *a: 0.0,
'quantity': 1,
'discount': 0.0,
'price_unit': _price_unit_default,
}
@ -1570,4 +1571,7 @@ class res_partner(osv.osv):
_columns = {
'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True),
}
res_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -191,7 +191,4 @@ class res_partner(osv.osv):
}
res_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: