[FIX]: fix for the journal voucher
bzr revid: mga@tinyerp.com-20100914131329-41dylw1tfaiymeap
This commit is contained in:
parent
ed6d18a6b1
commit
bd1b567453
|
@ -196,7 +196,6 @@ class account_voucher(osv.osv):
|
||||||
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
|
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# TODO: review this code.
|
|
||||||
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}):
|
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}):
|
||||||
tax_pool = self.pool.get('account.tax')
|
tax_pool = self.pool.get('account.tax')
|
||||||
partner_pool = self.pool.get('res.partner')
|
partner_pool = self.pool.get('res.partner')
|
||||||
|
@ -255,6 +254,44 @@ class account_voucher(osv.osv):
|
||||||
})
|
})
|
||||||
return {'value':default}
|
return {'value':default}
|
||||||
|
|
||||||
|
def onchange_journal_voucher(self, cr, uid, ids, partner_id=False, journal_id=False, context={}):
|
||||||
|
"""price
|
||||||
|
Returns a dict that contains new values and context
|
||||||
|
|
||||||
|
@param partner_id: latest value from user input for field partner_id
|
||||||
|
@param args: other arguments
|
||||||
|
@param context: context arguments, like lang, time zone
|
||||||
|
|
||||||
|
@return: Returns a dict which contains new values, and context
|
||||||
|
"""
|
||||||
|
default = {
|
||||||
|
'value':{},
|
||||||
|
}
|
||||||
|
|
||||||
|
if not journal_id or not journal_id:
|
||||||
|
return default
|
||||||
|
|
||||||
|
partner_pool = self.pool.get('res.partner')
|
||||||
|
journal_pool = self.pool.get('account.journal')
|
||||||
|
|
||||||
|
journal = journal_pool.browse(cr, uid, journal_id)
|
||||||
|
partner = partner_pool.browse(cr, uid, partner_id)
|
||||||
|
account_id = False
|
||||||
|
tr_type = False
|
||||||
|
if journal.type in ('sale','sale_refund'):
|
||||||
|
account_id = partner.property_account_receivable.id
|
||||||
|
tr_type = 'sale'
|
||||||
|
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
||||||
|
account_id = partner.property_account_payable.id
|
||||||
|
tr_type = 'purchase'
|
||||||
|
else:
|
||||||
|
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
||||||
|
tr_type = 'receipt'
|
||||||
|
|
||||||
|
default['value']['account_id'] = account_id
|
||||||
|
default['value']['type'] = tr_type
|
||||||
|
return default
|
||||||
|
|
||||||
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}):
|
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}):
|
||||||
"""price
|
"""price
|
||||||
Returns a dict that contains new values and context
|
Returns a dict that contains new values and context
|
||||||
|
@ -440,7 +477,7 @@ class account_voucher(osv.osv):
|
||||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
|
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
|
||||||
return super(account_voucher, self).unlink(cr, uid, ids, context=context)
|
return super(account_voucher, self).unlink(cr, uid, ids, context=context)
|
||||||
|
|
||||||
# TODO
|
# TODO: may be we can remove this method if not used anyware
|
||||||
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
|
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
|
||||||
res = {}
|
res = {}
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
|
@ -755,6 +792,7 @@ class account_voucher_line(osv.osv):
|
||||||
ttype = 'cr'
|
ttype = 'cr'
|
||||||
if journal.type in ('sale', 'purchase_refund'):
|
if journal.type in ('sale', 'purchase_refund'):
|
||||||
account_id = journal.default_credit_account_id and journal.default_credit_account_id.id or False
|
account_id = journal.default_credit_account_id and journal.default_credit_account_id.id or False
|
||||||
|
ttype = 'cr'
|
||||||
elif journal.type in ('purchase', 'expense', 'sale_refund'):
|
elif journal.type in ('purchase', 'expense', 'sale_refund'):
|
||||||
account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False
|
account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False
|
||||||
ttype = 'dr'
|
ttype = 'dr'
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_voucher_form">
|
<record model="ir.ui.view" id="view_voucher_form">
|
||||||
<field name="name">account.voucher.form</field>
|
<field name="name">account.voucher.form</field>
|
||||||
<field name="model">account.voucher</field>
|
<field name="model">account.voucher</field>
|
||||||
|
@ -28,11 +28,11 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Accounting Voucher">
|
<form string="Accounting Voucher">
|
||||||
<group col="6" colspan="4">
|
<group col="6" colspan="4">
|
||||||
|
<field name="partner_id" required="1" on_change="onchange_journal_voucher(partner_id, journal_id)"/>
|
||||||
|
<field name="journal_id" widget="selection" select="1" on_change="onchange_journal_voucher(partner_id, journal_id)"/>
|
||||||
|
<field name="type" required="1"/>
|
||||||
<field name="name" colspan="4"/>
|
<field name="name" colspan="4"/>
|
||||||
<field name="reference" select="1"/>
|
<field name="reference" select="1"/>
|
||||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
|
||||||
<field name="type" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
|
||||||
<field name="journal_id" widget="selection" select="1" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
|
||||||
<field name="account_id" widget="selection" invisible="True"/>
|
<field name="account_id" widget="selection" invisible="True"/>
|
||||||
</group>
|
</group>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
|
|
Loading…
Reference in New Issue