[IMP]: improve account voucher
bzr revid: mga@tinyerp.com-20100817073251-vucfjf4uxkeunvp2
This commit is contained in:
@@ -105,7 +105,7 @@ class account_voucher(osv.osv):
|
||||
_rec_name = 'number'
|
||||
|
||||
_columns = {
|
||||
'name':fields.char('Name', size=256, required=False, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'name':fields.char('Memo', size=256, required=False, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'type': fields.selection([
|
||||
('payment', 'Payment'),
|
||||
('receipt', 'Receipt'),
|
||||
@@ -133,7 +133,7 @@ class account_voucher(osv.osv):
|
||||
\n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \
|
||||
\n* The \'Cancelled\' state is used when user cancel voucher.'),
|
||||
'amount':fields.float('Amount', readonly=True),
|
||||
'reference': fields.char('Reference', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Payment or Receipt transaction number, i.e. Bank cheque number or payorder number or Wire transfer number or Acknowledge number."),
|
||||
'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Payment or Receipt transaction number, i.e. Bank cheque number or payorder number or Wire transfer number or Acknowledge number."),
|
||||
'reference_type': fields.selection(_get_reference_type, 'Reference Type', required=True),
|
||||
'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'),
|
||||
'move_id':fields.many2one('account.move', 'Account Entry'),
|
||||
@@ -244,42 +244,44 @@ class account_voucher(osv.osv):
|
||||
voucher_line_pool.unlink(dbcr, uid, line_ids)
|
||||
|
||||
voucher = voucher_pool.browse(dbcr, uid, ids[0])
|
||||
if voucher.account_id.tax_ids:
|
||||
if voucher.type in ('sale', 'purchase'):
|
||||
if voucher.account_id.tax_ids:
|
||||
for line in voucher.payment_ids:
|
||||
if voucher.account_id.tax_ids:
|
||||
for line in voucher.payment_ids:
|
||||
|
||||
if line.amount <= 0:
|
||||
raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !'))
|
||||
if line.amount <= 0:
|
||||
raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !'))
|
||||
|
||||
part = line.partner_id and partner_pool.browse(dbcr, uid, line.partner_id.id) or False
|
||||
taxes = position_pool.map_tax(dbcr, uid, part and part.property_account_position or False, voucher.account_id.tax_ids)
|
||||
taxes = tax_pool.browse(dbcr, uid, taxes)
|
||||
new_price = line.amount
|
||||
for tax in tax_pool.compute_all(dbcr, uid, taxes, line.amount, 1).get('taxes'):
|
||||
tax_line = {
|
||||
'name':"%s / %s" % (line.name, tax.get('name')),
|
||||
'amount':tax.get('amount'),
|
||||
'voucher_id': voucher.id,
|
||||
'is_tax':True
|
||||
}
|
||||
crdr = False
|
||||
account = False
|
||||
if voucher.type == 'purchase':
|
||||
crdr = 'dr'
|
||||
account = tax.get('account_paid_id')
|
||||
elif voucher.type == 'sale':
|
||||
crdr = 'cr'
|
||||
account = tax.get('account_collected_id', account)
|
||||
part = line.partner_id and partner_pool.browse(dbcr, uid, line.partner_id.id) or False
|
||||
taxes = position_pool.map_tax(dbcr, uid, part and part.property_account_position or False, voucher.account_id.tax_ids)
|
||||
taxes = tax_pool.browse(dbcr, uid, taxes)
|
||||
new_price = line.amount
|
||||
for tax in tax_pool.compute_all(dbcr, uid, taxes, line.amount, 1).get('taxes'):
|
||||
tax_line = {
|
||||
'name':"%s / %s" % (line.name, tax.get('name')),
|
||||
'amount':tax.get('amount'),
|
||||
'voucher_id': voucher.id,
|
||||
'is_tax':True,
|
||||
'ref':tax.get('name')
|
||||
}
|
||||
crdr = False
|
||||
account = False
|
||||
if voucher.type == 'purchase':
|
||||
crdr = 'dr'
|
||||
account = tax.get('account_paid_id')
|
||||
elif voucher.type == 'sale':
|
||||
crdr = 'cr'
|
||||
account = tax.get('account_collected_id', account)
|
||||
|
||||
tax_line.update({
|
||||
'account_id':account or voucher.account_id.id,
|
||||
'type':crdr
|
||||
})
|
||||
new_line += [tax_line]
|
||||
tax_line.update({
|
||||
'account_id':account or voucher.account_id.id,
|
||||
'type':crdr
|
||||
})
|
||||
new_line += [tax_line]
|
||||
|
||||
if new_line:
|
||||
for line in new_line:
|
||||
voucher_line_pool.create(dbcr, uid, line)
|
||||
if new_line:
|
||||
for line in new_line:
|
||||
voucher_line_pool.create(dbcr, uid, line)
|
||||
|
||||
voucher = voucher_pool.browse(dbcr, uid, ids[0])
|
||||
for line in voucher.payment_ids:
|
||||
@@ -312,12 +314,12 @@ class account_voucher(osv.osv):
|
||||
# return res
|
||||
|
||||
def voucher_recheck(self, cr, uid, ids, context={}):
|
||||
# self.open_voucher(cr, uid, ids, context)
|
||||
self.open_voucher(cr, uid, ids, context)
|
||||
self.write(cr, uid, ids, {'state':'recheck'}, context)
|
||||
return True
|
||||
|
||||
def proforma_voucher(self, cr, uid, ids, context={}):
|
||||
# self.open_voucher(cr, uid, ids, context)
|
||||
self.open_voucher(cr, uid, ids, context)
|
||||
self.action_move_line_create(cr, uid, ids)
|
||||
self.write(cr, uid, ids, {'state':'posted'})
|
||||
return True
|
||||
@@ -560,10 +562,9 @@ class account_voucher_line(osv.osv):
|
||||
_description = 'Voucher Line'
|
||||
_columns = {
|
||||
'voucher_id':fields.many2one('account.voucher', 'Voucher'),
|
||||
'name':fields.char('Memo', size=256, required=True),
|
||||
'name':fields.related('voucher_id', 'name', size=256, type='char', string='Memo'),
|
||||
'account_id':fields.many2one('account.account','Account', required=True, domain=[('type','<>','view')]),
|
||||
# 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True),
|
||||
'partner_id': fields.related('voucher_id','partner_id', type='many2one', relation='res.partner', string='Partner'),
|
||||
'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
|
||||
'amount':fields.float('Amount'),
|
||||
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Type'),
|
||||
'ref':fields.char('Reference', size=32),
|
||||
|
||||
@@ -32,13 +32,11 @@
|
||||
<form string="Accounting Voucher">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id"/>
|
||||
<field name="name"/>
|
||||
<field name="number"/>
|
||||
<field name="journal_id" select="1" on_change="onchange_journal(journal_id,type)"/>
|
||||
<field name="account_id" on_change="onchange_account(account_id)"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="journal_id" widget="selection" select="1" on_change="onchange_journal(journal_id,type)"/>
|
||||
<field name="account_id" widget="selection" on_change="onchange_account(account_id)" readonly="1"/>
|
||||
<field name="type" on_change="onchange_journal(journal_id,type)"/>
|
||||
</group>
|
||||
|
||||
<notebook colspan="4">
|
||||
<page string="Voucher Entry">
|
||||
<field name="payment_ids" colspan="4" nolabel="1" height="180">
|
||||
@@ -57,6 +55,7 @@
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<field name="number"/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="date" select="1" on_change="onchange_date(date)"/>
|
||||
<field name="currency_id" select="1" attrs="{'readonly':[('type','in',['sale', 'purchase'])]}"/>
|
||||
@@ -74,7 +73,7 @@
|
||||
</notebook>
|
||||
<group col="10" colspan="4">
|
||||
<field name="state"/>
|
||||
<button name="open_voucher" states="draft" attrs="{'readonly':[('type','not in',['sale', 'purchase'])]}" string="Compute" type="object" icon="terp-stock_format-scientific"/>
|
||||
<!-- <button name="open_voucher" states="draft" string="Compute" type="object" icon="terp-stock_format-scientific"/>-->
|
||||
<button name="proforma_voucher" string="Create" states="draft" icon="terp-document-new"/>
|
||||
<button name="recheck_voucher" string="Approve" states="recheck" icon="terp-check"/>
|
||||
<!-- <button name="audit_complete" string="Audit Pass" states="posted" icon="terp-check"/>-->
|
||||
@@ -182,7 +181,7 @@
|
||||
|
||||
<!-- Receipt Vouchers -->
|
||||
<record model="ir.actions.act_window" id="action_receipt_vou_voucher_list">
|
||||
<field name="name">Receivable Vouchers</field>
|
||||
<field name="name">Sales Vouchers</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,graph</field>
|
||||
@@ -196,7 +195,7 @@
|
||||
|
||||
<!-- Purchase Vouchers -->
|
||||
<record model="ir.actions.act_window" id="action_pay_vou_voucher_list">
|
||||
<field name="name">Payable Vouchers</field>
|
||||
<field name="name">Purchase Vouchers</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,graph</field>
|
||||
@@ -221,19 +220,35 @@
|
||||
<menuitem action="action_voucher_list" id="menu_encode_entries_by_voucher" parent="account.menu_finance_entries" sequence="6"/>
|
||||
|
||||
<record id="action_cheque_register" model="ir.actions.act_window">
|
||||
<field name="name">Vouchers</field>
|
||||
<field name="name">Receive Payments</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('journal_id.type', '=', 'bank')]</field>
|
||||
<field name="domain">[('journal_id.type', '=', 'bank'), ('type','=','receipt')]</field>
|
||||
<field name="context">{'type':'bank'}</field>
|
||||
<field name="view_id" ref="view_voucher_tree"/>
|
||||
<field name="search_view_id" ref="view_voucher_filter_new"/>
|
||||
</record>
|
||||
<menuitem action="action_cheque_register"
|
||||
id="menu_action_cheque_register"
|
||||
parent="account.menu_finance_bank_and_cash"/>
|
||||
|
||||
<menuitem action="action_cheque_register" id="menu_action_cheque_register" parent="account.menu_finance_bank_and_cash"/>
|
||||
|
||||
<record id="action_cheque_pay" model="ir.actions.act_window">
|
||||
<field name="name">Pay Bills</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('journal_id.type', '=', 'bank'), ('type','=','payment')]</field>
|
||||
<field name="context">{'type':'bank'}</field>
|
||||
<field name="view_id" ref="view_voucher_tree"/>
|
||||
<field name="search_view_id" ref="view_voucher_filter_new"/>
|
||||
</record>
|
||||
<menuitem action="action_cheque_pay"
|
||||
id="menu_action_cheque_pay"
|
||||
parent="account.menu_finance_bank_and_cash"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_form_inherit">
|
||||
<field name="name">account.journal.form.inherit</field>
|
||||
<field name="model">account.journal</field>
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
"description": """Extension Account Voucher module includes allows to link payment / receipt
|
||||
entries with voucher, also automatically reconcile during the payment and receipt entries
|
||||
""",
|
||||
"category" : "Generic Modules/Indian Accounting",
|
||||
"website" : "http://tinyerpindia.com",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"website" : "http://www.openerp.com",
|
||||
"depends" : [
|
||||
"base",
|
||||
"account",
|
||||
@@ -43,7 +43,6 @@
|
||||
|
||||
],
|
||||
"test" : [
|
||||
# "test/account_voucher.yml",
|
||||
"test/account_voucher_payment.yml",
|
||||
],
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ account_move_line()
|
||||
class account_voucher(osv.osv):
|
||||
_inherit = 'account.voucher'
|
||||
_columns = {
|
||||
'voucher_line_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'payment_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
}
|
||||
|
||||
def action_move_line_create(self, cr, uid, ids, *args):
|
||||
@@ -233,8 +233,7 @@ class account_voucher_line(osv.osv):
|
||||
return data
|
||||
|
||||
_columns = {
|
||||
# 'invoice_id' : fields.many2one('account.invoice','Invoice'),
|
||||
'move_id' : fields.many2one('account.move','Journal Entry'),
|
||||
'move_id' : fields.many2one('account.move','Bill / Invoice'),
|
||||
}
|
||||
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
<field name="inherit_id" ref="account_voucher.view_voucher_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="payment_ids" position="replace">
|
||||
<field name="voucher_line_ids" colspan="4" nolabel="1" height="200">
|
||||
<field name="payment_ids" colspan="4" nolabel="1" height="200">
|
||||
<tree string="Voucher Lines" editable="top">
|
||||
<field name="name" on_change="onchange_partner(parent.partner_id,type,parent.type, parent.currency_id)"/>
|
||||
<field name="account_id"/>
|
||||
<field name="type" on_change="onchange_type(parent.partner_id,type,parent.type, parent.currency_id)"/>
|
||||
<!-- <field name="name"/>-->
|
||||
<field name="ref" on_change="onchange_partner(parent.partner_id,type,parent.type, parent.currency_id)"/>
|
||||
<field name="move_id" context="{'ttype':parent.type, 'partner_id':parent.partner_id, 'voucher':True}" on_change="onchange_invoice_id(move_id, parent.currency_id)" domain="[('state','=','posted'), ('partner_id','=',parent.partner_id)]"/>
|
||||
<field name="amount"/>
|
||||
<field name="ref"/>
|
||||
<field name="type" on_change="onchange_type(parent.partner_id,type,parent.type, parent.currency_id)"/>
|
||||
<field name="account_id"/>
|
||||
<field name="account_analytic_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user