[IMP]: improve a accounting module
account account voucher account voucher payment bzr revid: mga@tinyerp.com-20100728183557-ykq5kiqea2tv73ze
This commit is contained in:
@@ -1288,11 +1288,11 @@
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('to_check','=',True)]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="ref" select="1"/>
|
||||
<field name="ref" select="1"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="partner_id" select='1'/>
|
||||
<field name="date" select='1'/>
|
||||
<field name="narration" select="1"/>
|
||||
<field name="partner_id" select='1'/>
|
||||
<field name="date" select='1'/>
|
||||
<field name="narration" select="1"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
|
||||
@@ -25,21 +25,19 @@
|
||||
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_account_tree2")],
|
||||
"tz": False, "active_id": ref("account.menu_action_account_tree2"), })
|
||||
|
||||
-
|
||||
In order to test Account Move Line Wizard I check the move line entries using this wizard
|
||||
-
|
||||
!record {model: account.move.line.select, id: account_move_line_select_0}:
|
||||
{}
|
||||
-
|
||||
I clicked on Button to open the account move lines
|
||||
-
|
||||
!python {model: account.move.line.select}: |
|
||||
self.open_window(cr, uid, [ref("account_move_line_select_0")], {"lang": 'en_US',
|
||||
"state": "all", "tz": False, "active_model": "account.account", "active_ids":
|
||||
[ref("account.a_recv")], "fiscalyear": 1, "active_id": ref("account.a_recv"),
|
||||
})
|
||||
|
||||
|
||||
#-
|
||||
# In order to test Account Move Line Wizard I check the move line entries using this wizard
|
||||
#-
|
||||
# !record {model: account.move.line.select, id: account_move_line_select_0}:
|
||||
# {}
|
||||
#-
|
||||
# I clicked on Button to open the account move lines
|
||||
#-
|
||||
# !python {model: account.move.line.select}: |
|
||||
# self.open_window(cr, uid, [ref("account_move_line_select_0")], {"lang": 'en_US',
|
||||
# "state": "all", "tz": False, "active_model": "account.account", "active_ids":
|
||||
# [ref("account.a_recv")], "fiscalyear": 1, "active_id": ref("account.a_recv"),
|
||||
# })
|
||||
-
|
||||
In order to test the Analytic Charts of Account wizard I will generate chart
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ class account_voucher(osv.osv):
|
||||
('bank_pay_voucher','Bank Payment'),
|
||||
('rec_voucher','Cash Receipt'),
|
||||
('bank_rec_voucher','Bank Receipt'),
|
||||
# ('cont_voucher','Contra'),
|
||||
('journal_sale_vou','Journal Sale'),
|
||||
('journal_pur_voucher','Journal Purchase'),
|
||||
('journal_voucher','Journal Voucher'),
|
||||
@@ -120,9 +119,9 @@ class account_voucher(osv.osv):
|
||||
'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"),
|
||||
'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}, domain=[('type','<>','view')]),
|
||||
'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'draft':[('readonly',True)]}),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'posted':[('readonly',True)]}),
|
||||
'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}, required=False),
|
||||
'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'posted':[('readonly',False)]}),
|
||||
'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'state':fields.selection(
|
||||
@@ -262,26 +261,33 @@ class account_voucher(osv.osv):
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
analytic_pool = self.pool.get('account.analytic.line')
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
invoice_pool = self.pool.get('account.invoice')
|
||||
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
|
||||
|
||||
if inv.move_id:
|
||||
continue
|
||||
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
diff_currency_p = inv.currency_id.id <> company_currency
|
||||
|
||||
|
||||
journal = journal_pool.browse(cr, uid, inv.journal_id.id)
|
||||
if journal.sequence_id:
|
||||
name = sequence_pool.get_id(cr, uid, journal.sequence_id.id)
|
||||
|
||||
ref = False
|
||||
if inv.type in ('journal_pur_voucher', 'bank_rec_voucher', 'rec_voucher'):
|
||||
ref = inv.reference
|
||||
else:
|
||||
ref = invoice_pool._convert_ref(cr, uid, name)
|
||||
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
diff_currency_p = inv.currency_id.id <> company_currency
|
||||
|
||||
move = {
|
||||
'name' : name,
|
||||
'journal_id': journal.id,
|
||||
'type' : inv.type,
|
||||
'narration' : inv.narration and inv.narration or inv.name,
|
||||
'name':name,
|
||||
'journal_id':journal.id,
|
||||
'type':inv.type,
|
||||
'narration':inv.narration and inv.narration or inv.name,
|
||||
'date':inv.date,
|
||||
'ref':inv.reference
|
||||
'ref':ref
|
||||
}
|
||||
|
||||
if inv.period_id:
|
||||
@@ -301,7 +307,7 @@ class account_voucher(osv.osv):
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'partner_id': False,
|
||||
'ref': inv.reference,
|
||||
'ref':ref,
|
||||
'date': inv.date
|
||||
}
|
||||
if diff_currency_p:
|
||||
@@ -321,18 +327,22 @@ class account_voucher(osv.osv):
|
||||
line_ids += [move_line_pool.create(cr, uid, move_line)]
|
||||
for line in inv.payment_ids:
|
||||
amount=0.0
|
||||
|
||||
if inv.type in ('bank_pay_voucher', 'pay_voucher', 'journal_voucher'):
|
||||
ref = line.ref
|
||||
|
||||
move_line = {
|
||||
'name': line.name,
|
||||
'debit': False,
|
||||
'credit': False,
|
||||
'account_id': line.account_id.id or False,
|
||||
'move_id': move_id ,
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'partner_id': line.partner_id.id or False,
|
||||
'ref': line.ref,
|
||||
'date': inv.date,
|
||||
'analytic_account_id': False
|
||||
'name':line.name,
|
||||
'debit':False,
|
||||
'credit':False,
|
||||
'account_id':line.account_id.id or False,
|
||||
'move_id':move_id ,
|
||||
'journal_id':inv.journal_id.id,
|
||||
'period_id':inv.period_id.id,
|
||||
'partner_id':line.partner_id.id or False,
|
||||
'ref':ref,
|
||||
'date':inv.date,
|
||||
'analytic_account_id':False
|
||||
}
|
||||
|
||||
if diff_currency_p:
|
||||
@@ -400,9 +410,9 @@ class account_voucher(osv.osv):
|
||||
context={}
|
||||
ids = []
|
||||
if name:
|
||||
ids = self.search(cr, user, [('number','=',name)]+ args, limit=limit, context=context)
|
||||
ids = self.search(cr, user, [('number','=',name)]+args, limit=limit, context=context)
|
||||
if not ids:
|
||||
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
|
||||
ids = self.search(cr, user, [('name',operator,name)]+args, limit=limit, context=context)
|
||||
return self.name_get(cr, user, ids, context)
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open','proforma','posted','recheck','audit')" string="Accounting Vouchers">
|
||||
<tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open','proforma','posted','recheck','audit')" string="Voucher Entries">
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="name"/>
|
||||
@@ -34,7 +34,7 @@
|
||||
<field name="type" on_change="onchange_journal(journal_id,type)"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Journal Entries">
|
||||
<page string="Voucher Entry">
|
||||
<field name="payment_ids" colspan="4" nolabel="1" height="200">
|
||||
<tree string="Voucher Lines" editable="top">
|
||||
<field name="partner_id" on_change="onchange_partner(partner_id,type,parent.type, parent.currency_id)"/>
|
||||
@@ -55,7 +55,6 @@
|
||||
<field name="reference" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="currency_id" select="1"/>
|
||||
|
||||
</group>
|
||||
</page>
|
||||
<page string="Accounting Entries">
|
||||
@@ -88,11 +87,13 @@
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-check" string="Proforma" domain="[('state','=','proforma')]" help="Proforma Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<filter icon="terp-gtk-stop" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Vouchers"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="Reviewed" domain="[('state','=','audit')]" groups="base.group_extended" help="To Review"/>
|
||||
<filter icon="terp-gtk-stop" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Vouchers" groups="base.group_extended"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date" select='1'/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="number" select='1'/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="account_id" select="1"/>
|
||||
<field name="partner_id" select='1'/>
|
||||
</group>
|
||||
<newline/>
|
||||
@@ -106,7 +107,6 @@
|
||||
<group expand="0" string="Extended options...">
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" />
|
||||
<field name="period_id" widget="selection" context="{'period_id': self}" groups="base.group_extended"/>
|
||||
<field name="type" context="{'type': self}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
@@ -120,15 +120,25 @@
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-check" string="Proforma" domain="[('state','=','proforma')]" help="Proforma Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<filter icon="terp-gtk-stop" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','audit')]" help="Posted Vouchers"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<filter icon="terp-gtk-stop" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Vouchers" groups="base.group_extended"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date" select='1'/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="number" select='1'/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="account_id" select="1"/>
|
||||
<field name="partner_id" select='1'/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" select="1"/>
|
||||
<field name="period_id" widget="selection" select="1"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="narration" select="1"/>
|
||||
<field name="date" select='1'/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="12" col="10">
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id'}"/>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = "account.move.line"
|
||||
_columns = {
|
||||
@@ -45,26 +44,33 @@ class account_voucher(osv.osv):
|
||||
analytic_pool = self.pool.get('account.analytic.line')
|
||||
currency_pool = self.pool.get('res.currency')
|
||||
invoice_pool = self.pool.get('account.invoice')
|
||||
invoice_pool = self.pool.get('account.invoice')
|
||||
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
|
||||
if inv.move_id:
|
||||
continue
|
||||
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
diff_currency_p = inv.currency_id.id <> company_currency
|
||||
|
||||
journal = journal_pool.browse(cr, uid, inv.journal_id.id)
|
||||
if journal.sequence_id:
|
||||
name = sequence_pool.get_id(cr, uid, journal.sequence_id.id)
|
||||
|
||||
ref = False
|
||||
if inv.type in ('journal_pur_voucher', 'bank_rec_voucher', 'rec_voucher'):
|
||||
ref = inv.reference
|
||||
else:
|
||||
ref = invoice_pool._convert_ref(cr, uid, name)
|
||||
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
diff_currency_p = inv.currency_id.id <> company_currency
|
||||
|
||||
move = {
|
||||
'name' : name,
|
||||
'journal_id': journal.id,
|
||||
'type' : inv.type,
|
||||
'narration' : inv.narration and inv.narration or inv.name,
|
||||
'date':inv.date,
|
||||
'ref':inv.reference
|
||||
'ref':ref
|
||||
}
|
||||
|
||||
if inv.period_id:
|
||||
@@ -76,16 +82,16 @@ class account_voucher(osv.osv):
|
||||
|
||||
#create the first line manually
|
||||
move_line = {
|
||||
'name': inv.name,
|
||||
'debit': False,
|
||||
'name':inv.name,
|
||||
'debit':False,
|
||||
'credit':False,
|
||||
'account_id': inv.account_id.id or False,
|
||||
'move_id': move_id ,
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'partner_id': False,
|
||||
'ref': inv.reference,
|
||||
'date': inv.date
|
||||
'account_id':inv.account_id.id or False,
|
||||
'move_id':move_id ,
|
||||
'journal_id':inv.journal_id.id,
|
||||
'period_id':inv.period_id.id,
|
||||
'partner_id':False,
|
||||
'ref':ref,
|
||||
'date':inv.date
|
||||
}
|
||||
if diff_currency_p:
|
||||
amount_currency = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount)
|
||||
@@ -103,20 +109,25 @@ class account_voucher(osv.osv):
|
||||
line_ids = []
|
||||
line_ids += [move_line_pool.create(cr, uid, move_line)]
|
||||
rec_ids = []
|
||||
|
||||
for line in inv.payment_ids:
|
||||
amount=0.0
|
||||
|
||||
if inv.type in ('bank_pay_voucher', 'pay_voucher', 'journal_voucher'):
|
||||
ref = line.ref
|
||||
|
||||
move_line = {
|
||||
'name': line.name,
|
||||
'debit': False,
|
||||
'credit': False,
|
||||
'account_id': line.account_id.id or False,
|
||||
'move_id': move_id ,
|
||||
'journal_id': inv.journal_id.id,
|
||||
'period_id': inv.period_id.id,
|
||||
'partner_id': line.partner_id.id or False,
|
||||
'ref': line.ref,
|
||||
'date': inv.date,
|
||||
'analytic_account_id': False
|
||||
'name':line.name,
|
||||
'debit':False,
|
||||
'credit':False,
|
||||
'account_id':line.account_id.id or False,
|
||||
'move_id':move_id ,
|
||||
'journal_id':inv.journal_id.id,
|
||||
'period_id':inv.period_id.id,
|
||||
'partner_id':line.partner_id.id or False,
|
||||
'ref':ref,
|
||||
'date':inv.date,
|
||||
'analytic_account_id':False
|
||||
}
|
||||
|
||||
if diff_currency_p:
|
||||
@@ -151,9 +162,7 @@ class account_voucher(osv.osv):
|
||||
rec_ids += [move_line_id]
|
||||
for move_line in line.invoice_id.move_id.line_id:
|
||||
if line.account_id.id == move_line.account_id.id:
|
||||
rec_ids += [move_line.id]
|
||||
#move_line_pool.reconcile_partial(cr, uid, rec_ids)
|
||||
|
||||
rec_ids += [move_line.id]
|
||||
if rec_ids:
|
||||
move_line_pool.reconcile_partial(cr, uid, rec_ids)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user