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
| # if the journal view has a state field, color lines depending on
# its value
state = ''
for field in journal.view_id.columns_id:
if field.field=='state':
state = ' colors="red:state==\'draft\'"'
#xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5"%s>\n\t''' % (title, state)
xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="_on_create_write"%s>\n\t''' % (title, state)
fields = []
widths = {
'ref': 50,
'statement_id': 50,
'state': 60,
'tax_code_id': 50,
'move_id': 40,
}
for field in journal.view_id.columns_id:
fields.append(field.field)
attrs = []
if field.field=='debit':
attrs.append('sum="Total debit"')
elif field.field=='credit':
attrs.append('sum="Total credit"')
elif field.field=='account_id' and journal.id:
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]"')
if field.readonly:
attrs.append('readonly="1"')
if field.required:
attrs.append('required="1"')
else:
attrs.append('required="0"')
if field.field == 'partner_id':
attrs.append('on_change="onchange_partner_id(move_id,partner_id,account_id,debit,credit,((\'journal_id\' in context) and context[\'journal_id\']) or {})"')
if field.field in widths:
attrs.append('width="'+str(widths[field.field])+'"')
xml += '''<field name="%s" %s/>\n''' % (field.field,' '.join(attrs)) |
Partager