Error tracking in odoo - odoo-9

I am trying create a template for my own invoices - according to http://odoo.guide/report-design-workshop/
I already failed with the simplest sceleton.
When trying to print the invoice I get
"Record does not exist or has been deleted."
I am just wondering how I can get more information on what is wrong here. Some kind of debug or error log. I can see anything in /var/log/odoo/odoo-server.log.
What would be the default way in odoo to track down such error?
Edit
These are my views:
Report
<?xml version="1.0"?>
<t t-name="account.netknights_report">
<t call="report.netknights_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<h3>Rechnung</h3>
</div>
</div>
</t>
</t>
</t>
Layout
<?xml version="1.0"?>
<t t-name="report.netknights_layout">
<t t-call="report.netknights_layout_header">
</t>
<t t-raw="0" />
<t t-call="report.netknights_layout_footer">
</t>
</t>
Header
<?xml version="1.0"?>
<t t-name="report.netknights_layout_header">
<div class="header">
<div class="row">
<div class="col-xs-4 col-xs-offset-8">
<img src="/document/images/NetKnights-800px.png" />
</div>
</div>
</div>
</t>
Footer
<?xml version="1.0"?>
<t t-name="report.netknights_layout_footer">
<!-- Header Architecture -->
<b>Bankverbindung</b>
</t>
Then I created these external identifiers:
account.netknights_report account.netknights_report ir.ui.view 831
report.netknights_layout report.netknights_layout ir.ui.view 319
report.netknights_layout_footer report.netknights_layout_footer ir.ui.view 320
report.netknights_layout_header report.netknights_layout_header ir.ui.view 321

There may already be some logging wherever your odoo server is configured to output logging. Check your config or startup script to determine where logging is being written to.
A way you can get some logging while running your report is to define an abstract model for your report. Here is an example.
class ReportClass(models.AbstractModel):
_name = 'report.myaddon.report_view_id'
#api.multi
def render_html(self, data=None):
_logger = logging.getLogger(__name__)
_logger.info("Creating My Report")
report_obj = self.env['report']
report = report_obj._get_report_from_name('myaddon.report_view_id')
docs = self.env['myaddon.model'].browse(self._ids)
docargs = {
'doc_model': report.model,
'docs': docs,
}
return report_obj.render('myaddon.report_view_id', docargs)
Notice the logging. These logs should appear wherever your odoo instance is configured to log to. If you are running in a development environment it might be standard output. If you have a config file or have started your server with a config file specified it should show up there. If you use _logger.info ensure you are logging info level (not warning or error) output.
From the sounds of things your report is trying to access data on a record that the system thinks is missing (sorry for stating the obvious, I am sure you already know that). Anyways this should atleast give you a start at looking at some logging.
I just noticed that you alias your records as "o" however you have a t-raw="0" which says output the raw value of the value of the variable "0", not "o". This might be a typo. Because if you really just wanted a 0 I assume you would have used
<p>0</p>
or something like that.
Check out this Odoo Qweb Reports. There is some decent info for reports.

Related

Translation in parameter of translation with Thymeleaf

Using Thymeleaf 3.0.9, suppose I have this translation:
hello=Hello {0}
In my template, I have:
<span th:text="#{hello(${user.getName()})}"></span>
Now suppose user.getName() can be null, so I want to display something nice in that case:
<span th:text="#{hello(${user.getName()?:'Unknown'})}"></span>
This works fine.
Now I also want to tranlate Unknown, how can I do this?
I tried:
<span th:text="#{hello(${user.getName()?:#{unknown})}"></span>
But that does not seem to work.
I think you can use the #messages utility object:
<span th:text="#{hello(${user.getName()?:#messages.msg('unknown')})}"></span>
And add property in the messages file(s):
unknown=Unknown

How to grab an href using xpath after certain words appear in the class above

I want to grab: a) the Facebook page URL b) the Facebook page name from here:
<div class="desc">Example text</div>
Example Facebook page Name
Is there anyway XPATH can check for the class='desc' then return me what I need?
First you need valid xml to work with:
<?xml version="1.0" encoding="utf-8"?>
<form>
<div class="desc">Example text</div>
Example Facebook page Name
</form>
Given that, this will work:
//div[#class = "desc"]/following-sibling::a/#href

Bootstrap Navbar Highlighting in Thymeleaf's layout

