Odoo13 QWEB report pdf name - odoo-10

On my custom modules that generate pdf reports the field "print_report_name" not name the report. I need report name + datetime actual.
Always take the name of the "name" field from the report definition.
I used it with Odoo10CE and it works perfectly.
Maybe there is another way to do it from the v10? I found nothing in the documentation.

You have to use this tag for your custom report name print under report tag. Right now I am using basic module. You can use your custom field and model for your use.
<field name="print_report_name">'%s - %s' % (object.name, object.date_done)</field>
Block of code for your reference.
<record id="action_report_lot_label" model="ir.actions.report">
<field name="name">Lot/Serial Number (PDF)</field>
<field name="model">stock.production.lot</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">stock.report_lot_label</field>
<field name="report_file">stock.report_lot_label</field>
<field name="print_report_name">'%s - %s' % (object.name, object.date_done)</field>
<field name="binding_model_id" ref="model_stock_production_lot"/>
<field name="binding_type">report</field>
</record>

Related

How to print nested xml elements?

Sample xml:
<Root>
<Customers>
<Customer>
<CompanyName>Great Lakes Food Market</CompanyName>
<ContactName>Howard Snyder</ContactName>
<ContactTitle>Marketing Manager</ContactTitle>
<Phone>(503) 555-7555</Phone>
<FullAddress>
<Address>2732 Baker Blvd.</Address>
<City>Eugene</City>
<Region>OR</Region>
<PostalCode>97403</PostalCode>
<Country>USA</Country>
</FullAddress>
</Customer>
</Customers>
</Root>
In the above xml, when I use "Customer" as the root node and xpath query as "/Root/Customers/Customer", I'm unable to print the child nodes of "FullAddress" and when I use "FullAddress" as the root node and the xpath query as "/Root/Customers/Customer/FullAddress", unable to print all the fields.
Kindly help me with the solution to print all the xml elements including the nested in a single report.
The correct XPath query is
<queryString language="XPath">
<![CDATA[/Root/Customers/Customer]]>
</queryString>
This include both of your nodes, to access the value is FullAddress node you should use XPath also in fieldDescription when you define your field, hence Address is accessed through FullAddress/Address
Example
If the field declaration of CompanyName is
<field name="CompanyName" class="java.lang.String">
<fieldDescription><![CDATA[CompanyName]]></fieldDescription>
</field>
the field declaration of for example the City is
<field name="City" class="java.lang.String">
<fieldDescription><![CDATA[FullAddress/City]]></fieldDescription>
</field>

Ignoring diacritics when sorting facet values in Solr 4

