diff --git a/addons/account/account.py b/addons/account/account.py index 06060f59e28..937f50249e5 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -584,6 +584,9 @@ class account_journal_column(osv.osv): result = [] cols = self.pool.get('account.move.line')._columns for col in cols: + if col in ('period_id', 'journal_id'): + continue + result.append( (col, cols[col].string) ) result.sort() return result @@ -657,11 +660,9 @@ class account_journal(osv.osv): # }) return journal_id - def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): + def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100): if not args: args = [] - if context is None: - context = {} ids = [] if name: ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit, context=context) @@ -832,7 +833,7 @@ class account_period(osv.osv): cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True - def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): + def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=80): if args is None: args = [] if context is None: @@ -844,7 +845,7 @@ class account_period(osv.osv): ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) return self.name_get(cr, user, ids, context=context) - def write(self, cr, uid, ids, vals, context=None): + def write(self, cr, uid, ids, vals, context={}): obj=[] if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)]) diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index dd577f98458..48e0e27e59a 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -3,9 +3,9 @@ - - - + + + @@ -13,7 +13,7 @@ - + @@ -36,7 +36,7 @@ - diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index b8719f26242..cf8318f1ef2 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -529,6 +529,7 @@ class account_move_line(osv.osv): return result def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): + print 'XXXXXXXXXXXXXXXXXXXXXXXXXXX : ', move_id, partner_id, account_id, debit, credit, date, journal val = {} val['date_maturity'] = False @@ -788,57 +789,81 @@ class account_move_line(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) - if view_type=='tree' and 'journal_id' in context: - title = self.view_header_get(cr, uid, view_id, view_type, context) - journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id']) - - # if the journal view has a state field, color lines depending on - # its value - state = '' + if view_type != 'tree': + return result + + fld = [] + fields = {} + flds = [] + title = self.view_header_get(cr, uid, view_id, view_type, context) + xml = '''\n\n\t''' % (title) + journal_pool = self.pool.get('account.journal') + + ids = journal_pool.search(cr, uid, []) + journals = journal_pool.browse(cr, uid, ids) + all_journal = [] + for journal in journals: + all_journal.append(journal.id) for field in journal.view_id.columns_id: - if field.field=='state': - state = ' colors="red:state==\'draft\'"' - - #xml = '''\n\n\t''' % (title, state) - xml = '''\n\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_tax_id': - attrs.append('domain="[(\'parent_id\',\'=\',False)]"') - elif field.field=='account_id' and journal.id: - attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"') - elif field.field == 'partner_id': - attrs.append('on_change="onchange_partner_id(move_id,partner_id,account_id,debit,credit,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"') - if field.readonly: - attrs.append('readonly="1"') - if field.required: - attrs.append('required="1"') + if not field.field in fields: + fields[field.field] = [journal.id] + fld.append((field.field, field.sequence)) + flds.append(field.field) else: - attrs.append('required="0"') - if field.field in ('amount_currency','currency_id'): - attrs.append('on_change="onchange_currency(account_id,amount_currency,currency_id,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"') + fields.get(field.field).append(journal.id) + + fld.append(('period_id', 3)) + fld.append(('journal_id', 10)) + flds.append('period_id') + flds.append('journal_id') + fields['period_id'] = all_journal + fields['journal_id'] = all_journal + + from operator import itemgetter + fld = sorted(fld, key=itemgetter(1)) - if field.field in widths: - attrs.append('width="'+str(widths[field.field])+'"') - xml += '''\n''' % (field.field,' '.join(attrs)) + widths = { + 'ref': 50, + 'statement_id': 50, + 'state': 60, + 'tax_code_id': 50, + 'move_id': 40, + } - xml += '''''' - result['arch'] = xml - result['fields'] = self.fields_get(cr, uid, fields, context) + for field_it in fld: + field = field_it[0] + if field=='state': + state = 'colors="red:state==\'draft\'"' + + attrs = [] + if field == 'debit': + attrs.append('sum="Total debit"') + elif field == 'credit': + attrs.append('sum="Total credit"') + elif field == 'account_tax_id': + attrs.append('domain="[(\'parent_id\',\'=\',False)]"') + elif field == 'account_id' and journal.id: + attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"') + elif field == 'partner_id': + attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"') +# if field.readonly: +# attrs.append('readonly="1"') +# if field.required: +# attrs.append('required="1"') +# else: +# attrs.append('required="0"') + if field in ('amount_currency','currency_id'): + attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"') + + if field in widths: + attrs.append('width="'+str(widths[field])+'"') + + attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field))) + xml += '''\n''' % (field,' '.join(attrs)) + + xml += '''''' + result['arch'] = xml + result['fields'] = self.fields_get(cr, uid, flds, context) return result def _check_moves(self, cr, uid, context): diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index a93179e3f98..6526befb3d5 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -693,9 +693,23 @@ - + + + + Journal Entries + account.move + form + tree,form + + + + + @@ -713,7 +727,7 @@ - + @@ -843,10 +857,15 @@ - + + + + + + @@ -1033,27 +1052,27 @@ - + - Receivable Entries - account.move + Journal Items + account.move.line form tree,form - - - [('journal_id.type', '=', 'sale')] + + + [('journal_id.type', 'in', ['sale', 'sale_refund'])] - Payable Entries - account.move + Transaction Journal + account.move.line form tree,form - - - [('journal_id.type', '=', 'purchase')] + + + [('journal_id.type', 'in', ['purchase', 'purchase_refund'])] diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index aed57a283aa..71d0ca27979 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -118,7 +118,7 @@ [('journal_id.type','=','sale')] + action="action_receipt_vou_voucher_list" parent="account.menu_finance_receivables" sequence="12"/> @@ -130,7 +130,7 @@ [('journal_id.type','=','purchase')] + action="action_pay_vou_voucher_list" parent="account.menu_finance_payables" sequence="12"/>