Add issue33209.diff # [account_invoice] Forbid to create credit notes from nonposted invoices

This commit is contained in:
Jordi Garcia 2018-01-18 15:04:16 +01:00
parent d0e0d7d575
commit 83f8986101
3 changed files with 42 additions and 21 deletions

View File

@ -1,21 +0,0 @@
diff --git a/trytond/ir/action.py b/trytond/ir/action.py
--- a/trytond/trytond/ir/action.py
+++ b/trytond/trytond/ir/action.py
@@ -149,13 +149,13 @@
def check_wizard_model(self):
ActionWizard = Pool().get('ir.action.wizard')
if self.action.type == 'ir.action.wizard':
- action_wizard, = ActionWizard.search([
+ action_wizards = ActionWizard.search([
('action', '=', self.action.id),
], limit=1)
- if action_wizard.model:
- if self.model.__name__ != action_wizard.model:
+ if action_wizards and action_wizards[0].model:
+ if self.model.__name__ != action_wizards[0].model:
self.raise_user_error('wrong_wizard_model', (
- action_wizard.rec_name,))
+ action_wizards[0].rec_name,))
@staticmethod
def _convert_vals(vals):

41
issue33209.diff Normal file
View File

@ -0,0 +1,41 @@
diff -r 096004a93da6 trytond/trytond/modules/account_invoice/invoice.py
--- a/trytond/trytond/modules/account_invoice/invoice.py Thu Jan 18 13:57:46 2018 +0100
+++ b/trytond/trytond/modules/account_invoice/invoice.py Thu Jan 18 14:43:12 2018 +0100
@@ -2665,11 +2665,11 @@
refund = self.start.with_refund
invoices = Invoice.browse(Transaction().context['active_ids'])
- if refund:
- for invoice in invoices:
- if invoice.state != 'posted':
- self.raise_user_error('refund_non_posted',
- (invoice.rec_name,))
+ for invoice in invoices:
+ if invoice.state != 'posted':
+ self.raise_user_error('invoice_non_posted',
+ (invoice.rec_name,))
+ if refund:
if invoice.payment_lines:
self.raise_user_error('refund_with_payement',
(invoice.rec_name,))
diff -r 096004a93da6 trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst
--- a/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst Thu Jan 18 13:57:46 2018 +0100
+++ b/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst Thu Jan 18 14:43:12 2018 +0100
@@ -139,6 +139,17 @@
Decimal('240.00')
>>> invoice.save()
+Try to credit the invoice::
+
+ >>> invoice.state
+ u'draft'
+ >>> credit = Wizard('account.invoice.credit', [invoice])
+ >>> credit.form.with_refund = True
+ >>> credit.execute('credit') #doctest: +IGNORE_EXCEPTION_DETAIL
+ Traceback (most recent call last):
+ ...
+ UserError: ('UserError', (u'You can not credit with refund invoice "1 Party" because it is not posted.', ''))
+
Test change tax::
>>> tax_line, = invoice.taxes

1
series
View File

@ -71,3 +71,4 @@ issue6845-issue5613.diff # [commission] Missing agent type domain on sale and in
issue7011.diff # [stock_consignment] stock_consignment should create invoices for moves that go to a production location
issue7012.diff # [stock_consignment] Allow to create internal order points to provision supplier consignment locations
issue33209.diff # [account_invoice] Forbid to create credit notes from nonposted invoices