I am evaluating spring boot + MVC + bootstrap . One problem I am facing is bootstrap's navbar highlighting problem in thymeleaf.
I hope thymeleaf can judge the tab which should be highlighted.
I searched and found this solution : Bootstrap Navbar Highlighting in Thymeleaf
In the containing(outer) page , it uses
<div th:replace="header::header('home')">
to be replaced header
</div>
to designate the home tab should be highlighted.
And in the contained (inner) page , it uses
<nav class="..." th:fragment="header(activeTab)">
<ul class="nav navbar-nav">
<li th:class="${activeTab == 'home'} ? 'active' : null ">Home</li>
</ul>
to judge this tab should be highlighted or not.
It works for every single page well , but not for layout.
In a layout page , the containing (outer) page is a decorator , which decorates other pages (home / about / contact ...) . The tab value is pending here .
for example
<div th:replace="header::header('home')">
to be replaced header
</div>
<div layout:fragment="content">
layout
</div>
<div th:replace="footer::footer">
to be replaced footer
</div>
I cannot pre-assign home tab in the layout file.
Is there any way to solve it ?
Can it judge by controller or even controller's method ?
environment :
springboot.version 1.3.0.M5
spring.version :4.2.1.RELEASE
Thanks a lot !
It is not a exact solution for your question but maybe you will like the idea. You may use request context path to recognize which tab is actually selected, so you can use ${#httpServletRequest.getContextPath()} and maybe then something like that:
<ul class="nav navbar-nav" th:with="view=${#httpServletRequest.getServletPath()}">
<li th:classappend="${#strings.startsWith(view,'/home')? 'active' : ''}">Home</li>
</ul>
Or you can use ControllerAdvice:
#ControllerAdvice(assignableTypes = { MyController.class })
public class MyControllerAdvice {
#ModelAttribute
public void addAttributes(#RequestParam Map<String, String> params, Model model, HttpServletRequest request) {
String activeTab = ... whatever
model.addAttribute("active_tab", activeTab);
}
}
There is one big disadvantage of using #ControllerAdvice. If you are planning to use Spring WebFlow to create multi-page forms (wizards) then it will not work because WebFlow does not use model attributes.
change this line <nav class="..." th:fragment="header(activeTab)">
to this
<nav class="..." th:fragment="header(activeTab='activeTab')">
it worked for me

How to render html on a given view brefore RenderBody() from the layout is triggered

I'm working on an ASP.NET MVC3 project. I'm using Twitter Bootstrap for my styling (not sure if that's important). The problem I have is that my Index.cshtml view of the Home controller has slightly different layout from the other pages (additional image navigation at the top which I don't show once the user select where he wants to go) but this is causing problems so I remove this part from the Index view to another partial view _ImageNavigation.cshtml and what I want to do is render the content of this partial view when Home/Index.cshtml is opened and I want to render it before the #RenderBody() also independently from it so I get the page the way I want it.
Right now in my _Layout.cshtml I have:
<div id="main">
<div class="container-fluid">
<div class="row">
<div class="col-md-10">#RenderBody() </div>
<div class="col-md-2">
//some static content
</div>
</div>
</div>
So I have two ideas first - adding #RenderPage("~/Views/Shared/_ImageNavigation.cshtml") right before #RenderBody() like :
<div class="row">
#RenderPage("~/Views/Shared/_ImageNavigation.cshtml")
<div class="col-md-10">#RenderBody() </div>
which produces the effect I want, but as you may guess _ImageNavigation is rendered on every page which is not what I want. I want it only on my Home/Index.cshtml so I guess the maybe some kind of check could be made to see what view is loading and render _ImageNavigation only if it's the correct view. Something like :
if (LoadingView == Home/Index.cshtml)
{
#RenderPage("~/Views/Shared/_ImageNavigation.cshtml")
}
Of course the above is just pseudo code, I don't know if it's possible and how to make such a check. And also I wonder if there is a way to do it in the page itself. I tried to put #RenderPage("~/Views/Shared/_ImageNavigation.cshtml") directly in my Home/Index.cshtml but obviously this way the page is rendered as if the code is written directly in the View and not loaded explicitly.
Maybe there's other way. This seems like pretty standard problem but I don't seem to find a proper solution.
When you have a smaller number of exceptions I like to use Sections. Here is a very simlified example:
Layout:
#if (IsSectionDefined("Nav"))
{
RenderSection("Nav")
}
else
{
<nav>default nav</nav>
}
#RenderBody()
Page with alternative nav:
#section Nav
{
<nav>My alternate nav</nav>
}
<div>This is the body for RenderBody</div>
You can read more on Defining Default Content For A Razor Layout Section - Phil Haacked.

How do I theme the title of a block in a view

I am using views and I have created a block. I need to add a span to Newest members.
I tried using the theme tpl files given by views. The top most file is views-view.tpl.php, I added a class to the first div "vishaltest" however u can see it starts a bit lower than what I want. how can I override this section
<div class="block-title">Newest members</div>
the code:
<section id="block-views-5a3590205379433adabbd042516161b0" class="block block-views clearfix">
<div class="block-title">Newest members</div>
<div class="view view-recently-added-updated-profiles view-id-recently_added_updated_profiles view-display-id-newest_member view-dom-id-e8042a917bbe79ecf65705f5c8bda2a3 vishaltest">
I think you would have more chance to access the block title through block--views-view.tpl.php using $block->subject variable.

Resources