Replace shipment qty decimal from Double

This commit is contained in:
Raimon Esteve 2017-06-09 10:47:41 +02:00
parent 707f3a7cde
commit d7d879efc3
2 changed files with 29 additions and 5 deletions

View file

@ -7,7 +7,7 @@
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/"]]></defaultValueExpression>
</parameter>
<parameter name="TAXES_DS" class="java.lang.Object"/>
<parameter name="shipment_qty_decimal" class="java.lang.Boolean"/>
<queryString language="xPath">
<![CDATA[]]>
</queryString>
@ -68,7 +68,7 @@
<field name="product-rec_name" class="java.lang.String">
<fieldDescription><![CDATA[/data/record/outgoing_moves-outgoing_moves/product-product/rec_name-rec_name]]></fieldDescription>
</field>
<field name="quantity-quantity" class="java.lang.String">
<field name="quantity-quantity" class="java.lang.Double">
<fieldDescription><![CDATA[/data/record/outgoing_moves-outgoing_moves/quantity-quantity]]></fieldDescription>
</field>
<field name="unit_price-unit_price" class="java.lang.Number">
@ -357,7 +357,15 @@
<textElement textAlignment="Left">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{quantity-quantity} ? $F{company-shipment_qty} ? (int)Double.valueOf($F{quantity-quantity}.trim()).doubleValue() : Double.valueOf($F{quantity-quantity}.trim()).doubleValue() : '0']]></textFieldExpression>
<textFieldExpression><![CDATA[$F{quantity-quantity} != null && $F{quantity-quantity} != ""
?
$P{shipment_qty_decimal} == true
?
String.format("%.2f", $F{quantity-quantity})
:
String.valueOf($F{quantity-quantity}).split("\\.")[0]
:
""]]></textFieldExpression>
</textField>
<textField>
<reportElement x="416" y="2" width="72" height="12" uuid="ec43897a-bf45-4166-a66f-cc89b2c9996e"/>

View file

@ -1,12 +1,28 @@
# This file is part jasper_reports module for Tryton.
# This file is part stock_delivery_note_valuer_jreport module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.pool import Pool
from trytond.pool import PoolMeta
from trytond.modules.jasper_reports.jasper import JasperReport
__all__ = ['DeliveryNoteValued']
__metaclass__ = PoolMeta
class DeliveryNoteValued(JasperReport):
__metaclass__ = PoolMeta
__name__ = 'stock.shipment.out.delivery_note_valued'
@classmethod
def execute(cls, ids, data):
pool = Pool()
Config = pool.get('stock.configuration')
config = Config(1)
parameters = {
'shipment_qty_decimal': config.shipment_qty_decimal or False
}
if 'parameters' in data:
data['parameters'].update(parameters)
else:
data['parameters'] = parameters
return super(DeliveryNoteValued, cls).execute(ids, data)