[FIX]: fix a problem of the pay button visiblity
[FIX]: Improve so that it's possible to do a negative sales payment. bzr revid: mga@tinyerp.com-20100901120808-qftjn2zf2695sco3
This commit is contained in:
@@ -422,7 +422,7 @@ class account_voucher(osv.osv):
|
||||
terms = term_pool.compute(cr, uid, term_id, amount)
|
||||
return terms
|
||||
return False
|
||||
|
||||
|
||||
move_pool = self.pool.get('account.move')
|
||||
move_line_pool = self.pool.get('account.move.line')
|
||||
analytic_pool = self.pool.get('account.analytic.line')
|
||||
@@ -460,7 +460,12 @@ class account_voucher(osv.osv):
|
||||
credit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount)
|
||||
elif inv.type in ('sale', 'receipt'):
|
||||
debit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount)
|
||||
|
||||
if debit < 0:
|
||||
credit = -debit
|
||||
debit = 0.0
|
||||
if credit < 0:
|
||||
debit = -credit
|
||||
credit = 0.0
|
||||
if inv.type == 'purchase' and inv.term_id and _get_payment_term_lines(inv.term_id.id, credit or debit):
|
||||
terms = _get_payment_term_lines(inv.term_id.id, credit or debit)
|
||||
for term in terms:
|
||||
@@ -510,6 +515,13 @@ class account_voucher(osv.osv):
|
||||
'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False,
|
||||
'quantity':1
|
||||
}
|
||||
if amount < 0:
|
||||
amount = -amount
|
||||
if line.type == 'dr':
|
||||
line.type = 'cr'
|
||||
else:
|
||||
line.type = 'dr'
|
||||
|
||||
if (line.type=='dr'):
|
||||
line_total += amount
|
||||
move_line['debit'] = amount
|
||||
@@ -522,7 +534,7 @@ class account_voucher(osv.osv):
|
||||
rec_ids = [master_line, line.move_line_id.id]
|
||||
rec_list_ids.append(rec_ids)
|
||||
|
||||
if inv.tax_amount > 0:
|
||||
if inv.tax_amount:
|
||||
amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
|
||||
name = inv.tax_id and inv.tax_id.name or '/'
|
||||
move_line = {
|
||||
@@ -533,11 +545,12 @@ class account_voucher(osv.osv):
|
||||
'partner_id':inv.partner_id.id,
|
||||
'currency_id':inv.currency_id.id,
|
||||
}
|
||||
|
||||
if inv.journal_id.type in ('sale','purchase_refund'):
|
||||
if inv.journal_id.type in ('sale','purchase_refund') and amount > 0:
|
||||
line_total -= amount
|
||||
move_line['credit'] = amount
|
||||
else:
|
||||
if amount < 0:
|
||||
amount = -amount
|
||||
line_total += amount
|
||||
move_line['debit'] = amount
|
||||
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- <act_window-->
|
||||
<!-- id="act_pay_voucher"-->
|
||||
<!-- name="Sales Payment"-->
|
||||
<!-- context="{'default_journal_type':'bank', 'default_type':'receipt', 'default_partner_id': partner_id}"-->
|
||||
<!-- res_model="account.voucher.open"-->
|
||||
<!-- src_model="account.voucher"-->
|
||||
<!-- target="new"/>-->
|
||||
|
||||
<record id="act_pay_voucher" model="ir.actions.act_window">
|
||||
<field name="name">Sales Payment</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
@@ -25,7 +19,7 @@
|
||||
<form string="Sales Receipt">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id)" string="Customer"/>
|
||||
<field name="journal_id" domain="[('type','=','sale')]" widget="selection" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="journal_id" domain="[('type','in',['sale','purchase_refund'])]" widget="selection" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="number"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date" on_change="onchange_date(date)"/>
|
||||
@@ -78,7 +72,7 @@
|
||||
<field name="state"/>
|
||||
<button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/>
|
||||
<button name="proforma_voucher" string="Post" states="draft" icon="terp-camera_test"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_voucher)d" context="{'title':'Sales Payment', 'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}" type="action" string="Pay" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_voucher)d" context="{'title':'Sales Payment', 'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}" type="action" string="Pay" states="posted" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
|
||||
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
|
||||
<button name="%(action_view_account_voucher_unreconcile)d" string="Cancel" type="action" states="posted" icon="terp-stock_effects-object-colorize"/>
|
||||
</group>
|
||||
@@ -91,7 +85,7 @@
|
||||
<field name="name">Sales Receipt</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type','=','sale'), ('type','=','sale')]</field>
|
||||
<field name="domain">[('journal_id.type','in',['sale','purchase_refund']), ('type','=','sale')]</field>
|
||||
<field name="context">{'journal_type':'sale', 'type':'sale'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
@@ -108,7 +102,7 @@
|
||||
<form string="Vendor Bills">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" string="Vendor" on_change="onchange_partner_id(partner_id, journal_id, amount)"/>
|
||||
<field name="journal_id" domain="[('type','=','purchase')]" widget="selection" select="1" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="journal_id" domain="[('type','in',['purchase','sale_refund'])]" widget="selection" select="1" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="number"/>
|
||||
@@ -168,7 +162,7 @@
|
||||
<field name="name">Vendor Bills</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type','=','purchase'), ('type','=','purchase')]</field>
|
||||
<field name="domain">[('journal_id.type','in',['purchase','sale_refund']), ('type','=','purchase')]</field>
|
||||
<field name="context">{'journal_type':'purchase', 'type':'purchase'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
|
||||
Reference in New Issue
Block a user