From 52ee9769f69144ab8050ed70572ddcaffe0dd6c5 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 26 Oct 2012 18:48:03 +0200 Subject: [PATCH] [IMP] sale_portal: add payment option on invoices, fix state check to display it on sale.order bzr revid: odo@openerp.com-20121026164803-625usw34bnyzmxqu --- addons/portal_sale/portal_sale.py | 21 +++++++++++++++- addons/portal_sale/portal_sale_view.xml | 33 +++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/addons/portal_sale/portal_sale.py b/addons/portal_sale/portal_sale.py index d45653bd817..09d71fc1d2b 100644 --- a/addons/portal_sale/portal_sale.py +++ b/addons/portal_sale/portal_sale.py @@ -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 \ No newline at end of file diff --git a/addons/portal_sale/portal_sale_view.xml b/addons/portal_sale/portal_sale_view.xml index e1c5a233eb9..f01b35eff12 100644 --- a/addons/portal_sale/portal_sale_view.xml +++ b/addons/portal_sale/portal_sale_view.xml @@ -1,7 +1,8 @@ - + + sale.order.form.payment sale.order @@ -12,6 +13,16 @@ + + account.invoice.form.payment + account.invoice + + + + + + +