Sum function not working when selecting value after matching condition - xslt

I'm trying to extract and sum values from a XML file. The data set have an element called "Pallets" which contains "Y" or "N". So if the "Pallets" value equals "Y" then I want to get the value in "Amount". I went through lot of XSL codes here and on the internet then I came up with the below code part.
<xsl:value-of select=
"('
Pallet Amount',
$fullPath/LineItemRows/LineItemRow/Fields
[Field[#Label = 'Pallets']/Value = 'Y']
/sum(number(translate(Field[#Label = 'Amount']/Value,
',',
'.')
)
)
)"/>
Which is producing the below out put,
Pallet Amount 7.21 7.21 14.06
As you guys can see I do get the values but they're not summing up. My desired out put is 28.48.
Below is a sample set of data which is similar to the XML I'm using (the actual file is too big and it generated by a software we use).
<LineItemRows>
<LineItemRow ID="0" FromPage="1">
<Fields>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>406,74</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="3" FromPage="1">
<Fields>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>Y</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>7,21</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="0" FromPage="1">
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>33,92</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="5" FromPage="1">
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>Y</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>7,21</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="6" FromPage="1">
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>Y</Value>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>14,06</Value>
</Field>
</Fields>
</LineItemRow>
</LinItemRows>
I also tried some other ways but those literally didn't work. Hope I made my question clear. Also I'm using xsl version 2.0 but system is compatible with version 1.0 as well.

The XPath 2 expression
sum(LineItemRows/LineItemRow/Fields[Field[#Label='Pallets' and Value='Y']]/Field[#Label='Amount']/xs:decimal(translate(Value,',','.')))
If there is any risk that the Y or N value could be padded with whitespace then use normalize-space(Value)='Y' for that value test.
Your original expression was applying the summing within the LineItemRow which would only have found a single value and so you were outputting a sequence of those single-value sums.
The expression here also performs the sum using the XMLSchema Decimal type (declare the namespace xmlns:xs="http://www.w3.org/2001/XMLSchema" for the prefix used in that expression) rather than the default double precision number representation which should avoid inaccuracies and the need to round the sums to two digits.

Related

Group data when condition is met

I'm working on a XSL solution to convert a XML file to CSV. The end product need me to read set of invoices from the XML and then group them according to the invoice number and then list the items below the invoice number.
I'm not a fluent in XSL but I wrote the entire thing but I'm stuck on creating the tables. Below is the out put I'm required to create.
I tried to find away to make it work but only way I came close with this posts second answer. Following that I came up with the below code. Also like to mention I'm using XSL v 2.0
<!-- Line items -->
<!-- Full path for the elemnts I'm just lazy to tye the same thing again and again -->
<xsl:variable name="fullPath" select="/BatchObject/BaseTypeContainerList/BaseTypeContainer/BaseTypeObject/Metadata"/>
<!-- Full path for line items. I'm just too lazy -->
<xsl:variable name="fullPathLine" select="/BatchObject/BaseTypeContainerList/BaseTypeContainer/BaseTypeObject/Metadata/LineItemRows/LineItemRow"/>
<xsl:for-each-group select="$fullPath" group-by="$fullPath/Fields/Field[#Label = 'Invoice Number']/Value" >
<xsl:text>
</xsl:text>
<xsl:value-of select="current-grouping-key()"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="$fullPath/Fields/Field[#Label = 'Invoice Number']/Value = current-grouping-key()">
<xsl:value-of select="('
',$fullPathLine/Fields/Field[#Label = 'Line']/Value,';')"/>
<xsl:value-of select="($fullPathLine/Fields/Field[#Label = 'Description']/Value,';')"/>
<xsl:text>
</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each-group>
But the out put is looks like this,
01108840
1 2 3 4 1 2 3 4 5 6 7 1 2 3 4 5 6 ;Ekstra lang Høy skillevegg, ekstra Gummimatte, ekstra Pallet 1200x800 Hylle 1458x216x54 Hylle 1296x216x54 Forhøyningsramme med Bakdeksel 486x270 Bakdeksel 648x378 Pallet 1200x800 Pallet frame 1200X800 Skuff 486x486x216 Hylle 486x486x54 Hyllestige med kortere Verktøyplate 486x270 Bakdeksel 486x270 Gummimatte, hylle ;
01108849
1 2 3 4 1 2 3 4 5 6 7 1 2 3 4 5 6 ;Ekstra lang Høy skillevegg, ekstra Gummimatte, ekstra Pallet 1200x800 Hylle 1458x216x54 Hylle 1296x216x54 Forhøyningsramme med Bakdeksel 486x270 Bakdeksel 648x378 Pallet 1200x800 Pallet frame 1200X800 Skuff 486x486x216 Hylle 486x486x54 Hyllestige med kortere Verktøyplate 486x270 Bakdeksel 486x270 Gummimatte, hylle ;
But out put I want to create is
01108840
1;Ekstra lang Høy
2;skillevegg,
3;ekstra Gummimatte,
4;ekstra Pallet 1200x800
XML data sheet.
<BaseTypeContainerList>
<BaseTypeContainer ID="2292be4cbac2405097d8b40fdbe0068b" DBID="0" Archived="0001-01-01T00:00:00" Destroy="0001-01-01T00:00:00" Created="2020-03-31T12:12:00.2302687+02:00" Modified="2020-03-31T12:12:00.2302687+02:00" CreatedOrder="0" Status="Complete" RejectionMailSendt="false">
<BaseTypeObject xsi:type="Email" ID="5885e93bfc8e404187bc274417ee4ac5">
<Metadata>
<Fields>
<Field ID="186e155a1fb6442b872a88dc5f6e8a7f" Type="Text" Status="Complete" Label="Master">
<Value>KGH_Modulsystem</Value>
</Field>
<Field ID="4911c6aa66864547b5e81ae92e1241af" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Agreement Number">
<Value>130</Value>
</Field>
<Field ID="6941c04028f149b4b48cd3eb659bb71d" Type="Text" Status="Complete" Label="Seller">
<Value>112885</Value>
</Field>
<Field ID="90236e52a3194885b4812e4d84afda76" Type="Text" Status="Complete" Label="Buyer">
<Value>Modul-System AS</Value>
</Field>
<Field ID="c03844760c5342caab89253570eb6af9" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Customer Number">
<Value>9095</Value>
</Field>
<Field ID="510fe5c44e1d4e9d8499a83cfae92802" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Invoice Number">
<Value>01108840</Value>
</Field>
<Field ID="d34638d12dd64e519bbb5da0b92d1f0b" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Date" Status="Complete" Label="Invoice Date">
<Value>28.11.2019</Value>
</Field>
<Field ID="c121fadca3d34278a68aa2feb26fc969" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Invoice Type">
<Value>CI</Value>
</Field>
<Field ID="2d489e9bb66b49559ee634e140df33b0" MappedFieldID="d9f08184ff57469cb9bb37fa28014249" Type="Text" Status="Complete" Label="Delivery Term">
<Value>DDP</Value>
</Field>
<Field ID="ee9cd176f29245b0978de6d0706dc478" Type="Text" Status="Complete" Label="Delivery Term Location">
<Value>Skjetten</Value>
</Field>
<Field ID="6c23fea43499495590efebb0b4cea541" Type="Text" Status="Complete" Label="Packages">
<Value>1</Value>
</Field>
<Field ID="66fdcc37d3ae4eafa21523a7ec1937d9" Type="Text" Status="Complete" Label="Package Type">
<Value>PX</Value>
</Field>
<Field ID="e6d8303294a8400e933ee622196dbcc3" Type="Text" Status="Complete" Label="Pallet Weight">
<Value>23</Value>
</Field>
<Field ID="a4548889d35d44159c1f19d55017412f" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Batch Gross Weight">
<Value>3000</Value>
</Field>
<Field ID="05ce757f80a14c1182c59f070be06522" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Batch Net Weight">
<Value>2500</Value>
</Field>
<Field ID="fce2f65786314fc2ae466639b8c4a7f9" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Over-Head Cost">
<Value>45,22</Value>
</Field>
<Field ID="160f608391854226a6e3fc3d363a5490" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Total Amount">
<Value>452,23</Value>
</Field>
<Field ID="0cd4d1027d9d44b490e306f0e04e36e6" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Currency">
<Value>EUR</Value>
</Field>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line" />
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity" />
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description" />
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number" />
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin" />
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount" />
<Field ID="bc54c6e2147949899ed875c189753846" Type="Text" Status="Complete" Label="Table Amount">
<Value>452,23</Value>
</Field>
<Field ID="e182f943a4694123b7f7182b2b017fca" Type="Text" Status="Complete" Label="Country Sender Receiver">
<Value>SE;NO</Value>
</Field>
<Field ID="e3136a0631c346149a3cfd48e7824f85" MappedFieldID="ce76fa9ee7c74b1aa4367e2eac8de23b" Type="Text" Status="Complete" Label="Email">
<Value>stian.svarholt#kghcustoms.com</Value>
</Field>
</Fields>
<LineItemRows>
<LineItemRow ID="0" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>1</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>1,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Ekstra lang</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>406,74</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="1" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>2</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>2,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Høy skillevegg, ekstra</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>24,90</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="2" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>3</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>3,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Gummimatte, ekstra</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>13,38</Value>
</Field>
</Fields>
</LineItemRow>
</LineItemRows>
<BaseTypeContainer ID="1320da9c026b4b6ead49f7a736676570" DBID="0" Archived="0001-01-01T00:00:00" Destroy="0001-01-01T00:00:00" Created="2020-03-31T12:12:01.9314102+02:00" Modified="2020-03-31T12:12:01.9314102+02:00" CreatedOrder="1" Status="Complete" RejectionMailSendt="false">
<BaseTypeObject xsi:type="Email" ID="b77a7d029687426cb9e60d017df5bb58">
<Metadata>
<Fields>
<Field ID="186e155a1fb6442b872a88dc5f6e8a7f" Type="Text" Status="Complete" Label="Master">
<Value>KGH_Modulsystem</Value>
</Field>
<Field ID="4911c6aa66864547b5e81ae92e1241af" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Agreement Number">
<Value>130</Value>
</Field>
<Field ID="6941c04028f149b4b48cd3eb659bb71d" Type="Text" Status="Complete" Label="Seller">
<Value>112885</Value>
</Field>
<Field ID="90236e52a3194885b4812e4d84afda76" Type="Text" Status="Complete" Label="Buyer">
<Value>Modul-System AS</Value>
</Field>
<Field ID="c03844760c5342caab89253570eb6af9" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Customer Number">
<Value>9095</Value>
</Field>
<Field ID="510fe5c44e1d4e9d8499a83cfae92802" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Invoice Number">
<Value>01108849</Value>
</Field>
<Field ID="d34638d12dd64e519bbb5da0b92d1f0b" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Date" Status="Complete" Label="Invoice Date">
<Value>28.11.2019</Value>
</Field>
<Field ID="c121fadca3d34278a68aa2feb26fc969" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Invoice Type">
<Value>CI</Value>
</Field>
<Field ID="2d489e9bb66b49559ee634e140df33b0" MappedFieldID="d9f08184ff57469cb9bb37fa28014249" Type="Text" Status="Complete" Label="Delivery Term">
<Value>DDP</Value>
</Field>
<Field ID="ee9cd176f29245b0978de6d0706dc478" Type="Text" Status="Complete" Label="Delivery Term Location">
<Value>Skjetten</Value>
</Field>
<Field ID="6c23fea43499495590efebb0b4cea541" Type="Text" Status="Complete" Label="Packages">
<Value>3</Value>
</Field>
<Field ID="66fdcc37d3ae4eafa21523a7ec1937d9" Type="Text" Status="Complete" Label="Package Type">
<Value>PX</Value>
</Field>
<Field ID="e6d8303294a8400e933ee622196dbcc3" Type="Text" Status="Complete" Label="Pallet Weight">
<Value>23</Value>
</Field>
<Field ID="a4548889d35d44159c1f19d55017412f" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Batch Gross Weight">
<Value>3000</Value>
</Field>
<Field ID="05ce757f80a14c1182c59f070be06522" MappedFieldID="04672b33e6f14285abc11a866c2a993e" Type="Text" Status="Complete" Label="Batch Net Weight">
<Value>2500</Value>
</Field>
<Field ID="fce2f65786314fc2ae466639b8c4a7f9" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Over-Head Cost">
<Value>19,27</Value>
</Field>
<Field ID="160f608391854226a6e3fc3d363a5490" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Total Amount">
<Value>192,72</Value>
</Field>
<Field ID="0cd4d1027d9d44b490e306f0e04e36e6" MappedFieldID="e05d5ee159484e81b071b8bd85cca134" Type="Text" Status="Complete" Label="Currency">
<Value>EUR</Value>
</Field>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line" />
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity" />
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description" />
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number" />
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin" />
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount" />
<Field ID="bc54c6e2147949899ed875c189753846" Type="Text" Status="Complete" Label="Table Amount">
<Value>192,72</Value>
</Field>
<Field ID="e182f943a4694123b7f7182b2b017fca" Type="Text" Status="Complete" Label="Country Sender Receiver">
<Value>SE;NO</Value>
</Field>
<Field ID="e3136a0631c346149a3cfd48e7824f85" MappedFieldID="ce76fa9ee7c74b1aa4367e2eac8de23b" Type="Text" Status="Complete" Label="Email">
<Value>stian.svarholt#kghcustoms.com</Value>
</Field>
</Fields>
<LineItemRows>
<LineItemRow ID="0" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>1</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>1,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Hylle 1458x216x54</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>33,92</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="1" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>2</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>1,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Hylle 1296x216x54</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>33,44</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="2" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>3</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>1,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Forhøyningsramme med</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>19,20</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="3" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>4</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>2,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Bakdeksel 486x270</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>31,82</Value>
</Field>
</Fields>
</LineItemRow>
<LineItemRow ID="4" FromPage="1">
<Fields>
<Field ID="26fc88ba67cf4f8fb8e5a25383e9403f" Type="Text" Status="Complete" Label="Line">
<Value>5</Value>
</Field>
<Field ID="86381702799b4265a48d7d96eba3abbf" Type="Text" Status="Complete" Label="Quantity">
<Value>3,00</Value>
</Field>
<Field ID="2d42106344c54189a9045ee0dedb51b6" Type="Text" Status="Complete" Label="Description">
<Value>Bakdeksel 648x378</Value>
</Field>
<Field ID="55d85303fa4c4c37bc51ac0562d887f1" Type="Text" Status="Complete" Label="HS Code">
<Value>94032009</Value>
</Field>
<Field ID="6caaa2a60bc842c193ac8590550108b0" Type="Text" Status="Complete" Label="Article Number">
<Value>94032009</Value>
</Field>
<Field ID="a16255ad1e9549b48a9a31d001629b36" Type="Text" Status="Complete" Label="Pallets">
<Value>N</Value>
</Field>
<Field ID="64cd6620ab5a456997694c8592b9e87b" Type="Text" Status="Complete" Label="Colli" />
<Field ID="c43102102ce64a1db469408a5b131f4d" Type="Text" Status="Complete" Label="Net Weight" />
<Field ID="0565320a98c84652963ce0732cac7ad9" Type="Text" Status="Complete" Label="Origin">
<Value>SE</Value>
</Field>
<Field ID="252a9390778540edac6520d3f9f260b8" Type="Text" Status="Complete" Label="Amount">
<Value>53,07</Value>
</Field>
</Fields>
</LineItemRow>
</LineItemRows>
I know the data set is big but wanted show you what I've to work with. So hope some can shed some light on what I'm doing wrong.
I think instead of
<xsl:for-each select="$fullPath/Fields/Field[#Label = 'Invoice Number']/Value = current-grouping-key()">
you want
<xsl:for-each select="current-group()">

How to get field value from another Many2many field?

I use odoo 10 and I created a custom module to plan trips. I create a view for the plans in which I will select the list of my travels. My problem now is how I can get the Start and Destination fields of each trip insert in this view knowing that the field that displays the list of trips is travel_ids = fields.Many2many ('tms.travel', copy = False, string = 'Travels'). I try a lot but no result. Any idea for help please ??
tms_travel_planning.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="view_tms_travel_planning_form" model="ir.ui.view">
<field name="name">view.tms.travel.planning.form</field>
<field name="model">tms.planning</field>
<field name="arch" type="xml">
<form string="Plannification des voyage">
<header>
<field name="state" statusbar_visible="draft,approved,confirmed" widget="statusbar"/>
</header>
<sheet>
<div class="oe_title">
<h1>
<label class="oe_inline" style="font-size:30px;" string="Plannification - " attrs="{'invisible':[('name','=', False)]}"/>
<field name="name" readonly="1"/>
</h1>
</div>
<group>
<group>
<field name="datetime"/>
<field attrs="{'readonly':[('state','in',('confirmed', 'cancel'))]}" name="operating_unit_id"/>
</group>
<group>
<field name="num_vehicule_dispo"/>
<field name="num_chauffeur_dispo"/>
</group>
</group>
<notebook colspan="1">
<page string="Les voyages à planifier">
<separator coslpan="4" string="Voyages"/>
<!--<field attrs="{'readonly':[('state','in',('confirmed', 'cancel'))]}" name="operating_unit_id"/>-->
<field attrs="{'readonly':[('state','in',('confirmed', 'cancel'))]}" colspan="4"
domain="[('state','not in',('cancel','closed'))]" name="travel_ids" nolabel="1"/>
<separator coslpan="4" string="Véhicules"/>
<field colspan="4" name="fleet_ids" nolabel="1"/>
<separator coslpan="4" string="Conducteurs"/>
<field colspan="4" name="employee_ids" nolabel="1"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
tms_travel_planning.py
# -*- coding: utf-8 -*-
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class TmsTravelPlanning(models.Model):
_name = 'tms.planning'
name = fields.Char('Num du plannification')
operating_unit_id = fields.Many2one(
'operating.unit', string='Operating Unit', required=True)
id_planning=fields.Integer(string="Numéro du plannification")
datetime=fields.Date(string="Date")
num_vehicule_dispo=fields.Integer(string="Nombre de véhicule disponible")
num_chauffeur_dispo=fields.Integer(string="Nombre de chauffeur disponible")
tms
fleet_ids = fields.Many2many('fleet.vehicle', copy=False, string='Véhicules')
employee_ids = fields.Many2many('hr.employee', copy=False, string='Conducteurs')
state = fields.Selection([
('draft', 'Pending'),
('approved', 'Approved'),
('confirmed', 'Confirmed'),
('cancel', 'Cancelled')], readonly=True,
help="Gives the state of the Waybill.",
default='draft')
#api.model
def create(self, values):
planning = super(TmsTravelPlanning, self).create(values)
if not planning.operating_unit_id.planning_sequence_id:
raise ValidationError(_(
'You need to define the sequence for planning in base %s' %
planning.operating_unit_id.name
))
sequence = planning.operating_unit_id.planning_sequence_id
planning.name = sequence.next_by_id()
print(str(values['num_vehicule_dispo']))
print(str(values['num_chauffeur_dispo']))
return planning
tms_travel.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_tms_travel_tree" model="ir.ui.view">
<field name="name">tms.travel.tree</field>
<field name="model">tms.travel</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="date"/>
<field name="departure_id"/>
<field name="arrival_id"/>
<field name="state"/>
<button groups="tms.group_traffic,tms.group_expenses" icon="fa-thumbs-up" name="action_progress" states="draft" string="Dispatch Travel" type="object"/>
<button groups="tms.group_traffic,tms.group_expenses" icon="fa-check-square" name="action_end" states="progress" string="End Travel" type="object"/>
</tree>
</field>
</record>
</odoo>
Ok, you are missing some information in your many2many relationship. here is what you need.
field_name = fields.Manmy2many('related.model', 'relational_table', 'current_model_id', 'related_model_id', string='other information')
and usually I put the inverse on the related model ex:
(On the hr.holidays model)
payslip_ids = fields.Many2many('hr.payslip', 'hr_payslip_holiday_rel', 'holiday_id', 'payslip_id', ...)
(On the hr.payslip model)
holiday_ids - fields.Many2many('hr.holidays', 'hr_payslip_holiday_rel', 'payslip_id', 'holiday_id', ...)
Then at some point you need to add one of the ids to the other model for ex:
holiday.payslip_ids |= current_payslip_id

Not able to add columns to Document Library from Visual Studio template

I am trying to create new document library from SharePoint project template from Visual Studio 2015.
While doing so I am able to create Document Library Template and Instance. Also if I deploy solution to one of my site it creates list as well. Strange thing is if I add a column to the template and then deploy it creates the list but does not create new custom column.
Below is the schema file for the template.
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="SharedDocuments" Direction="$Resources:Direction;" Url="SharedDocuments" BaseType="1" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
<MetaData>
<ContentTypes>
<ContentType ID="0x0101000dba2955561e4de0a115152637e9f8e2" Name="ListFieldsContentType">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
<FieldRef ID="{4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e}" Name="TemplateUrl" />
<FieldRef ID="{cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64}" Name="xd_ProgID" />
<FieldRef ID="{fbf29b2d-cae5-49aa-8e0a-29955b540122}" Name="xd_Signature" />
<FieldRef ID="{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}" Name="Combine" />
<FieldRef ID="{5d36727b-bcb2-47d2-a231-1f0bc63b7439}" Name="RepairDocument" />
<FieldRef ID="{8f838bdc-4b95-4b26-b86f-3025d2df964f}" Name="TestColumn" />
</FieldRefs>
</ContentType>
<ContentTypeRef ID="0x0101">
<Folder TargetName="Forms/Document" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120" />
</ContentTypes>
<Fields>
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="$Resources:core,Title;" Sealed="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title"></Field>
<Field ID="{4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e}" Type="Text" Name="TemplateUrl" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Template_Link;" XName="TemplateUrl" Filterable="TRUE" Sortable="TRUE" Hidden="TRUE" FromBaseType="TRUE" PITarget="mso-infoPathSolution" PIAttribute="href" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="TemplateUrl"></Field>
<Field ID="{cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64}" Type="Text" Name="xd_ProgID" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Html_File_Link;" XName="ProgID" Filterable="TRUE" Sortable="TRUE" Hidden="TRUE" FromBaseType="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="xd_ProgID"></Field>
<Field ID="{fbf29b2d-cae5-49aa-8e0a-29955b540122}" Type="Boolean" Group="_Hidden" Name="xd_Signature" DisplaceOnUpgrade="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="xd_Signature" DisplayName="$Resources:core,Xml_signed;" XName="{FBF29B2D-CAE5-49aa-8E0A-29955B540122}" Filterable="TRUE" Sortable="TRUE" Sealed="TRUE" Hidden="TRUE" FromBaseType="TRUE" ReadOnly="TRUE"></Field>
<Field ID="{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}" ReadOnly="TRUE" Type="Computed" Name="Combine" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Merge;" Filterable="FALSE" Sortable="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Combine">
<FieldRefs>
<FieldRef Name="FSObjType" Key="Primary" />
<FieldRef Name="EncodedAbsUrl" />
<FieldRef Name="TemplateUrl" />
</FieldRefs>
</Field>
<Field ID="{5d36727b-bcb2-47d2-a231-1f0bc63b7439}" ReadOnly="TRUE" Type="Computed" Name="RepairDocument" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Relink;" Filterable="FALSE" Sortable="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="RepairDocument">
<FieldRefs>
<FieldRef Name="FSObjType" Key="Primary" />
<FieldRef Name="ID" />
</FieldRefs>
</Field>
<Field Name="TestColumn" ID="{8f838bdc-4b95-4b26-b86f-3025d2df964f}" DisplayName="TestColumn" Type="Text" />
</Fields>
<Views>
--Removed--
</Views>
<Forms>
<Form Type="DisplayForm" SetupPath="pages\form.aspx" Url="Forms/DispForm.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" SetupPath="pages\form.aspx" Url="Forms/EditForm.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="Forms/Upload.aspx" WebPartZoneID="Main" />
--Removed--
</Forms>
</MetaData>
</List>
When you upload a document in a Document Library there's an option for you to choose the Content Type, choose your custom Content Type and you'll see the fields you defined.

Why Wizard view cannot find the model?

i make a simple wizard in odoo and i want to show the wizard but, my model can't found of my view . what wrong with my simple code?
This my wizard
class RequestReceiveWizard(models.TransientModel):
_name ='estate.nursery.requestreceivewizard'
# def _default_session(self):
# return self.env['estate.nursery.requestline'].browse(self._context.get('request_id'))
name=fields.Char("Wizard name")
request_id=fields.Many2one('estate.nursery.request')
requestline_ids = fields.Many2many("estate.nursery.requestline")
And this my view :
<!--request Wizard -->
<record model="ir.ui.view" id="request_view_wizard">
<field name="name">Request receive wizard</field>
<field name="model">estate.nursery.requestreceivewizard</field>
<field name="arch" type="xml">
<form string="Wizard For Request Received">
<group collspan="2" col="2">
<field name="name"/>
<field name="requestline_ids"/>
</group>
<footer>
<button name="Apply" type="Action" string="Apply" >Apply</button>
<button special="cancel" string="Cancel">Cancel</button>
</footer>
</form>
</field>
</record>
<act_window id="received_request_wizard" name="Request Wizard"
src_model="estate.nursery.request"
res_model="estate.nursery.requestreceivewizard"
view_mode="form"
target="new"
multi="True" key2="client_action_multi"/>
What wrong with my simple code? And this my error
Model not found: estate.nursery.requestreceivewizard
act_window replace to this record and try this code:
<record id="received_request_wizard" model="ir.actions.act_window">
<field name="name">estate.nursery.request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">estate.nursery.request</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="request_view_wizard"/>
<field name="target">new</field>
</record>
May be It's work for you...

except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

i created a wizard and now its giving me the above error , it took me ages but couldn't sorted it , between am doing wizard for the first time in Openerp . please help thanks in advance . here is my code
class test_wizard(osv.osv_memory):
_name="test.wizard"
_description="will generate dynamic views, that's all"
_columns={
'age_text': fields.text('text age'),
}
def next(self,cr,uid,ids,contet=None):
test_obj=self.pool.get('test.chbc')
for wiz in self.browse(cr,uid,ids):
if wiz.age_text <=5:
raise osv.except_osv('user error, please slect something , know what')
limit= datetime.date.today()-datetime.timedelta(days=wiz.age_text)
ids_to_del=test_obj.search(cr,uid,[('create_date','<',
limit.striftime('%y-%m-%d 00:00:00'))],context=context)
test_obj.unlink(cr,uid,ids_to_del)
return{}
test_wizard()
here is my xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="test_wizard" model="ir.ui.view">
<field name="name">test.wizard.form</field>
<field name="model">test.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Test wizard ">
<label colspan="4" string="select age please , am in a hurry "/>
<field name="age_text" string="Age(days)"/>
<group col="4" colspan="4">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" name="next" string="Next" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_test_wizard" model="ir.actions.act_window">
<field name="name">Next</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">test.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
Change you model name mean give the name of the class where you want to put it
<field name="model">test.wizard</field>