diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index f4fe6810f44..a64d0c906a2 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -427,8 +427,8 @@ class AccountInvoice(models.Model): def _compute_access_url(self): super(AccountInvoice, self)._compute_access_url() - for order in self: - order.access_url = '/my/invoices/%s' % (order.id) + for invoice in self: + invoice.access_url = '/my/invoices/%s' % (invoice.id) @api.depends('state', 'journal_id', 'date_invoice') def _get_sequence_prefix(self): @@ -1505,6 +1505,24 @@ class AccountInvoice(models.Model): len(res), ) for r in res] + @api.multi + def get_portal_url(self, suffix=None): + """ + Get a portal url for this invoice, including access_token. + - suffix: string to append to the url, before the query string + """ + self.ensure_one() + return self.access_url + '%s?access_token=%s' % (suffix if suffix else '', self._portal_ensure_token()) + + @api.multi + def preview_invoice(self): + self.ensure_one() + return { + 'type': 'ir.actions.act_url', + 'target': 'self', + 'url': self.get_portal_url(), + } + class AccountInvoiceLine(models.Model): _name = "account.invoice.line" diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 4d22d4d9a93..a59d9410bd8 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -408,6 +408,7 @@ string="Register Payment" groups="account.group_account_invoice" class="oe_highlight"/>