Error trying to print Advance Payment auto generated invoice

Hello there. I am hoping someone might be able to help with an error that I do not know how to get remedied. I am new to the use and implementation of the Sale_Advance_Payment module. I do suspect that I have it configured at least partially correct as I am able to:

  1. Start an quote in Sales.
  2. add items like usual.
  3. Navigate to “Other Info” tab .
  4. select an “Advance Payment Term” (ie 50% prepay) I created from the list.
  5. It populates the the Advance Payment Conditions correctly and does indeed Block Supply and Block Shipping and auto create an invoice related to Advance Payment (and for the correct amount of 50% of total_amount).
  6. Correct values/amounts are reflected on GL Accounts.

The problem and error I am incurring is the following:
When I try to “print” the auto generated invoice related to the Advance Payment I get this error and no invoice/document is available to view or print (.odt or pdf). Can anyone look at this trace and possibly help me to understand and remedy this problem. I would like to be able to send a copy of the invoices to customers so they have something to remit payment by.

Traceback (most recent call last):
  File "/genshi/template/", line 301, in lookup_attr
    val = getattr(obj, key)
AttributeError: 'NoneType' object has no attribute 'description'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/genshi/template/", line 307, in lookup_attr
    val = obj[key]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/trytond/", line 109, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/", line 43, in rpc
    return methods.get(request.rpc_method, _dispatch)(
  File "/trytond/", line 75, in wrapper
    return func(request, *args, **kwargs)
  File "/trytond/protocols/", line 197, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/", line 196, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/modules/account_invoice/", line 3240, in execute
    return super().execute(ids, data)
  File "/trytond/report/", line 244, in execute
    oext, content = cls._execute(
  File "/trytond/modules/account_invoice/", line 3219, in _execute
    result = super()._execute(records, header, data, action)
  File "/trytond/report/", line 265, in _execute
    return cls.convert(action, cls.render(action, report_context))
  File "/trytond/modules/account_invoice/", line 3235, in render
    return super().render(*args, **kwargs)
  File "/trytond/report/", line 367, in render
    data = template.generate(**report_context).render()
  File "/relatorio/templates/", line 16, in render
    return self.serializer(
  File "/relatorio/templates/", line 1157, in __call__
  File "/genshi/", line 60, in encode
    for chunk in iterator:
  File "/genshi/", line 243, in __call__
    for kind, data, pos in stream:
  File "/genshi/", line 674, in __call__
    for kind, data, pos in stream:
  File "/genshi/", line 779, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/genshi/", line 598, in __call__
    for ev in stream:
  File "/relatorio/templates/", line 1053, in __call__
    for kind, data, pos in stream:
  File "/genshi/filters/", line 789, in __call__
    for kind, data, pos in stream:
  File "/genshi/template/", line 641, in _include
    for event in stream:
  File "/genshi/template/", line 326, in _match
    for event in stream:
  File "/genshi/template/", line 581, in _flatten
    for kind, data, pos in stream:
  File "/genshi/template/", line 369, in __call__
    iterable = _eval_expr(self.expr, ctxt, vars)
  File "/genshi/template/", line 290, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/genshi/template/", line 160, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "<string>", line 1, in <Expression "iter((invoice.payment_term.description or '').split('\\n'))">
  File "/genshi/template/", line 309, in lookup_attr
    val = cls.undefined(key, owner=obj)
  File "/genshi/template/", line 397, in undefined
    raise UndefinedError(key, owner=owner)
genshi.template.eval.UndefinedError: None has no member named "description"

The error/problem seems to only be related to the printing of the auto generated invoice for Advance Payment. If I apply payment to the auto invoice that won’t print and it is considered “Paid” it will then auto generate a Shipment and second Invoice for the remainder as desired. The second invoice also references the deduction of the Advance Payment as desired. It will allow me to print the newly generated invoice for the remainder and without any error like normal.
Is this simply a matter of my Invoice and/or Sale template (.odt) are insufficiently constructed?

Thank you in advance!

It looks like you are using a custom invoice template which does not check that invoice.payment_term is filled before using it.
The standard template has an if test="" /if for the payment term.

Hey there Cedric, thank you. I pulled the default template for Invoice from the Demo7.0 instance, loaded it to my instance and verified that it the original template indeed does work and not give any error. This was also the template I began to with and modified to get my custom tailored form.
I checked the code in the template and all of the placeholders matched verbatim, and the table properties are identical.

Being at a loss for what to do, I began going step by step to customizing again to see where the breaking change occurred. Fortunately, it occurred in the first step…When I modified the header on the form by adding an image of my logo and a table with contact information consisting of <INVOICE.COMPANY.REC_NAME> and generic text. Saved as .odt and the breaking change occurred. Then out of an act of exhaustion I saved it as a .fodt . Worked wonderfully! Then went back to the Invoice Template that the error I referenced began with when using Advance_Payment, saved that unchanged file as a .fodt, loaded it on my instance and works wonderfully now.

So while things seem to be operational by using a .fodt format, instead of .odt, as a workaround I now have a few questions.

  1. Do you foresee the use of the .fodt creating any problems I have not experienced yet?
  2. I wonder why the template I customized (.odt) functions and is stable with Invoices (All states: Draft, Validated, and Posted) so long as the Advance Payment is not involved? It only is breaking when Advance Payment is involved on individual invoice and is indeed the same file source entirely, theonly difference is format saved of .odt vs .fodt .

Thanks in advance!


Because advance payment invoice has no payment term.

I apologize but I don’t quite understand the answer for question 2, maybe I did not word my question very well.

Why does the identical content in my invoice template work successfully when used in .fodt format
fail when used in .odt format?

If there is a question regarding my customized template I am happy to forward a copy to go in a test environment if that would be helpful.
Thank you for your help!

I do not think it is linked to the format as the only error you showed is about payment term being used before testing if the invoice has a payment term.