This question has been flagged

Hi,

I am trying to create a new report in the sale.order object that only print if the shipment is done. To do that I need to acces to another object, the --> "stock.picking" and confirm that the field "state" is set to "done".


 I need to make and "if" statement and acces to this variable any place of the next .xml report that is the one who create the report:


<odoo>
<data>
<report id="report_albaran_template"
string="Imprimir albarán"
model="sale.order"
report_type="qweb-pdf"
name="print_albaran_from_confirmed_order.report_albaran_template"
print_report_name="'A- %s' % (object.name)"

/>

<template id="report_albaran_template_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//h2[@class='mt16']" position="replace">
<h2 class="mt16">
<span t-if="doc.state in ['sent']">Albarán # </span>
<span t-field="doc.name"/>
</h2>
</xpath>
</template>

<template id="report_albaran_template" inherit_id="sale.report_saleorder">
<xpath expr='//t[@t-call="sale.report_saleorder_document"]' position="replace">
<t t-call="print_albaran_from_confirmed_order.report_albaran_template_document" t-lang="doc.partner_id.lang"/>
</xpath>
</template>

</data>
</odoo>

Do I need to do that from xml, as I saw in the "sale.order.state" with "order" and "quotation" labels for the report? or you suggest another way to do that?


How can I acces to another model? if the "doc" variable of the .xml is pointing to the "sale.order" object.


Thanks and regards,

 Amadeo

Avatar
Discard