1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# -*- encoding: utf-8 -*-
# __author__ = jeff@openerp.cn
from osv import osv, fields
from tools.translate import _
class account_move(osv.osv):
_inherit = 'account.move'
"""
添加制单、审核、附件数三个字段
"""
_columns = {
'write_uid':fields.many2one('res.users', '审核', readonly=True),
'create_uid':fields.many2one('res.users', '制单', readonly=True, select=True),
'proof':fields.integer('附件数', required=True, help='该记账凭证对应的原始凭证数量'),
}
"""
附件数默认为1张
凭证业务类型默认为总帐
"""
_defaults = {
'proof': lambda *args: 1,
'journal_id': lambda self, cr, uid, context:self.pool.get('account.journal').search(cr, uid, [('type', '=', 'general')], limit=1)[0]
}
account_move()
class account_account(osv.osv):
_inherit = 'account.account'
"""
Replace metheod accoun.account.name_get(), show full name of account on many2one field
Sample “100902 其他货币资金/银行本票”
"""
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
reads = self.read(cr, uid, ids, ['name', 'code','parent_id'], context)
res = []
for record in reads:
name = record['name']
if record['code']:
if record['parent_id']:
account_parent_id = record['parent_id'][0]
while account_parent_id:
parent_obj = self.read(cr, uid, account_parent_id, ['name', 'parent_id'], context)
name = parent_obj['name'] + '/'+name
if parent_obj['parent_id']:
account_parent_id = parent_obj['parent_id'][0]
else:
account_parent_id = False
name = record['code'] + ' '+name
res.append((record['id'], name))
return res
account_account()
|