[FIX] account: Fixed with some coding standards.
bzr revid: uco@tinyerp.com-20110615085138-51stynbvm10e6r6a
This commit is contained in:
@@ -41,10 +41,16 @@ class account_invoice_refund(osv.osv_memory):
|
||||
|
||||
def _get_journal(self, cr, uid, context=None):
|
||||
obj_journal = self.pool.get('account.journal')
|
||||
user_obj = self.pool.get('res.users')
|
||||
if context is None:
|
||||
context = {}
|
||||
journal_type = context.get('journal_type', False)
|
||||
journal = obj_journal.search(cr, uid, [('type', '=', journal_type)])
|
||||
inv_type = context.get('type', 'out_invoice')
|
||||
company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
|
||||
type = (inv_type == 'out_invoice') and 'sale_refund' or \
|
||||
(inv_type == 'out_refund') and 'sale' or \
|
||||
(inv_type == 'in_invoice') and 'purchase_refund' or \
|
||||
(inv_type == 'in_refund') and 'purchase'
|
||||
journal = obj_journal.search(cr, uid, [('type', '=', type), ('company_id','child_of',[company_id])], limit=1, context=context)
|
||||
return journal and journal[0] or False
|
||||
|
||||
_defaults = {
|
||||
@@ -55,15 +61,17 @@ class account_invoice_refund(osv.osv_memory):
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
user_obj = self.pool.get('res.users')
|
||||
res = super(account_invoice_refund,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
|
||||
type = context.get('type', 'out_invoice')
|
||||
company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
|
||||
journal_type = (type == 'out_invoice') and 'sale_refund' or \
|
||||
(type == 'out_refund') and 'sale' or \
|
||||
(type == 'in_invoice') and 'purchase_refund' or \
|
||||
(type == 'in_refund') and 'purchase'
|
||||
for field in res['fields']:
|
||||
if field == 'journal_id':
|
||||
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', journal_type)], context=context, limit=None, name_get_uid=1)
|
||||
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', journal_type), ('company_id','child_of',[company_id])], context=context, limit=None, name_get_uid=1)
|
||||
res['fields'][field]['selection'] = journal_select
|
||||
return res
|
||||
|
||||
@@ -196,9 +204,9 @@ class account_invoice_refund(osv.osv_memory):
|
||||
if 'value' in data and data['value']:
|
||||
inv_obj.write(cr, uid, [inv_id], data['value'])
|
||||
created_inv.append(inv_id)
|
||||
xml_id = (inv.type == 'out_invoice') and 'action_invoice_tree3' or \
|
||||
(inv.type == 'out_refund') and 'action_invoice_tree1' or \
|
||||
xml_id = (inv.type == 'out_refund') and 'action_invoice_tree1' or \
|
||||
(inv.type == 'in_invoice') and 'action_invoice_tree2' or \
|
||||
(inv.type == 'out_invoice') and 'action_invoice_tree3' or \
|
||||
(inv.type == 'in_refund') and 'action_invoice_tree4'
|
||||
result = mod_obj.get_object_reference(cr, uid, 'account', xml_id)
|
||||
id = result and result[1] or False
|
||||
|
||||
Reference in New Issue
Block a user