I tried to integrate the analytic account in report.picking for purchase, like I've done for sale.
For sale picking report i have done like this :
<span class="oe_editable" t-field="o.sale_id.project_id"/>
I tried to do the same in picking report for incoming like that:
<t t-if="o.picking_type_id.code !== 'outgoing'">
<td>
<span class="oe_editable" t-field="o.sale_id.project_id"/>
</td>
</t>
<t t-if="o.picking_type_id.code !== 'incoming'">
<td>
<span class="oe_editable" t-field="o.invoice_line[0].account_analytic_id"/>
</td>
</t>
I have got an error like:
QWebException: "'stock.picking' object has no attribute 'invoice_line'" while evaluating
'o.invoice_line[0]'
But I can't find the right field to integrate.
I think I don't have the good model in o.*
Any idea on how the find good and complete field name ?
Related
Hello i need some help with a basic question. This is my code:
{foreach $sArticle.attributes.core->toArray() as $attribute}
<tr class="product--properties-row">
<td class="product--properties-label is--bold">{$sArticle.attributes.name}{$sArticle.attributesName}</td>
<td class="product--properties-label is--bold">{$attribute}</td>
</tr>
{/foreach}
1.Question: How do I enter the attributes name? I mean the column name from the attribute in the database?
2.Question: I only want to loop with the foreach through columns with name="artikelattr_" any idea how this can be done?
Thanks
I adjusted my answer here: https://stackoverflow.com/a/71237355/7201069
How to get the name of the attribute.
To consider only certain attributes that starts with a specific string, just add an if in the loop:
{foreach $sArticle.attributes.core->toArray() as $attributeName => $attribute}
{if $attributeName|strpos:"artikelattr_" === 0}
{$attributeName|var_dump}
{$attribute|var_dump}
{/if}
{/foreach}
You can simply use nearly all PHP functions in Smarty.
Please help, i cann't find in freemarker guide how to convert from thymeleaf this:
lists.isEmpty and for each
<th:block th:if="${#lists.isEmpty(employees)}">
<h3>No employee</h3>
</th:block>
<th:block th:unless="${#lists.isEmpty(employees)}">
<tr th:each="contact,iterStat : ${employees}">
<td th:text="${iterStat.count}"></td>
<td th:text="${contact.name}"></td>
<td th:text="${contact.phone}"></td>
Thanks!
Maybe Something like this? (sketch, not tested)
<#list employees as contact>
<tr>
<td>${contact?index}
<td>${contat.name}</td>
<td>${contact.phone}</td>
</tr>
<#else>
<h3>No employee</h3>
</#list>
Notes
<#list> Will generate a <tr> element for each item in the employees sequence, containing <td>'s for each field.
If the employees sequence is empty it will generate the <h3> element.
See List Directive Doc
It gets the zero based index of the item using the build-in function
?index. See built-ins and loop variables in the help. Freemarker built-ins Doc. If you want one based, you can add one to it.
It's works
<#list employees as contact>
<tr>
<td>${contact?index}
<td>${contat.name}</td>
<td>${contact.phone}</td>
</tr>
<#else>
<h3>No employee</h3>
</#list>
I have a simple table and I have checkbox inside that table. If checkbox is selected I want to display other features.
My code:
<table>
<tr th:each="obj,iterationStatus : ${objs}">
<td th:text="${obj.name}"></td>
<td><input type="checkbox" name="firstcheckbox"></td>
<td th:if="isChecked">
<!-- do something -->
</td>
</tr>
</table>
How I do this without using javascript and backbean?
In this case you have two options, the first option you don't want but is not a bad option is using Javascript: creating a function called isChecked.
Otherwise, you can know if a checkbox is checked with thymeleaf in the case you are in a form which calls itself. You could do something like if(firstcheckbox != null) and, of course, your checkbox would have a value <input type="checkbox" name="firstcheckbox" value="value">. Finally, you must add as attribute in your model: model.addAttribute("firstCheckbox", firstCheckbox);
I have a table like this with many numbers, below particular row from this table.
<tr>
<td>5100<td>
<td> Number description<td>
<td>long number description<td>
<td>
<input class="checkbox" type="checkbox" checked="" value="5100" name="id_rola[]">
<td>
<td>
<a href="javascript:documeny.frolazak_5100.submit();">
<b><img src="temp/img/foto.gif"></b>
</a>
<td>
<tr>
Whats i try to do was for this number check checkbox and next click link, but with this i have a problem. Firstly when i do check("5100") this show me unable to find checkbox "5100", and next when i try click link with find(:xpath, "//a[#href="javascript:document.frolazak_5100.submit();]").click , this show me unable to find xpath.
For any suggestion thx.
EDIT: ANSWERS
Check checkbox with particular value:
find(:css, ".checkbox[value='5100']").set(true)
Click on image in link in row:
To do this i wrote:
all('tr').each do |tr|
next unless tr.has_text?('5100')
#href = tr.all('td a')[0][:href]
end
visit #href
But this solution was be sloowly, so first i puts #href and then i could manipulate directly with params in this href and instead using method all simply visit this href. BTW why i dont think about it earlier :)
I have a composite domain object as follows:
class Person
{
static embedded = ['forSale']
Boolean isSelling
House forSale
}
class House
{
Integer numBedrooms
}
I have a select control for the numBedrooms as follows:
<tr class="prop">
<td valign="top" class="name">
<label for="numBedrooms"><g:message code="person.numBedrooms.label" default="Num Bedrooms" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: personInstance, field: 'forSale.numBedrooms', 'errors')}">
<g:select name="numBedrooms" value="${fieldValue(bean: personInstance, field: 'forSale.numBedrooms')}"
noSelection="${['null':'Select a number...']}"
from="${1..6}"
/>
</td>
</tr>
Notice that I am using forSale.numBedrooms in the fieldValue on the select. I haven't been able to produce scaffolded code for this to take a look at how it is supposed to be done because the create view which gets generated by create-views contains no references to the fields in the forSale House object.
I also haven't been able to turn up any exampes of composite fields being accessed via GSP, so this is a bit of a guess. In any case the GSP page renders without errors, although that may be because I haven't been able to save any data.
I send the value of numBedrooms back as part of a URl query string...
&numBedrooms=2
When I do this the save code in my controller is failing silently - at least nothing ever gets written to the database. I have switched on debug logging for pretty much everything but I get no messages in the log which suggest anything is wrong, although something obviously is.
If I remove the numBedrooms parameter from the query string then my save proceeds as normal, so I am guessing it is something to do with resolving numBedrooms.
Any clue what I am doing wrong and what I can do to track down my problem?
What I do is generate-all for the House Domain then copy and paste the GSP code and remove the files once I am done. I have also found it smarter to create templates to edit the House domain in the case where I am using the House domain later on.
For you GSP you need something like this (Notice the name attribute)
<tr class="prop">
<td valign="top" class="name">
<label for="forSale.numBedrooms"><g:message code="house.numBedrooms.label" default="Num Bedrooms" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: personInstance.forSale, field: 'numBedrooms', 'errors')}">
<g:select name="forSale.numBedrooms" value="${fieldValue(bean: personInstance.forSale, field: 'numBedrooms')}"
noSelection="${['null':'Select a number...']}"
from="${1..6}"
/>
</td>
</tr>
In your param string you need *forSale*.numBedrooms=2. this code will work with person.properties = params or new Person(params).
The embedded "instruction" only tells Hibernate to include the parameters in the same table they are still seperate Domain classes. It will probably generate a table for the domain even though you may never use it.
Hope this helps.