Tl;dr: How can I get Solr 4 to ignore diacritics when sorting facet values?
I've added the following four documents to the "collection1" Solr core in the default Solr example:
<doc>
<field name="id">1</field>
<field name="cat">manuka</field>
<field name="cat">mystery</field>
</doc>
<doc>
<field name="id">2</field>
<field name="cat">mānuka</field>
<field name="cat">stuff</field>
</doc>
<doc>
<field name="id">3</field>
<field name="cat">management</field>
<field name="cat">stuff</field>
</doc>
<doc>
<field name="id">4</field>
<field name="cat">abc</field>
<field name="cat">stuff</field>
</doc>
The "cat" field is defined as:
<field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>
and the "string" type is defined as:
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
When I do a facet query on the "cat" field, sorted by value (http://localhost:8983/solr/collection1/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=cat&facet.sort=index), I get:
....
"facet_fields":{
"cat":[
"abc",1,
"management",1,
"manuka",1,
"mystery",1,
"mānuka",1,
"stuff",3]},
....
Note that mānuka comes after mystery. I'd like to have mānuka come after manuka and before stuff, that is, I'd like the sort to ignore diacritics including the macron.
If this was a non-facet search, it looks like I could achieve what I want by setting up Collation for a separate copy field and sort by that (I can't set up collation for the field itself because the stored data will be a binary representation of the collation key). However, it looks like this approach isn't possible for facet queries since they can only be sorted by index or count.
Am I overlooking something? Is there some trick to get this working in an environment where I do need to display the value of the "cat" field?
The question is about customizing the index-order of a facet.
Your suggestion is to use Collation. You can do this and the order of your facets will be correct. The problem is that neither CollationField nor ICUCollationField are overriding the indexedToReadable method.
The two classes cannot override indexedToReadable because in general the mapping from word to term is not invertible. But for your case possible you can implemenent a subclass of ICUCollationField which overrides indexedToReadable in a sencefull way.
Your starting point could be TestICUCollationField with
<fieldType name="sort_fr_t" class="solr.ICUCollationField" locale="fr" strength="primary"/>
...
<field name="sort_fr" type="sort_fr_t" indexed="true" stored="true" docValues="true" multiValued="true"/>
as you will see in this case the names of the facet values are very unreadable.

Conditional validation of format or required property in Beanio

I have a requirement to conditionally validate the format or required=true/false based another fields in a beanmapper configuration.
Example:
<stream name="stream1" format="fixedlength" minlength="101" maxlength="101">
<record name="record1" class="a.b.c.SomeClassName">
<field name="updateType" required="true" length="1" regex="A|C" />
<field name="firstName" required=? length="50" format=?/>
<field name="lastName" required=? length="50" format=?/>
</record>
</stream>
Condition scenario 1: for updateType="A", I need firstName to have not null ( not all spaces as this is a fixed length format record) and for updateType="C", firstName must be all blanks.
Condition scenario 2: for firstName=some value, lastName must also have some value (non blank)
How can I achieve this in Beanio? I am using spring-batch 3x for my job execution.
I could not get any BeanIO utility for this, out of the box. The way I am handling this now is performing those conditional validations in the spring batch processor.

AXMLS check constraint

I am creating q site using Conreate 5 CMS.
I am creating a new block and I have to use AXMLS to create a database table.
I have been able to create a basic table but I would like to extend it to add an check constraint. Below is the code I have written so far.
<?xml version="1.0"?>
<schema version="0.3">
<table name="btAddVehicle">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="title" type="C" size="100">
<NOTNULL />
</field>
<field name="imgLocation" type="X"></field>
<field name="year" type="I" size="4"></field>
<field name="desciption" type="X"></field>
</table>
</schema>
so for the line I was intending to that size="4" would restrict the number of values to 4. eg 1990,1999 but this didn'st work
I have read this http://phplens.com/lens/adodb/docs-datadict.htm#foreignkey
but it seems unclear
It says
CONSTRAINTS Additional constraints defined at the end of the field definition."
SO would it be something like
<field name="year" type="I" constraint="check([year] LIKE REPLICATE ('[0-9]', 4)) "></field>
Or do I need to add an at the end of this code
`<sql>
add some kind of alter table to add the constraint
AlTER tblTable etc....
</sql>`
The size=4 only restrict it to a number between 0 and 9999. So no, that won't work.
I don't know how to use CONSTRAINTS either, but I have never needed that. Normally I use Concrete5's validation helper to validate values before saving them to the database. This also makes it a lot easier to get it printed out to the user in your view, if needed, using the validation error helper
Hope this helps you...

XPATH query to filter values on certain attributes only

I have following XML:
<Library>
<Item>
<Field Name="Name">smooth</Field>
<Field Name="File Type">mid</Field>
<Field Name="File Size">60026</Field>
</Item>
<Item>
<Field Name="Name">mid</Field>
<Field Name="File Type">mp3</Field>
<Field Name="File Size">4584972</Field>
</Item>
</Library>
I'd like to get all item names of items of the file type "mid". My XPATH query looks as
/Library/Item/Field
[
#Name="Name" and
(../Field[#Name="File Type" and ../Field[.="mid"]])
]
But unfortunately both items are returned from that query.
smooth
mid
Seems that the last condition is not checked against fields with the attribute "File Type" only, but all fields. Which results in a return of the name "mid", even if this item is of file type "mp3".
How can I restrict the comparison with "mid" to the value of the field with the attribute Name="File Type"?
Can anybody suggest me an XPATH syntax which works as expected?
XPath predicates can be applied anywhere, this would be more straight-forward:
/Library/Item[Field[#Name="File Type"] = "mid"]/Field[#Name="Name"]
Your own expression would be correct as
/Library/Item/Field[
#Name="Name"
and ../Field[#Name="File Type"] = "mid"
]

Resources