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

This commit is contained in:
Jordi Garcia 2018-01-19 13:20:44 +01:00
parent 34510fe2fa
commit 666fd5a7a5
2 changed files with 40 additions and 0 deletions

38
issue33209.diff Normal file
View File

@ -0,0 +1,38 @@
diff -r 47914f00b7da trytond/trytond/modules/account_invoice/invoice.py
--- a/trytond/trytond/modules/account_invoice/invoice.py Fri Jan 19 12:42:33 2018 +0100
+++ b/invoice.py Fri Jan 19 13:12:01 2018 +0100
@@ -2834,11 +2834,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('refund_non_posted',
+ (invoice.rec_name,))
+ if refund:
if invoice.payment_lines:
self.raise_user_error('refund_with_payement',
(invoice.rec_name,))
diff -r 47914f00b7da trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst
--- a/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst Fri Jan 19 12:42:33 2018 +0100
+++ b/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst Fri Jan 19 13:12:01 2018 +0100
@@ -199,6 +199,14 @@
>>> invoice.total_amount
Decimal('240.00')
>>> invoice.save()
+ >>> 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.', ''))
>>> Invoice.post([invoice.id], config.context)
>>> invoice.reload()
>>> invoice.state

2
series
View File

@ -132,3 +132,5 @@ issue6371.diff # stock Do not set effective date on assignation
# issue6626_improve_performance_of_average_cost_price.diff
filestore.diff
issue33209.diff # [account_invoice] Forbid to create credit notes from nonposted invoices