[FIX/IMP]: fix a problem of journal entries (remove selection widget on period_id)
[IMP]: implement name_search for account move [IMP]: implement on_change_date for account move line, it will change the period [FIX]: now it is possible to link existing lines with existing move -> remove readonly attribute on move_id under object account.move.line bzr revid: mga@tinyerp.com-20100812201733-s0os5160atacra6e
This commit is contained in:
parent
ed29832f40
commit
aef424a9f2
|
@ -1027,6 +1027,33 @@ class account_move(osv.osv):
|
||||||
_description = "Account Entry"
|
_description = "Account Entry"
|
||||||
_order = 'id desc'
|
_order = 'id desc'
|
||||||
|
|
||||||
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
|
"""
|
||||||
|
Returns a list of tupples containing id, name, as internally it is called {def name_get}
|
||||||
|
result format : {[(id, name), (id, name), ...]}
|
||||||
|
|
||||||
|
@param cr: A database cursor
|
||||||
|
@param user: ID of the user currently logged in
|
||||||
|
@param name: name to search
|
||||||
|
@param args: other arguments
|
||||||
|
@param operator: default operator is 'ilike', it can be changed
|
||||||
|
@param context: context arguments, like lang, time zone
|
||||||
|
@param limit: Returns first 'n' ids of complete result, default is 80.
|
||||||
|
|
||||||
|
@return: Returns a list of tupples containing id and name
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not args:
|
||||||
|
args=[]
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
|
ids = []
|
||||||
|
|
||||||
|
if name:
|
||||||
|
ids += self.search(cr, user, [('state','=','draft'), ('id','=',name)], limit=limit)
|
||||||
|
|
||||||
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
def name_get(self, cursor, user, ids, context=None):
|
def name_get(self, cursor, user, ids, context=None):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return []
|
return []
|
||||||
|
@ -2205,7 +2232,6 @@ class account_add_tmpl_wizard(osv.osv_memory):
|
||||||
def _get_def_cparent(self, cr, uid, context):
|
def _get_def_cparent(self, cr, uid, context):
|
||||||
acc_obj=self.pool.get('account.account')
|
acc_obj=self.pool.get('account.account')
|
||||||
tmpl_obj=self.pool.get('account.account.template')
|
tmpl_obj=self.pool.get('account.account.template')
|
||||||
#print "Searching for ",context
|
|
||||||
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id'])
|
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id'])
|
||||||
if not tids or not tids[0]['parent_id']:
|
if not tids or not tids[0]['parent_id']:
|
||||||
return False
|
return False
|
||||||
|
@ -2247,7 +2273,6 @@ class account_add_tmpl_wizard(osv.osv_memory):
|
||||||
# 'tax_ids': [(6,0,tax_ids)], todo!!
|
# 'tax_ids': [(6,0,tax_ids)], todo!!
|
||||||
'company_id': company_id,
|
'company_id': company_id,
|
||||||
}
|
}
|
||||||
# print "Creating:", vals
|
|
||||||
new_account = acc_obj.create(cr, uid, vals)
|
new_account = acc_obj.create(cr, uid, vals)
|
||||||
return {'type':'state', 'state': 'end' }
|
return {'type':'state', 'state': 'end' }
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ class account_move_line(osv.osv):
|
||||||
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
||||||
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
||||||
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
|
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
|
||||||
'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2),
|
'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", help="The move of this entry line.", select=2),
|
||||||
'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Narration'),
|
'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Narration'),
|
||||||
'ref': fields.char('Ref.', size=64),
|
'ref': fields.char('Ref.', size=64),
|
||||||
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
|
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
|
||||||
|
@ -560,7 +560,7 @@ class account_move_line(osv.osv):
|
||||||
#if jt in ('sale', 'purchase_refund', 'bank', 'cash'):
|
#if jt in ('sale', 'purchase_refund', 'bank', 'cash'):
|
||||||
if jt in ('sale', 'purchase_refund'):
|
if jt in ('sale', 'purchase_refund'):
|
||||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
|
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
|
||||||
elif jt in ('purchase', 'sale_refund', 'expense'):
|
elif jt in ('purchase', 'sale_refund', 'expense', 'bank', 'cash'):
|
||||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
|
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
|
||||||
|
|
||||||
if val.get('account_id', False):
|
if val.get('account_id', False):
|
||||||
|
@ -798,30 +798,30 @@ class account_move_line(osv.osv):
|
||||||
return j+(p and (':'+p) or '')
|
return j+(p and (':'+p) or '')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# def onchange_date(self, cr, user, ids, date, context={}):
|
def onchange_date(self, cr, user, ids, date, context={}):
|
||||||
# """
|
"""
|
||||||
# Returns a dict that contains new values and context
|
Returns a dict that contains new values and context
|
||||||
# @param cr: A database cursor
|
@param cr: A database cursor
|
||||||
# @param user: ID of the user currently logged in
|
@param user: ID of the user currently logged in
|
||||||
# @param date: latest value from user input for field date
|
@param date: latest value from user input for field date
|
||||||
# @param args: other arguments
|
@param args: other arguments
|
||||||
# @param context: context arguments, like lang, time zone
|
@param context: context arguments, like lang, time zone
|
||||||
# @return: Returns a dict which contains new values, and context
|
@return: Returns a dict which contains new values, and context
|
||||||
# """
|
"""
|
||||||
# res = {}
|
res = {}
|
||||||
# period_pool = self.pool.get('account.period')
|
period_pool = self.pool.get('account.period')
|
||||||
# pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
|
pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
|
||||||
# if pids:
|
if pids:
|
||||||
# res.update({
|
res.update({
|
||||||
# 'period_id':pids[0]
|
'period_id':pids[0]
|
||||||
# })
|
})
|
||||||
# context.update({
|
context.update({
|
||||||
# 'period_id':pids[0]
|
'period_id':pids[0]
|
||||||
# })
|
})
|
||||||
# return {
|
return {
|
||||||
# 'value':res,
|
'value':res,
|
||||||
# 'context':context,
|
'context':context,
|
||||||
# }
|
}
|
||||||
|
|
||||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
|
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)
|
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||||
|
@ -882,20 +882,29 @@ class account_move_line(osv.osv):
|
||||||
attrs = []
|
attrs = []
|
||||||
if field == 'debit':
|
if field == 'debit':
|
||||||
attrs.append('sum="Total debit"')
|
attrs.append('sum="Total debit"')
|
||||||
|
|
||||||
elif field == 'credit':
|
elif field == 'credit':
|
||||||
attrs.append('sum="Total credit"')
|
attrs.append('sum="Total credit"')
|
||||||
|
|
||||||
elif field == 'account_tax_id':
|
elif field == 'account_tax_id':
|
||||||
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
|
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
|
||||||
attrs.append("context=\"{'journal_id':journal_id}\"")
|
attrs.append("context=\"{'journal_id':journal_id}\"")
|
||||||
|
|
||||||
elif field == 'account_id' and journal.id:
|
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)"')
|
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':
|
elif field == 'partner_id':
|
||||||
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
|
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
|
||||||
|
|
||||||
elif field == 'journal_id':
|
elif field == 'journal_id':
|
||||||
attrs.append("context=\"{'journal_id':journal_id}\"")
|
attrs.append("context=\"{'journal_id':journal_id}\"")
|
||||||
|
|
||||||
elif field == 'statement_id':
|
elif field == 'statement_id':
|
||||||
attrs.append("domain=\"[('state','!=','confirm'),('journal_id.type','=','bank')]\"")
|
attrs.append("domain=\"[('state','!=','confirm'),('journal_id.type','=','bank')]\"")
|
||||||
|
|
||||||
|
elif field == 'date':
|
||||||
|
attrs.append('on_change="onchange_date(date)"')
|
||||||
|
|
||||||
if field in ('amount_currency', 'currency_id'):
|
if field in ('amount_currency', 'currency_id'):
|
||||||
attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
|
attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
|
||||||
|
|
||||||
|
|
|
@ -1048,7 +1048,7 @@
|
||||||
<field name="credit" operator="+"/>
|
<field name="credit" operator="+"/>
|
||||||
</graph>
|
</graph>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_account_move_line_filter" model="ir.ui.view">
|
<record id="view_account_move_line_filter" model="ir.ui.view">
|
||||||
<field name="name">Entry Lines</field>
|
<field name="name">Entry Lines</field>
|
||||||
|
@ -1058,9 +1058,10 @@
|
||||||
<search string="Search Entry Lines">
|
<search string="Search Entry Lines">
|
||||||
<group col='10' colspan='4'>
|
<group col='10' colspan='4'>
|
||||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Entry Lines"/>
|
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Entry Lines"/>
|
||||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','valid')]" help="Posted Entry Lines"/>
|
|
||||||
<separator orientation="vertical"/>
|
<separator orientation="vertical"/>
|
||||||
|
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','valid')]" help="Posted Entry Lines"/>
|
||||||
<filter icon="terp-stock_symbol-selection" string="Unposted" domain="[('move_id.state','=','draft')]" help="Unposted Entry Lines"/>
|
<filter icon="terp-stock_symbol-selection" string="Unposted" domain="[('move_id.state','=','draft')]" help="Unposted Entry Lines"/>
|
||||||
|
<separator orientation="vertical"/>
|
||||||
<filter icon="terp-stock_symbol-selection" string="Unreconciled" domain="[('reconcile_id','=',False), ('account_id.type','in',['receivable', 'payable'])]" help="Unreconciled Entry Lines"/>
|
<filter icon="terp-stock_symbol-selection" string="Unreconciled" domain="[('reconcile_id','=',False), ('account_id.type','in',['receivable', 'payable'])]" help="Unreconciled Entry Lines"/>
|
||||||
<separator orientation="vertical"/>
|
<separator orientation="vertical"/>
|
||||||
<field name="ref" select="1" string="Reference"/>
|
<field name="ref" select="1" string="Reference"/>
|
||||||
|
@ -1073,8 +1074,8 @@
|
||||||
</group>
|
</group>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group col="10" colspan="4">
|
<group col="10" colspan="4">
|
||||||
<field name="journal_id" required="1" widget="selection" context="{'journal_id':self, 'visible_id':self or 0, 'normal_view':False}"/>
|
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self or 0, 'normal_view':False}"/>
|
||||||
<field name="period_id" required="1" widget="selection" context="{'period_id':self}"/>
|
<field name="period_id" context="{'period_id':self, 'search_default_period_id':self}"/>
|
||||||
<separator orientation="vertical"/>
|
<separator orientation="vertical"/>
|
||||||
<field name="narration" select="1"/>
|
<field name="narration" select="1"/>
|
||||||
<field name="date" select='1'/>
|
<field name="date" select='1'/>
|
||||||
|
@ -1377,29 +1378,29 @@
|
||||||
|
|
||||||
<menuitem action="action_move_line_form_encode_by_move" id="menu_encode_entries_by_move" parent="menu_finance_entries"/>-->
|
<menuitem action="action_move_line_form_encode_by_move" id="menu_encode_entries_by_move" parent="menu_finance_entries"/>-->
|
||||||
|
|
||||||
<record id="action_account_moves_sale" model="ir.actions.act_window">
|
<!-- <record id="action_account_moves_sale" model="ir.actions.act_window">-->
|
||||||
<field name="name">Journal Items</field>
|
<!-- <field name="name">Journal Items</field>-->
|
||||||
<field name="res_model">account.move.line</field>
|
<!-- <field name="res_model">account.move.line</field>-->
|
||||||
<field name="view_type">form</field>
|
<!-- <field name="view_type">form</field>-->
|
||||||
<field name="view_mode">tree,form,graph</field>
|
<!-- <field name="view_mode">tree,form,graph</field>-->
|
||||||
<field name="view_id" ref="view_move_line_tree"/>
|
<!-- <field name="view_id" ref="view_move_line_tree"/>-->
|
||||||
<field name="search_view_id" ref="view_account_move_line_filter"/>
|
<!-- <field name="search_view_id" ref="view_account_move_line_filter"/>-->
|
||||||
<field name="domain">[('journal_id.type', 'in', ['sale', 'purchase_refund'])]</field>
|
<!-- <field name="domain">[('journal_id.type', 'in', ['sale', 'purchase_refund'])]</field>-->
|
||||||
</record>
|
<!-- </record>-->
|
||||||
|
|
||||||
<menuitem action="action_account_moves_sale" id="menu_eaction_account_moves_sale" parent="menu_finance_receivables"/>
|
<!-- <menuitem action="action_account_moves_sale" id="menu_eaction_account_moves_sale" parent="menu_finance_receivables"/>-->
|
||||||
|
|
||||||
<record id="action_account_moves_purchase" model="ir.actions.act_window">
|
<!-- <record id="action_account_moves_purchase" model="ir.actions.act_window">-->
|
||||||
<field name="name">Journal Items</field>
|
<!-- <field name="name">Journal Items</field>-->
|
||||||
<field name="res_model">account.move.line</field>
|
<!-- <field name="res_model">account.move.line</field>-->
|
||||||
<field name="view_type">form</field>
|
<!-- <field name="view_type">form</field>-->
|
||||||
<field name="view_mode">tree,form,graph</field>
|
<!-- <field name="view_mode">tree,form,graph</field>-->
|
||||||
<field name="view_id" ref="view_move_line_tree"/>
|
<!-- <field name="view_id" ref="view_move_line_tree"/>-->
|
||||||
<field name="search_view_id" ref="view_account_move_line_filter"/>
|
<!-- <field name="search_view_id" ref="view_account_move_line_filter"/>-->
|
||||||
<field name="domain">[('journal_id.type', 'in', ['purchase', 'sale_refund'])]</field>
|
<!-- <field name="domain">[('journal_id.type', 'in', ['purchase', 'sale_refund'])]</field>-->
|
||||||
</record>
|
<!-- </record>-->
|
||||||
|
|
||||||
<menuitem action="action_account_moves_purchase" id="menu_eaction_account_moves_purchase" parent="menu_finance_payables"/>
|
<!-- <menuitem action="action_account_moves_purchase" id="menu_eaction_account_moves_purchase" parent="menu_finance_payables"/>-->
|
||||||
|
|
||||||
<record id="action_move_line_search" model="ir.actions.act_window">
|
<record id="action_move_line_search" model="ir.actions.act_window">
|
||||||
<field name="name">Entry Lines</field>
|
<field name="name">Entry Lines</field>
|
||||||
|
@ -2416,22 +2417,22 @@
|
||||||
id="menu_action_account_fiscal_position_form_template"
|
id="menu_action_account_fiscal_position_form_template"
|
||||||
parent="account_template_folder" sequence="20"/>
|
parent="account_template_folder" sequence="20"/>
|
||||||
|
|
||||||
<record id="action_account_moves_all" model="ir.actions.act_window">
|
<!-- <record id="action_account_moves_all" model="ir.actions.act_window">-->
|
||||||
<field name="name">Journal Items</field>
|
<!-- <field name="name">Journal Items</field>-->
|
||||||
<field name="res_model">account.move.line</field>
|
<!-- <field name="res_model">account.move.line</field>-->
|
||||||
<field name="view_type">form</field>
|
<!-- <field name="view_type">form</field>-->
|
||||||
<field name="view_mode">tree,form,graph</field>
|
<!-- <field name="view_mode">tree,form,graph</field>-->
|
||||||
<field name="view_id" ref="view_move_line_tree"/>
|
<!-- <field name="view_id" ref="view_move_line_tree"/>-->
|
||||||
<field name="search_view_id" ref="view_account_move_line_filter"/>
|
<!-- <field name="search_view_id" ref="view_account_move_line_filter"/>-->
|
||||||
</record>
|
<!-- </record>-->
|
||||||
|
|
||||||
<menuitem
|
<!-- <menuitem-->
|
||||||
action="action_account_moves_all"
|
<!-- action="action_account_moves_all"-->
|
||||||
icon="STOCK_JUSTIFY_FILL"
|
<!-- icon="STOCK_JUSTIFY_FILL"-->
|
||||||
id="menu_eaction_account_moves_all"
|
<!-- id="menu_eaction_account_moves_all"-->
|
||||||
parent="account.menu_finance_entries"
|
<!-- parent="account.menu_finance_entries"-->
|
||||||
sequence="4"
|
<!-- sequence="4"-->
|
||||||
/>
|
<!-- />-->
|
||||||
|
|
||||||
<!-- Cash Statement -->
|
<!-- Cash Statement -->
|
||||||
<record id="view_cash_statement_tree" model="ir.ui.view">
|
<record id="view_cash_statement_tree" model="ir.ui.view">
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
-
|
-
|
||||||
!record {model: account.move.journal, id: account_move_journal_0}:
|
!record {model: account.move.journal, id: account_move_journal_0}:
|
||||||
journal_id: account.sales_journal
|
journal_id: account.sales_journal
|
||||||
period_id: account_period_jan11
|
|
||||||
-
|
-
|
||||||
I clicked on Open Journal Button to check the entries
|
I clicked on Open Journal Button to check the entries
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Journal Select">
|
<form string="Journal Select">
|
||||||
<label string="Are you sure you want to open Journal Entries?" colspan="4"/>
|
<label string="Are you sure you want to open Journal Entries?" colspan="4"/>
|
||||||
<separator string="" colspan="4" />
|
<separator string="" colspan="4" />
|
||||||
<group colspan="4" col="6">
|
<group colspan="4" col="6">
|
||||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||||
<button icon="terp-gtk-go-back-rtl" string="Open Entries" name="action_open_window" type="object"/>
|
<button icon="terp-gtk-go-back-rtl" string="Open Entries" name="action_open_window" type="object"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
@ -26,22 +26,81 @@ import tools
|
||||||
class account_move_journal(osv.osv_memory):
|
class account_move_journal(osv.osv_memory):
|
||||||
_name = "account.move.journal"
|
_name = "account.move.journal"
|
||||||
_description = "Move journal"
|
_description = "Move journal"
|
||||||
_columns = {
|
|
||||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
|
||||||
'period_id': fields.many2one('account.period', 'Period', required=True),
|
|
||||||
}
|
|
||||||
|
|
||||||
def _get_period(self, cr, uid, context={}):
|
def _get_period(self, cr, uid, context={}):
|
||||||
"""Return default account period value"""
|
"""
|
||||||
|
Return default account period value
|
||||||
|
"""
|
||||||
ids = self.pool.get('account.period').find(cr, uid, context=context)
|
ids = self.pool.get('account.period').find(cr, uid, context=context)
|
||||||
period_id = False
|
period_id = False
|
||||||
if len(ids):
|
if len(ids):
|
||||||
period_id = ids[0]
|
period_id = ids[0]
|
||||||
return period_id
|
return period_id
|
||||||
|
|
||||||
_defaults = {
|
def _get_journal(self, cr, uid, context={}):
|
||||||
'period_id': _get_period
|
"""
|
||||||
}
|
Return journal based on the journal type
|
||||||
|
"""
|
||||||
|
|
||||||
|
journal_id = False
|
||||||
|
|
||||||
|
journal_pool = self.pool.get('account.journal')
|
||||||
|
if context.get('journal_type', False):
|
||||||
|
jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
|
||||||
|
journal_id = jids[0]
|
||||||
|
|
||||||
|
return journal_id
|
||||||
|
|
||||||
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||||
|
"""
|
||||||
|
Returns views and fields for current model where view will depend on {view_type}.
|
||||||
|
@param cr: A database cursor
|
||||||
|
@param user: ID of the user currently logged in
|
||||||
|
@param view_id: list of fields, which required to read signatures
|
||||||
|
@param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
|
||||||
|
@param context: context arguments, like lang, time zone
|
||||||
|
@param toolbar: contains a list of reports, wizards, and links related to current model
|
||||||
|
|
||||||
|
@return: Returns a dict that contains definition for fields, views, and toolbars
|
||||||
|
"""
|
||||||
|
|
||||||
|
res = super(account_move_journal, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||||
|
|
||||||
|
if not view_id:
|
||||||
|
return res
|
||||||
|
|
||||||
|
period_pool = self.pool.get('account.period')
|
||||||
|
journal_pool = self.pool.get('account.journal')
|
||||||
|
|
||||||
|
journal_id = self._get_journal(cr, uid, context)
|
||||||
|
period_id = self._get_period(cr, uid, context)
|
||||||
|
|
||||||
|
journal = False
|
||||||
|
if journal_id:
|
||||||
|
journal = journal_pool.read(cr, uid, [journal_id], ['name'])[0]['name']
|
||||||
|
else:
|
||||||
|
journal = "All"
|
||||||
|
|
||||||
|
period = False
|
||||||
|
if period_id:
|
||||||
|
period = period_pool.browse(cr, uid, [period_id], ['name'])[0]['name']
|
||||||
|
|
||||||
|
view = """<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<form string="Standard entries">
|
||||||
|
<separator string="Open a Journal Items" colspan="4"/>
|
||||||
|
<group colspan="4" >
|
||||||
|
<label width="300" string="Going to open a %s Journal(s) for %s Period"/>
|
||||||
|
</group>
|
||||||
|
<group colspan="4" col="4">
|
||||||
|
<label string ="" colspan="2"/>
|
||||||
|
<button icon="terp-gtk-go-back-rtl" string="Ok" name="action_open_window" type="object"/>
|
||||||
|
</group>
|
||||||
|
</form>""" % (str(journal), str(period))
|
||||||
|
|
||||||
|
res.update({
|
||||||
|
'arch':view
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
|
||||||
def action_open_window(self, cr, uid, ids, context=None):
|
def action_open_window(self, cr, uid, ids, context=None):
|
||||||
"""
|
"""
|
||||||
|
@ -50,47 +109,59 @@ class account_move_journal(osv.osv_memory):
|
||||||
@param uid: the current user’s ID for security checks,
|
@param uid: the current user’s ID for security checks,
|
||||||
@param ids: account move journal’s ID or list of IDs
|
@param ids: account move journal’s ID or list of IDs
|
||||||
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
|
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
|
||||||
|
|
||||||
"""
|
"""
|
||||||
jp = self.pool.get('account.journal.period')
|
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
period_pool = self.pool.get('account.journal.period')
|
||||||
|
data_pool = self.pool.get('ir.model.data')
|
||||||
|
journal_pool = self.pool.get('account.journal')
|
||||||
|
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
data = self.read(cr, uid, ids, ['journal_id', 'period_id'], context=context)[0]
|
|
||||||
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
|
|
||||||
view_res = cr.fetchone()
|
|
||||||
journal_id = data['journal_id']
|
|
||||||
period_id = data['period_id']
|
|
||||||
|
|
||||||
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
|
journal_id = self._get_journal(cr, uid, context)
|
||||||
('period_id', '=', period_id)],context=context)
|
period_id = self._get_period(cr, uid, context)
|
||||||
|
|
||||||
if not len(ids):
|
name = _("Journal Items")
|
||||||
name = self.pool.get('account.journal').read(cr, uid, [journal_id])[0]['name']
|
if journal_id:
|
||||||
state = self.pool.get('account.period').read(cr, uid, [period_id])[0]['state']
|
ids = period_pool.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)], context=context)
|
||||||
if state == 'done':
|
|
||||||
raise osv.except_osv(_('UserError'), _('This period is already closed !'))
|
|
||||||
company = self.pool.get('account.period').read(cr, uid, [period_id])[0]['company_id'][0]
|
|
||||||
jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company},context=context)
|
|
||||||
|
|
||||||
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
|
if not len(ids):
|
||||||
jp = jp.browse(cr, uid, ids, context=context)[0]
|
journal = journal_pool.browse(cr, uid, journal_id)
|
||||||
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
|
period = self.pool.get('account.period').browse(cr, uid, period_id)
|
||||||
|
|
||||||
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
|
name = journal.name
|
||||||
res = mod_obj.read(cr, uid, result, ['res_id'],context=context)
|
state = period.state
|
||||||
|
|
||||||
|
if state == 'done':
|
||||||
|
raise osv.except_osv(_('UserError'), _('This period is already closed !'))
|
||||||
|
|
||||||
|
company = period.company_id.id
|
||||||
|
res = {
|
||||||
|
'name': name,
|
||||||
|
'period_id': period_id,
|
||||||
|
'journal_id': journal_id,
|
||||||
|
'company_id': company
|
||||||
|
}
|
||||||
|
period_pool.create(cr, uid, res,context=context)
|
||||||
|
|
||||||
|
ids = period_pool.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
|
||||||
|
period = period_pool.browse(cr, uid, ids[0], context=context)
|
||||||
|
name = (period.journal_id.code or '') + ':' + (period.period_id.code or '')
|
||||||
|
|
||||||
|
result = data_pool._get_id(cr, uid, 'account', 'view_account_move_line_filter')
|
||||||
|
res_id = data_pool.browse(cr, uid, result, context=context).res_id
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id, period_id),
|
# 'domain': str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]),
|
||||||
'name': name,
|
'name': name,
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form,graph',
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'view_id': view_res,
|
'view_id': False,
|
||||||
'context': "{'journal_id': %d, 'period_id': %d}" % (journal_id, period_id),
|
'context': "{'journal_id': %d, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, period_id),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'search_view_id': res['res_id']
|
'search_view_id': res_id
|
||||||
}
|
}
|
||||||
|
|
||||||
account_move_journal()
|
account_move_journal()
|
||||||
|
|
||||||
|
|
|
@ -2,40 +2,72 @@
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="view_account_move_journal_form" model="ir.ui.view">
|
<record id="view_account_move_journal_form" model="ir.ui.view">
|
||||||
<field name="name">account.move.journal.form</field>
|
<field name="name">account.move.journal.form</field>
|
||||||
<field name="model">account.move.journal</field>
|
<field name="model">account.move.journal</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Standard entries">
|
<form string="Standard entries">
|
||||||
<group colspan="4" >
|
|
||||||
<field name="journal_id"/>
|
|
||||||
<newline/>
|
|
||||||
<field name="period_id" />
|
|
||||||
</group>
|
|
||||||
<separator string="" colspan="4" />
|
|
||||||
<group colspan="4" col="6">
|
|
||||||
<label string ="" colspan="2"/>
|
|
||||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
|
||||||
<button icon="terp-gtk-go-back-rtl" string="Open Journal" name="action_open_window" type="object"/>
|
|
||||||
</group>
|
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_account_move_journal_line_form" model="ir.actions.act_window">
|
<record id="action_account_moves_sale" model="ir.actions.act_window">
|
||||||
<field name="name">Entries by Line</field>
|
<field name="name">Journal Items</field>
|
||||||
<field name="res_model">account.move.journal</field>
|
<field name="res_model">account.move.journal</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_id" ref="view_account_move_journal_form"/>
|
||||||
<field name="view_id" ref="view_account_move_journal_form"/>
|
<field name="context">{'journal_type':'sale'}</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
<menuitem action="action_account_moves_sale" sequence="4" id="menu_eaction_account_moves_sale" parent="menu_finance_receivables" icon="STOCK_JUSTIFY_FILL"/>
|
||||||
|
|
||||||
|
<record id="action_account_moves_purchase_refund" model="ir.actions.act_window">
|
||||||
|
<field name="name">Journal Refund Items</field>
|
||||||
|
<field name="res_model">account.move.journal</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_id" ref="view_account_move_journal_form"/>
|
||||||
|
<field name="context">{'journal_type':'purchase_refund'}</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
<menuitem action="action_account_moves_purchase_refund" sequence="5" id="menu_eaction_account_moves_purchase_refund" parent="menu_finance_receivables" icon="STOCK_JUSTIFY_FILL"/>
|
||||||
|
|
||||||
|
<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="view_id" ref="view_account_move_journal_form"/>
|
||||||
|
<field name="context">{'journal_type':'purchase'}</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
<menuitem action="action_account_moves_purchase" sequence="4" id="menu_eaction_account_moves_purchase" parent="menu_finance_payables" icon="STOCK_JUSTIFY_FILL"/>
|
||||||
|
|
||||||
|
<record id="action_account_moves_sale_refund" model="ir.actions.act_window">
|
||||||
|
<field name="name">Journal Refund Items</field>
|
||||||
|
<field name="res_model">account.move.journal</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_id" ref="view_account_move_journal_form"/>
|
||||||
|
<field name="context">{'journal_type':'sale_refund'}</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
<menuitem action="action_account_moves_sale_refund" sequence="5" id="menu_eaction_account_moves_sale_refund" parent="menu_finance_payables" icon="STOCK_JUSTIFY_FILL"/>
|
||||||
|
|
||||||
|
<record id="action_account_moves_all" 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="view_id" ref="view_account_move_journal_form"/>
|
||||||
|
<field name="context">{'journal_type':'bank'}</field>
|
||||||
|
<field name="target">new</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- <menuitem icon="STOCK_JUSTIFY_FILL"-->
|
<menuitem
|
||||||
<!-- action="action_account_move_journal_line_form"-->
|
action="action_account_moves_all"
|
||||||
<!-- id="menu_action_move_journal_line_form"-->
|
icon="STOCK_JUSTIFY_FILL"
|
||||||
<!-- parent="account.menu_finance_entries" sequence="5" />-->
|
id="menu_eaction_account_moves_all"
|
||||||
|
parent="account.menu_finance_entries"
|
||||||
|
sequence="4"
|
||||||
|
/>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
Loading…
Reference in New Issue