-Modified data xml files:account_data1 and account_minimal for account.account.types and parent_id changed from one2many to manyone, -
bzr revid: jvo@tinyerp.com-20080723135627-bp678usxmm6jgpqo
This commit is contained in:
parent
1cc40127b0
commit
ac438d5a0b
|
@ -246,14 +246,32 @@ class account_account(osv.osv):
|
|||
result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code)
|
||||
return result
|
||||
|
||||
def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}):
|
||||
result={}
|
||||
for record in self.browse(cr, uid, ids, context):
|
||||
if record.child_parent_ids:
|
||||
result[record.id]=[x.id for x in record.child_parent_ids]
|
||||
else:
|
||||
result[record.id]=[]
|
||||
|
||||
if record.child_consol_ids:
|
||||
for acc in record.child_consol_ids:
|
||||
result[record.id].append(acc.id)
|
||||
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True, select=True),
|
||||
'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign', required=True, help='Allows to change the displayed amount of the balance to see positive results instead of negative ones in expenses accounts'),
|
||||
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."),
|
||||
'code': fields.char('Code', size=64),
|
||||
'type': fields.selection(_code_get, 'Account Type', required=True),
|
||||
'parent_id': fields.many2many('account.account', 'account_account_rel', 'child_id', 'parent_id', 'Parents'),
|
||||
'child_id': fields.many2many('account.account', 'account_account_rel', 'parent_id', 'child_id', 'Children'),
|
||||
# 'parent_id': fields.many2many('account.account', 'account_account_rel', 'child_id', 'parent_id', 'Parents'),
|
||||
'parent_id': fields.many2one('account.account','Parent'),
|
||||
'child_parent_ids':fields.one2many('account.account','parent_id','Children'),
|
||||
'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children',domain=[('type','=','root'), ('type', '=', 'consolidation')]),
|
||||
# 'child_id': fields.many2many('account.account', 'account_account_rel', 'parent_id', 'child_id', 'Children'),
|
||||
'child_id': filelds.function(_get_child_ids, method=True, type='many2many',relation="account.account",string="Children Accounts"),
|
||||
'balance': fields.function(_balance, digits=(16,2), method=True, string='Balance'),
|
||||
'credit': fields.function(_credit, digits=(16,2), method=True, string='Credit'),
|
||||
'debit': fields.function(_debit, digits=(16,2), method=True, string='Debit'),
|
||||
|
@ -283,14 +301,35 @@ class account_account(osv.osv):
|
|||
'active': lambda *a: True,
|
||||
}
|
||||
|
||||
# def _check_recursion(self, cr, uid, ids):
|
||||
# level = 100
|
||||
# while len(ids):
|
||||
# cr.execute('select distinct parent_id from account_account_rel where child_id in ('+','.join(map(str,ids))+')')
|
||||
# ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
# if not level:
|
||||
# return False
|
||||
# level -= 1
|
||||
# return True
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from account_account_rel where child_id in ('+','.join(map(str,ids))+')')
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
obj_self=self.browse(cr,uid,ids[0])
|
||||
p_id=obj_self.parent_id and obj_self.parent_id.id
|
||||
|
||||
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
||||
return False
|
||||
|
||||
while(ids):
|
||||
cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str,ids))+')')
|
||||
child_ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
c_ids=child_ids
|
||||
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
||||
return False
|
||||
level -= 1
|
||||
while len(c_ids):
|
||||
s_ids=self.search(cr,uid,[('parent_id','in',c_ids)])
|
||||
if p_id and (p_id in s_ids):
|
||||
return False
|
||||
c_ids=s_ids
|
||||
ids=child_ids
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
|
|
|
@ -126,7 +126,9 @@
|
|||
<field name="close_method"/>
|
||||
<field name="reconcile"/>
|
||||
<newline/>
|
||||
<field colspan="4" name="parent_id"/>
|
||||
<field name="parent_id"/>
|
||||
<newline/>
|
||||
<field name="child_consol_ids" colspan="4"/>
|
||||
<field colspan="4" name="tax_ids"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
|
|
|
@ -32,13 +32,7 @@
|
|||
<field name="code">consolidation</field>
|
||||
<field name="close_method">none</field>
|
||||
</record>
|
||||
|
||||
<record id="account_type_others" model="account.account.type">
|
||||
<field name="name">Others</field>
|
||||
<field name="code">others</field>
|
||||
<field name="close_method">none</field>
|
||||
</record>
|
||||
<!--<record id="account_type_income" model="account.account.type">
|
||||
<record id="account_type_income" model="account.account.type">
|
||||
<field name="name">Income</field>
|
||||
<field name="code">income</field>
|
||||
<field name="close_method">unreconciled</field>
|
||||
|
@ -73,6 +67,6 @@
|
|||
<field name="name">Closed</field>
|
||||
<field name="code">closed</field>
|
||||
<field name="close_method">none</field>
|
||||
</record>-->
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -10,7 +10,7 @@
|
|||
<field name="code">0</field>
|
||||
<field name="name">Minimal account chart</field>
|
||||
<field name="close_method">none</field>
|
||||
<!--<field eval="[]" name="parent_id"/>-->
|
||||
<field eval="0" name="parent_id"/>
|
||||
<field name="type">view</field>
|
||||
</record>
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
<record id="cash" model="account.account">
|
||||
<field name="name">Petty Cash</field>
|
||||
<field name="code">57</field>
|
||||
<field name="type">others</field>
|
||||
<field name="type">cash</field>
|
||||
<field eval="ref('minimal_0')" name="parent_id"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
|
@ -42,14 +42,14 @@
|
|||
<record id="a_expense" model="account.account">
|
||||
<field name="name">Products Purchase</field>
|
||||
<field name="code">600</field>
|
||||
<field name="type">others</field>
|
||||
<field name="type">expense</field>
|
||||
<field eval="ref('minimal_0')" name="parent_id"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
<record id="a_sale" model="account.account">
|
||||
<field name="name">Products Sales</field>
|
||||
<field name="code">701</field>
|
||||
<field name="type">others</field>
|
||||
<field name="type">income</field>
|
||||
<field eval="ref('minimal_0')" name="parent_id"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue