Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceback in Statement view #743

Merged
merged 17 commits into from
Apr 3, 2018
Merged

Traceback in Statement view #743

merged 17 commits into from
Apr 3, 2018

Conversation

juangallostra
Copy link
Contributor

@juangallostra juangallostra commented Mar 22, 2018

Description of the issue/feature this PR addresses

Linked issue: #733

Current behavior before PR

When navigating to the Statement's list and trying to access a Statement an error is raised. Furthermore, the traceback appears on the page the user is viewing.

The traceback of the error is:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module bika.lims.browser.bika_listing, line 578, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 98, in __call__
  Module z3c.pt.pagetemplate, line 158, in render
  Module chameleon.zpt.template, line 297, in render
  Module chameleon.template, line 191, in render
  Module chameleon.template, line 171, in render
  Module 7bc87a6cf00fb809870833bf3d328b00.py, line 443, in render
  Module ec3432c014db494cdf6ac1d157ed2259.py, line 1449, in render_master
  Module ec3432c014db494cdf6ac1d157ed2259.py, line 604, in render_content
  Module 7bc87a6cf00fb809870833bf3d328b00.py, line 364, in __fill_content_core
  Module five.pt.expressions, line 161, in __call__
  Module bika.lims.browser.bika_listing, line 1569, in contents_table
  Module bika.lims.browser.bika_listing, line 1747, in __init__
  Module bika.lims.browser.invoicebatch, line 98, in folderitems
AttributeError: getClient

Desired behavior after PR is merged

No traceback appears and the invoices are listed.

Screenshot (optional)

seleccio_008

seleccio_009

seleccio_010

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very small changes. Thanks!

number_link = "<a href='%s'>%s</a>" % (
item['url'], obj.getId()
)
item['replace']['id'] = number_link
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to remove number_link and use get_link from utils directly:

item['replace']['id'] = get_link(api.get_url(obj), obj.getId())

item['client'] = obj.getClient().Title()
item['replace']['client'] = "<a href='%s'>%s</a>" % (
obj.getClient().absolute_url(), item['client']
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, better use get_link

item['url'], obj.getId()
)
item['replace']['id'] = number_link
if obj.getClient():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using the client object in several places later, I suggest to use a local var to store the client:

client = obj.getClient()
if client:
    [...]

and use it later instead of obj.getClient()

)
item['email'] = obj.getClient().getEmailAddress()
item['replace']['email'] = "<a href='%s'>%s</a>" % (
'mailto:%s' % obj.getClient().getEmailAddress(), obj.getClient().getEmailAddress()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use get_email_link from utils:

item['replace']['email'] = get_email_link(client.getEmailAddress())

@xispa xispa merged commit 1f8756b into senaite:master Apr 3, 2018
@juangallostra juangallostra deleted the traceback-in-statement-view branch April 4, 2018 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants