Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3288 Lượt xem

Hello,


when I print my invoice report, I has on each line with line.origin the value for the delivery report:

Example: "WH/OUT/00215"
It takes from account_invoice_line


Now I want to add in this report, the date of the delivery.
stock_picking.date_done with ID stock_picking.name


How can I add this database value?

As SQL is "Select date_done from stock_picking where name = 'line.origin'


Thank you

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hii,

Extend the Report Template (QWeb)

Since QWeb can’t run SQL, you use a t-set with env to perform a model search.

Inside the loop that renders invoice lines (usually in a t-foreach="o.invoice_line_ids"), add:

<t t-set="picking" t-value="env['stock.picking'].search([('name', '=', line.origin)], limit=1)"/>

<t t-if="picking">

    <span>Delivered on: <t t-esc="picking.date_done.strftime('%d/%m/%Y')"/></span>

</t>

If the line.origin matches a stock.picking.name, the delivery date (date_done) will be printed on the invoice line.

Example Final Snippet:

<tr t-foreach="o.invoice_line_ids" t-as="line">

  <td>

    <t t-esc="line.name"/>

    <t t-set="picking" t-value="env['stock.picking'].search([('name', '=', line.origin)], limit=1)"/>

    <t t-if="picking">

        <br/>

        <small>Delivered on: <t t-esc="picking.date_done.strftime('%d/%m/%Y')"/></small>

    </t>

  </td>

  <!-- other columns like quantity, price, etc. -->

</tr>


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 6 17
9032
5
thg 11 16
6881
0
thg 8 16
5120
2
thg 6 16
3865
2
thg 12 24
4260