[MERGE] Merge psi branch => change currency, pay and refund invoices wizard replaced by buttons on form views

bzr revid: mra@tinyerp.com-20100517130607-07exonl3ai1d8is7
This commit is contained in:
mra (Open ERP) 2010-05-17 18:36:07 +05:30
commit 11c75c9586
6 changed files with 87 additions and 72 deletions

View File

@ -141,22 +141,23 @@
<field name="priority">2</field>
<field name="arch" type="xml">
<form string="Supplier invoice">
<group col="6" colspan="4">
<field domain="[('type', '=', 'purchase')]" name="journal_id"/>
<field name="number" readonly="1"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)"/>
<newline/>
<field name="partner_id" domain="[('supplier','=', 1)]" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank,company_id)" context="{'default_customer': 0}"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="base.group_user"/>
<group colspan="2" col="1" groups="base.group_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<group col="8" colspan="4">
<field domain="[('type', '=', 'purchase')]" name="journal_id"/>
<field name="number" readonly="1"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="gtk-apply" string="Change Currency"/>
<newline/>
<field name="partner_id" domain="[('supplier','=', 1)]" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank,company_id)" context="{'default_customer': 0}"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="base.group_user"/>
<group colspan="2" col="1" groups="base.group_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id" groups="base.group_user"/>
@ -200,10 +201,12 @@
<field name="state"/>
<field name="residual"/>
<group col="3" colspan="4">
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-apply"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name="%(action_account_state_open)d" type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-apply"/>
<button name="%(action_account_invoice_pay)d" type='action' string='Pay Invoice' states='open' icon="gtk-ok"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name="%(action_account_state_open)d" type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<button name="%(action_account_invoice_refund)d" type='action' string='Credit Note' states='paid' icon="gtk-execute"/>
</group>
</group>
</page>
@ -247,23 +250,23 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice">
<group colspan="4" col="6">
<field name="journal_id" groups="base.group_user"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank,company_id)" groups="base.group_user"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="base.group_user"/>
<group colspan="2" col="1" groups="base.group_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<group colspan="4" col="8">
<field name="journal_id" groups="base.group_user"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" domain="[('company_id','=', company_id)]" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="gtk-apply" string="Change Currency"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank,company_id)" groups="base.group_user"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="base.group_user"/>
<group colspan="2" col="1" groups="base.group_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id" groups="base.group_user"/>
@ -290,12 +293,14 @@
<field name="amount_total"/>
<field name="state"/>
<field name="residual"/>
<group col="3" colspan="4" groups="base.group_user">
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="gtk-print"/>
<button name="invoice_open" states="draft,proforma2" string="Create" icon="gtk-execute"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(action_account_state_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<group col="4" colspan="4" groups="base.group_user">
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="gtk-print"/>
<button name="invoice_open" states="draft,proforma2" string="Create" icon="gtk-execute"/>
<button name="%(action_account_invoice_pay)d" type='action' string='Pay Invoice' states='open' icon="gtk-ok"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(action_account_state_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<button name="%(action_account_invoice_refund)d" type='action' string='Credit Note' states='paid' icon="gtk-execute"/>
</group>
</group>
</page>
@ -478,7 +483,7 @@
<act_window domain="[('journal_id','=',active_id),('state','!=','draft'),('reconciled','=',False)]" id="act_account_journal_2_account_invoice_opened" name="Unpaid invoices" res_model="account.invoice" src_model="account.journal"/>
<act_window domain="[('account_analytic_id', '=', active_id)]" id="act_account_analytic_account_2_account_invoice_line" name="Invoice lines" res_model="account.invoice.line" src_model="account.analytic.account"/>
<!-- Partners inherited form -->
<record id="view_invoice_partner_info_form" model="ir.ui.view">
@ -495,6 +500,6 @@
</field>
</record>
</data>
</openerp>

View File

@ -48,27 +48,24 @@ class account_change_currency(osv.osv_memory):
data = self.read(cr, uid, ids)[0]
new_currency = data['currency_id']
for invoice in obj_inv.browse(cr, uid, context['active_ids'], context=context):
if invoice.currency_id.id == new_currency:
continue
invoice = obj_inv.browse(cr, uid, context['active_id'], context=context)
if invoice.currency_id.id == new_currency:
return {}
rate = obj_currency.browse(cr, uid, new_currency).rate
for line in invoice.invoice_line:
new_price = 0
if invoice.company_id.currency_id.id == invoice.currency_id.id:
new_price = line.price_unit * rate
for line in invoice.invoice_line:
rate = obj_currency.browse(cr, uid, new_currency).rate
new_price = 0
if invoice.company_id.currency_id.id == invoice.currency_id.id:
new_price = line.price_unit * rate
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
old_rate = invoice.currency_id.rate
new_price = line.price_unit / old_rate
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
old_rate = invoice.currency_id.rate
new_price = line.price_unit / old_rate
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
old_rate = invoice.currency_id.rate
new_price = (line.price_unit / old_rate ) * rate
obj_inv_line.write(cr, uid, [line.id], {'price_unit' : new_price})
invoice_ids.append(invoice.id)
obj_inv.write(cr, uid, invoice_ids, {'currency_id' : new_currency}, context=context)
if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
old_rate = invoice.currency_id.rate
new_price = (line.price_unit / old_rate ) * rate
obj_inv_line.write(cr, uid, [line.id], {'price_unit' : new_price})
obj_inv.write(cr, uid, [invoice.id], {'currency_id' : new_currency}, context=context)
return {}
account_change_currency()

View File

@ -8,6 +8,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice Currency">
<separator colspan="4" string="This wizard will change the currency of the invoice"/>
<field name="currency_id"/>
<separator colspan="4"/>
<group colspan="2" col="4">
@ -29,7 +30,7 @@
<field name="target">new</field>
</record>
<record model="ir.values" id="account_change_currency">
<!-- <record model="ir.values" id="account_change_currency">
<field name="model_id" ref="account.model_account_invoice" />
<field name="object" eval="1" />
<field name="name">Change Currency</field>
@ -37,7 +38,7 @@
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_change_currency'))"/>
<field name="key">action</field>
<field name="model">account.invoice</field>
</record>
</record>-->
</data>
</openerp>

View File

@ -46,6 +46,7 @@ class account_invoice_refund(osv.osv_memory):
account_m_line_obj = self.pool.get('account.move.line')
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
wf_service = netsvc.LocalService('workflow')
if context is None:
context = {}
@ -111,7 +112,6 @@ class account_invoice_refund(osv.osv_memory):
to_reconcile_ids[line.account_id.id] = [line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', \
refund.id, 'invoice_open', cr)
refund = inv_obj.browse(cr, uid, refund_id[0],context=context)

View File

@ -8,6 +8,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Credit Note">
<separator string="This wizard is used to refund the invoice" colspan="4"/>
<group colspan="4" >
<label string="Are you sure you want to refund this invoice ?" colspan="2"/>
<newline/>
@ -15,7 +16,7 @@
<field name="period"/>
<field name="description"/>
</group>
<separator string="" colspan="4" />
<separator colspan="4"/>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
@ -36,10 +37,10 @@
<field name="target">new</field>
</record>
<act_window id="action_account_invoice_refund"
<!-- <act_window id="action_account_invoice_refund"
key2 = "client_action_multi" name="Credit Note"
res_model="account.invoice.refund" src_model="account.invoice"
view_mode="form" target="new" view_type="form" />
view_mode="form" target="new" view_type="form" /> -->
</data>
</openerp>

View File

@ -25,14 +25,25 @@
</field>
</record>
<record id="action_account_invoice_pay" model="ir.actions.act_window">
<field name="name">Pay Invoice</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.invoice.pay</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_invoice_pay"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<act_window name="Pay Invoice"
<!-- <act_window name="Pay Invoice"
res_model="account.invoice.pay"
src_model="account.invoice"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_account_invoice_pay"/>
id="action_view_account_invoice_pay"/> -->
<record id="view_account_invoice_pay_writeoff" model="ir.ui.view">
<field name="name">account.invoice.pay.writeoff.form</field>