summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-07-18 07:59:46 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-07-18 07:59:46 +0000
commitb426b2f0232c8ed4e535cd902b9ad41b3ae6e928 (patch)
tree3964b78bc3fcb4eb36fd18cdf9f73b65101d6c6f
parent1ae356146ccfec22f624febbae47df686393c1eb (diff)
[FIX] account: invoice context from payment smart button is correct
Register a payment on a vendor bill. From the menu Account > Purchase > Payment, clik to see that payment click on the smart button to see the invoices Create a new Bill Before this commit, the default type and journal of the new bill were actually the ones of a customer invoice After this commit, those defaults are the ones of a vendor bill OPW 2038786 closes odoo/odoo#34967 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
-rw-r--r--addons/account/models/account_payment.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index 56d6a8a96d9..1d654be0652 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -430,20 +430,25 @@ class account_payment(models.Model):
@api.multi
def button_invoices(self):
- if self.partner_type == 'supplier':
- views = [(self.env.ref('account.invoice_supplier_tree').id, 'tree'), (self.env.ref('account.invoice_supplier_form').id, 'form')]
- else:
- views = [(self.env.ref('account.invoice_tree').id, 'tree'), (self.env.ref('account.invoice_form').id, 'form')]
- return {
+ action = {
'name': _('Paid Invoices'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
- 'views': views,
'type': 'ir.actions.act_window',
'domain': [('id', 'in', [x.id for x in self.invoice_ids])],
}
+ if self.partner_type == 'supplier':
+ action['views'] = [(self.env.ref('account.invoice_supplier_tree').id, 'tree'), (self.env.ref('account.invoice_supplier_form').id, 'form')]
+ action['context'] = {
+ 'journal_type': 'purchase',
+ 'type': 'in_invoice',
+ 'default_type': 'in_invoice',
+ }
+ else:
+ action['views'] = [(self.env.ref('account.invoice_tree').id, 'tree'), (self.env.ref('account.invoice_form').id, 'form')]
+ return action
@api.multi
def button_dummy(self):