summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-02-21 10:02:45 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-02-21 10:06:42 +0000
commit9fc2420ec6c39f9ce47804a57cc6ff99bbefd6cc (patch)
tree70b6de821c7b6eadd9c380f7c4d41274f8e0d089
parent84143a34b313c01b0b37b7d7246ce3d5c9476002 (diff)
[FIX] l10n_it_edi: cleaned context default_type
On the accounting dashboard, click on the button "new invoice" on the customer journal. Validate the invoice Before this commit, it crashed because, as always the key "default_type" was propagated all the way down to the attachment creation After this commit, we clean the context from that key to avoid the problem Note: There is no clean and safe method to clean the context from keys only useful to `default_get` in stable... OPW 1943439 closes odoo/odoo#31319
-rw-r--r--addons/l10n_it_edi/models/account_invoice.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py
index 123081e5503..1ba9b6ec213 100644
--- a/addons/l10n_it_edi/models/account_invoice.py
+++ b/addons/l10n_it_edi/models/account_invoice.py
@@ -49,6 +49,12 @@ class AccountInvoice(models.Model):
@api.multi
def invoice_validate(self):
+ # Clean context from default_type to avoid making attachment
+ # with wrong values in subsequent operations
+ cleaned_ctx = dict(self.env.context)
+ cleaned_ctx.pop('default_type', None)
+ self = self.with_context(cleaned_ctx)
+
super(AccountInvoice, self).invoice_validate()
for invoice in self:
if invoice.company_id.country_id != self.env.ref('base.it'):