Tryton - Issues

 

Issue8348

Title can't delete empty invoice if account_tax_cash is installed.
Priority bug Status resolved
Superseder Nosy List ced, reviewbot, risto3, roundup-bot
Type crash Components account_tax_cash
Assigned To ced Keywords review
Reviews 263531002
View: 263531002

Created on 2019-05-13.16:20:52 by risto3, last changed by roundup-bot.

Messages
New changeset 3860ddbea61c by Cédric Krier in branch '5.2':
Always filter out invoice without move in _update_tax_cash_basis
https://hg.tryton.org/modules/account_tax_cash/rev/3860ddbea61c

New changeset 7b53cba709e2 by Cédric Krier in branch '5.0':
Always filter out invoice without move in _update_tax_cash_basis
https://hg.tryton.org/modules/account_tax_cash/rev/7b53cba709e2

New changeset 236431bdb04a by Cédric Krier in branch '4.8':
Always filter out invoice without move in _update_tax_cash_basis
https://hg.tryton.org/modules/account_tax_cash/rev/236431bdb04a
New changeset eb5353e3c432 by Cédric Krier in branch 'default':
Always filter out invoice without move in _update_tax_cash_basis
https://hg.tryton.org/tryton-env/rev/eb5353e3c432
New changeset 8a7b4e244a0d by Cédric Krier in branch 'default':
Always filter out invoice without move in _update_tax_cash_basis
https://hg.tryton.org/modules/account_tax_cash/rev/8a7b4e244a0d
msg49854 (view) Author: [hidden] (risto3) Date: 2019-05-25.07:42:39
in account_invoice line 1095:
    def delete(cls, invoices):
        cls.check_modify(invoices)
        # Cancel before delete
        cls.cancel(invoices)
        for invoice in invoices:
            if invoice.state != 'cancel':
                cls.raise_user_error('delete_cancel', (invoice.rec_name,))
==>         if invoice.number:   # and invoice.type == 'out'
                cls.raise_user_error('delete_numbered', (invoice.rec_name,))
        super(Invoice, cls).delete(invoices)

the constraint is probably only required/useful for client invoices...
even there, the message could indicate that the invoice can only be cancelled, not deleted.
msg49853 (view) Author: [hidden] (risto3) Date: 2019-05-24.23:20:00
This patchset seems to only partially work.

If the invoice is never validated, it's okay... but if I first validate,
then set it back to draft, I get the message that it can't be deleted.
(BTW - translation error in French for the message displayed:
'La facture "xxxxx" ne peut pas être surpprimée')
review263531002 updated at https://codereview.tryton.org/263531002/#ps281551002
msg49826 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-05-22.23:41:53
Here is review263531002 which should fix it.
msg49712 (view) Author: [hidden] (risto3) Date: 2019-05-13.16:20:51
Easy to reproduce.... install account_tax_cash
then create an invoice without any lines then try to delete:

Traceback (most recent call last):
  File "/usr/local/lib/python35/dist-packages/trytond/wsgipy", line 73, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/usr/local/lib/python35/dist-packages/trytond/protocols/dispatcherpy", line 46, in rpc
    request, database_name, *requestrpc_params)
  File "/usr/local/lib/python35/dist-packages/trytond/wsgipy", line 44, in auth_required
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python35/dist-packages/trytond/protocols/wrapperspy", line 122, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/usr/local/lib/python35/dist-packages/trytond/protocols/dispatcherpy", line 176, in _dispatch
    result = rpcresult(meth(*c_args, **c_kwargs))
  File "/usr/local/lib/python35/dist-packages/trytond/modules/sale/invoicepy", line 20, in wrapper
    func(cls, invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/sale/invoicepy", line 82, in delete
    super(Invoice, cls)delete(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/purchase/invoicepy", line 21, in wrapper
    func(cls, invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/purchase/invoicepy", line 74, in delete
    super(Invoice, cls)delete(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/account_invoice/invoicepy", line 1091, in delete
    clscancel(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/sale/invoicepy", line 20, in wrapper
    func(cls, invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/sale/invoicepy", line 97, in cancel
    super(Invoice, cls)cancel(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/purchase/invoicepy", line 21, in wrapper
    func(cls, invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/purchase/invoicepy", line 108, in cancel
    super(Invoice, cls)cancel(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/model/modelviewpy", line 665, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/usr/local/lib/python35/dist-packages/trytond/model/workflowpy", line 36, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/account_tax_cash/accountpy", line 289, in cancel
    cls_update_tax_cash_basis(invoices)
  File "/usr/local/lib/python35/dist-packages/trytond/modules/account_tax_cash/accountpy", line 309, in _update_tax_cash_basis
    for line in invoicemovelines:
AttributeError: 'NoneType' object has no attribute 'lines'



in account.py line 309
        for invoice in invoices:
            if invoice.company not in periods:
                periods[invoice.company] = Period.find(
                    invoice.company.id, date=date)
            period = periods[invoice.company]
            ratio = invoice.cash_paid_ratio
==>         for line in invoice.move.lines:    # move can be None here!
                to_update[(period, ratio)].extend(line.tax_lines)
History
Date User Action Args
2019-06-12 21:51:22roundup-botsetmessages: + msg50213
2019-06-03 15:28:05roundup-botsetmessages: + msg49939
2019-06-03 15:28:00roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg49938
2019-05-25 07:42:40risto3setmessages: + msg49854
2019-05-24 23:20:00risto3setmessages: + msg49853
2019-05-22 23:59:46reviewbotsetnosy: + reviewbot
messages: + msg49828
2019-05-22 23:41:53cedsetstatus: unread -> testing
keyword: + review
nosy: + ced
messages: + msg49826
reviews: 263531002
assignedto: ced
type: crash
2019-05-13 16:20:52risto3create

Showing 10 items. Show all history (warning: this could be VERY long)