[IMP] sale_portal: add payment option on invoices, fix state check to display it on sale.order
bzr revid: odo@openerp.com-20121026164803-625usw34bnyzmxqu
This commit is contained in:
parent
0f3ed1e09a
commit
52ee9769f6
|
@ -34,7 +34,26 @@ class sale_order(osv.Model):
|
|||
result = dict.fromkeys(ids, False)
|
||||
payment_acquirer = self.pool.get('portal.payment.acquirer')
|
||||
for this in self.browse(cr, uid, ids, context=context):
|
||||
if this.state != 'draft' and not this.invoiced:
|
||||
if this.state not in ('draft','cancel') and not this.invoiced:
|
||||
result[this.id] = payment_acquirer.render_payment_block(cr, uid, this, this.name,
|
||||
this.pricelist_id.currency_id, this.amount_total, context=context)
|
||||
return result
|
||||
|
||||
|
||||
class account_invoice(osv.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
_payment_block_proxy = lambda self,*a,**kw: self._portal_payment_block(*a, **kw)
|
||||
|
||||
_columns = {
|
||||
'portal_payment_options': fields.function(_payment_block_proxy, type="html", string="Portal Payment Options"),
|
||||
}
|
||||
|
||||
def _portal_payment_block(self, cr, uid, ids, fieldname, arg, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
payment_acquirer = self.pool.get('portal.payment.acquirer')
|
||||
for this in self.browse(cr, uid, ids, context=context):
|
||||
if this.state not in ('draft','done') and not this.reconciled:
|
||||
result[this.id] = payment_acquirer.render_payment_block(cr, uid, this, this.number,
|
||||
this.currency_id, this.residual, context=context)
|
||||
return result
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<!-- Add payment options to sale.order and invoice forms -->
|
||||
<record model="ir.ui.view" id="sale_order_form_payment">
|
||||
<field name="name">sale.order.form.payment</field>
|
||||
<field name="model">sale.order</field>
|
||||
|
@ -12,6 +13,16 @@
|
|||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="invoice_form_payment">
|
||||
<field name="name">account.invoice.form.payment</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook version="7.0" position="before">
|
||||
<field name="portal_payment_options" groups="portal_sale.group_payment_options"/>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!--
|
||||
|
@ -60,7 +71,7 @@
|
|||
<field name="help">There are no public products.</field>
|
||||
</record>
|
||||
|
||||
<record id="action_invoice_tree1" model="ir.actions.act_window">
|
||||
<record id="portal_action_invoices" model="ir.actions.act_window">
|
||||
<field name="name">Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="view_mode">tree,form,calendar,graph</field>
|
||||
|
@ -69,8 +80,20 @@
|
|||
<field name="search_view_id" ref="account.view_account_invoice_filter"/>
|
||||
<field name="help">You don't have any invoice.</field>
|
||||
</record>
|
||||
<record id="portal_action_invoices_tree_spec" model="ir.actions.act_window.view">
|
||||
<field name="act_window_id" ref="portal_action_invoices"/>
|
||||
<field name="view_id" ref="account.invoice_tree"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="sequence" eval="0"/>
|
||||
</record>
|
||||
<record id="portal_action_invoices_form_spec" model="ir.actions.act_window.view">
|
||||
<field name="act_window_id" ref="portal_action_invoices"/>
|
||||
<field name="view_id" ref="account.invoice_form"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="sequence" eval="1"/>
|
||||
</record>
|
||||
|
||||
<record id="action_vendor_receipt" model="ir.actions.act_window">
|
||||
<record id="portal_action_vouchers" model="ir.actions.act_window">
|
||||
<field name="name">Refunds/Payments</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
|
||||
|
@ -89,8 +112,8 @@
|
|||
<menuitem id="portal_products" parent="portal.portal_orders"
|
||||
action="product_normal_action" sequence="40"/>
|
||||
<menuitem id="portal_invoices" parent="portal.portal_invoices_payements"
|
||||
action="action_invoice_tree1" sequence="10"/>
|
||||
action="portal_action_invoices" sequence="10"/>
|
||||
<menuitem id="portal_payments" parent="portal.portal_invoices_payements"
|
||||
action="action_vendor_receipt" sequence="20"/>
|
||||
action="portal_action_vouchers" sequence="20"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue