Search code examples
odoo-10invoice

internal reference of the product did not add to the invoice report in odoo 10


I add internal reference of product to the sale form and I want it in the invoice report also

the sale code is :

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'
    _name = 'sale.order.line'
    x_field = fields.Float('Unit cost')


internal_ref=fields.Char(related='product_id.default_code',string='Internal 
reference product',store=True,default=100)
    partner_name=fields.Many2one('res.partner','partner_id.name')

this is my code but did not work

the python code:

class invoiceLineField(models.Model):
    _inherit='account.invoice.line'
 internal_ref=fields.Char(related='product_id.default_code',string='Internal 
               reference product',store=True)

and this is xml report:

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<data>

<template id="report_invoice_document_itemnumber"

inherit_id="account.report_invoice_document">

<xpath expr="//div[contains(@class, 'page')]/table[1]/thead/tr/th[1]" 
position="before">

<th>Internal reference</th>

</xpath>

<xpath expr="//div[contains(@class, 'page')]/table[1]/tbody/tr/td[1]" 
position="before">

<td>

<span t-field="l.internal_ref"/>

</td>

</xpath>

</template>

</data>

</odoo>

no error but the internal reference of product did not appear in the result


Solution

    • If you want the 'default_code' field just to print in report then you can achieve it by 'product_id.default_code'.

    <span t-field="l.product_id.default_code"/>