[IMP]Journals views in one, comment of fields_view_get of account.move.line

bzr revid: dle@openerp.com-20121121142643-g29shtxwf9slvvhi
This commit is contained in:
Denis Ledoux dle@openerp.com 2012-11-21 15:26:43 +01:00
parent fb471068f2
commit 20c09c3393
2 changed files with 190 additions and 110 deletions

View File

@ -970,126 +970,126 @@ class account_move_line(osv.osv):
'context':context,
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
journal_pool = self.pool.get('account.journal')
if context is None:
context = {}
result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
if (view_type != 'tree') or view_id:
#Remove the toolbar from the form view
if view_type == 'form':
if result.get('toolbar', False):
result['toolbar']['action'] = []
#Restrict the list of journal view in search view
if view_type == 'search' and result['fields'].get('journal_id', False):
result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
ctx = context.copy()
#we add the refunds journal in the selection field of journal
if context.get('journal_type', False) == 'sale':
ctx.update({'journal_type': 'sale_refund'})
result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
elif context.get('journal_type', False) == 'purchase':
ctx.update({'journal_type': 'purchase_refund'})
result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
return result
if context.get('view_mode', False):
return result
fld = []
flds = []
title = _("Accounting Entries") # self.view_header_get(cr, uid, view_id, view_type, context)
# def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
# journal_pool = self.pool.get('account.journal')
# if context is None:
# context = {}
# result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
# if (view_type != 'tree') or view_id:
# #Remove the toolbar from the form view
# if view_type == 'form':
# if result.get('toolbar', False):
# result['toolbar']['action'] = []
# #Restrict the list of journal view in search view
# if view_type == 'search' and result['fields'].get('journal_id', False):
# result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
# ctx = context.copy()
# #we add the refunds journal in the selection field of journal
# if context.get('journal_type', False) == 'sale':
# ctx.update({'journal_type': 'sale_refund'})
# result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
# elif context.get('journal_type', False) == 'purchase':
# ctx.update({'journal_type': 'purchase_refund'})
# result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
# return result
# if context.get('view_mode', False):
# return result
# fld = []
# flds = []
# title = _("Accounting Entries") # self.view_header_get(cr, uid, view_id, view_type, context)
ids = journal_pool.search(cr, uid, [], context=context)
journals = journal_pool.browse(cr, uid, ids, context=context)
for journal in journals:
for field in journal.view_id.columns_id:
# sometimes, it's possible that a defined column is not loaded (the module containing
# this field is not loaded) when we make an update.
if field.field not in self._columns:
continue
# ids = journal_pool.search(cr, uid, [], context=context)
# journals = journal_pool.browse(cr, uid, ids, context=context)
# for journal in journals:
# for field in journal.view_id.columns_id:
# # sometimes, it's possible that a defined column is not loaded (the module containing
# # this field is not loaded) when we make an update.
# if field.field not in self._columns:
# continue
if not field.field in flds:
fld.append((field.field, field.sequence))
flds.append(field.field)
# if not field.field in flds:
# fld.append((field.field, field.sequence))
# flds.append(field.field)
default_columns = {
'period_id': 3,
'journal_id': 10,
'state': sys.maxint,
}
for d in default_columns:
if d not in flds:
fld.append((d, default_columns[d]))
flds.append(d)
# default_columns = {
# 'period_id': 3,
# 'journal_id': 10,
# 'state': sys.maxint,
# }
# for d in default_columns:
# if d not in flds:
# fld.append((d, default_columns[d]))
# flds.append(d)
fld = sorted(fld, key=itemgetter(1))
widths = {
'statement_id': 50,
'state': 60,
'tax_code_id': 50,
'move_id': 40,
}
# fld = sorted(fld, key=itemgetter(1))
# widths = {
# 'statement_id': 50,
# 'state': 60,
# 'tax_code_id': 50,
# 'move_id': 40,
# }
document = etree.Element('tree', string=title, editable="top",
on_write="on_create_write",
colors="red:state=='draft';black:state=='valid'")
fields_get = self.fields_get(cr, uid, flds, context)
for field, _seq in fld:
# TODO add string to element
f = etree.SubElement(document, 'field', name=field)
# document = etree.Element('tree', string=title, editable="top",
# on_write="on_create_write",
# colors="red:state=='draft';black:state=='valid'")
# fields_get = self.fields_get(cr, uid, flds, context)
# for field, _seq in fld:
# # TODO add string to element
# f = etree.SubElement(document, 'field', name=field)
if field == 'debit':
f.set('sum', _("Total debit"))
# if field == 'debit':
# f.set('sum', _("Total debit"))
elif field == 'credit':
f.set('sum', _("Total credit"))
# elif field == 'credit':
# f.set('sum', _("Total credit"))
elif field == 'move_id':
f.set('required', 'False')
# elif field == 'move_id':
# f.set('required', 'False')
elif field == 'account_tax_id':
f.set('domain', "[('parent_id', '=' ,False)]")
f.set('context', "{'journal_id': journal_id}")
# elif field == 'account_tax_id':
# f.set('domain', "[('parent_id', '=' ,False)]")
# f.set('context', "{'journal_id': journal_id}")
elif field == 'account_id' and journal.id:
f.set('domain', "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
f.set('on_change', 'onchange_account_id(account_id, partner_id)')
# elif field == 'account_id' and journal.id:
# f.set('domain', "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
# f.set('on_change', 'onchange_account_id(account_id, partner_id)')
elif field == 'partner_id':
f.set('on_change', 'onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)')
# elif field == 'partner_id':
# f.set('on_change', 'onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)')
elif field == 'journal_id':
f.set('context', "{'journal_id': journal_id}")
# elif field == 'journal_id':
# f.set('context', "{'journal_id': journal_id}")
elif field == 'statement_id':
f.set('domain', "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
f.set('invisible', 'True')
# elif field == 'statement_id':
# f.set('domain', "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
# f.set('invisible', 'True')
elif field == 'date':
f.set('on_change', 'onchange_date(date)')
# elif field == 'date':
# f.set('on_change', 'onchange_date(date)')
elif field == 'analytic_account_id':
# Currently it is not working due to being executed by superclass's fields_view_get
# f.set('groups', 'analytic.group_analytic_accounting')
pass
# elif field == 'analytic_account_id':
# # Currently it is not working due to being executed by superclass's fields_view_get
# # f.set('groups', 'analytic.group_analytic_accounting')
# pass
if field in ('amount_currency', 'currency_id'):
f.set('on_change', 'onchange_currency(account_id, amount_currency, currency_id, date, journal_id)')
f.set('attrs', "{'readonly': [('state', '=', 'valid')]}")
# if field in ('amount_currency', 'currency_id'):
# f.set('on_change', 'onchange_currency(account_id, amount_currency, currency_id, date, journal_id)')
# f.set('attrs', "{'readonly': [('state', '=', 'valid')]}")
if field in widths:
f.set('width', str(widths[field]))
# if field in widths:
# f.set('width', str(widths[field]))
if field in ('journal_id',):
f.set("invisible", "context.get('journal_id', False)")
elif field in ('period_id',):
f.set("invisible", "context.get('period_id', False)")
# if field in ('journal_id',):
# f.set("invisible", "context.get('journal_id', False)")
# elif field in ('period_id',):
# f.set("invisible", "context.get('period_id', False)")
orm.setup_modifiers(f, fields_get[field], context=context,
in_tree_view=True)
# orm.setup_modifiers(f, fields_get[field], context=context,
# in_tree_view=True)
result['arch'] = etree.tostring(document, pretty_print=True)
result['fields'] = fields_get
return result
# result['arch'] = etree.tostring(document, pretty_print=True)
# result['fields'] = fields_get
# return result
def _check_moves(self, cr, uid, context=None):
# use the first move ever created for this journal and period

View File

@ -1063,31 +1063,78 @@
</tree_account_reconciliation>
</field>
</record>
<!--
Sale :
1 Journal Entry
2 Ref
3 Date
5 Partner
6 Account
7 Name
8 Due Date
11 Debit
12 Credit
13 Tax
14 Analytic Account
19 Status
20 Reconcile
Bank :
1 Journal Entry
2 Ref
3 Date
4 Statement
5 Partner
6 Account
7 Name
11 Debit
12 Credit
19 Status
20 Reconcile
Sale Refund :
1 Journal Entry
2 Ref
3 Date
5 Partner
6 Account
7 Name
8 Due Date
11 Debit
12 Credit
13 Tax
14 Analytic Account
19 Status
20 Reconcile
-->
<record id="view_move_line_tree" model="ir.ui.view">
<field name="name">account.move.line.tree</field>
<field name="model">account.move.line</field>
<field eval="4" name="priority"/>
<field name="arch" type="xml">
<tree colors="red:state == 'draft';black:state == 'valid'" string="Journal Items" editable="top" on_write="on_create_write">
<field name="date"/>
<field name="period_id"/>
<field name="move_id"/>
<field name="ref"/>
<field name="invoice"/>
<field name="name"/>
<field name="date"/>
<field name="statement_id" invisible="context.get('journal_type', False) in ['sale','purchase']"/>
<field name="partner_id" on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"/>
<field name="account_id" domain="[('journal_id','=',journal_id), ('company_id', '=', company_id)]"/>
<field name="journal_id"/>
<field name="name"/>
<field name="date_maturity" invisible="context.get('journal_type', False) in ['bank']"/>
<field name="debit" sum="Total debit"/>
<field name="credit" sum="Total credit"/>
<field name="account_tax_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
<field name="amount_currency" attrs="{'readonly':[('state','=','valid')]}"/>
<field name="currency_id" attrs="{'readonly':[('state','=','valid')]}" groups="base.group_multi_currency"/>
<field name="account_tax_id" invisible="context.get('journal_type', False) in ['bank']"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('parent_id','!=',False)]" invisible="context.get('journal_type', False) in ['sale','purchase']"/>
<field name="state" />
<field name="reconcile_partial_id"/>
<field name="reconcile_id"/>
<field name="state" invisible="1"/>
<field name="invoice" invisible="context.get('journal_type', False) in ['sale','purchase','bank']"/>
<field name="amount_currency" attrs="{'readonly':[('state','=','valid')]}" groups="base.group_multi_currency" />
<field name="currency_id" attrs="{'readonly':[('state','=','valid')]}" groups="base.group_multi_currency" />
<field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1"/>
</tree>
</field>
</record>
@ -1280,6 +1327,39 @@
groups="group_account_user"
/>
<record id="action_account_moves_sale" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="res_model">account.move.journal</field>
<field name="view_type">form</field>
<field name="context">{'journal_type':'sale'}</field>
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. If you want to record a customer invoice, select the journal and the period in the search toolbar. Then, start by recording the entry line of the income account. OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account receivable".</field>
</record>
<menuitem action="action_account_moves_sale" sequence="16" id="menu_eaction_account_moves_sale"
parent="menu_finance_receivables" icon="STOCK_JUSTIFY_FILL" groups="group_account_user,group_account_manager"/>
<record id="action_account_moves_purchase" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="res_model">account.move.journal</field>
<field name="view_type">form</field>
<field name="context">{'journal_type':'purchase'}</field>
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. If you want to record a supplier invoice, start by recording the line of the expense account, OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account Payable".</field>
</record>
<menuitem action="action_account_moves_purchase"
id="menu_eaction_account_moves_purchase"
parent="menu_finance_payables"
icon="STOCK_JUSTIFY_FILL"
sequence="16"
groups="group_account_user,group_account_manager"/>
<record id="action_account_moves_bank" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="res_model">account.move.journal</field>
<field name="view_type">form</field>
<field name="context">{'journal_type':'bank'}</field>
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. Journal items are created by OpenERP if you use Bank Statements, Cash Registers, or Customer/Supplier payments.</field>
</record>
<record id="action_view_move_line" model="ir.actions.act_window">
<field name="name">Lines to reconcile</field>
<field name="res_model">account.move.line</field>