Home Ask Login Register

Developers Planet

Your answer is one click away!

Shravya Shetty February 2016

How to get the following situation solved in odoo 8?

I am trying to print a many2many field value in qweb pdf report

Following is the code


class purchase_quotation(osv.Model):

        'name':fields.many2one('res.users','Name', readonly=True),
        'date':fields.date('Order Date', required=True),
        'vno':fields.char('Voucher No',size=40,readonly=1),
    ('blockA', 'Block A'),
        ('blockB', 'Block B'),
        ('admin', 'Admin'),

        ], 'Branch/Office', readonly= False, select=True, required=True),
        'approve_by':fields.char('Approved By'),
        'order_line': fields.one2many('product.text', 'pro_ref', 'Order Lines',required=True),


class purchase_order(osv.osv):
    _inherit = "purchase.order"
    _columns = {
            'vno_ref':fields.many2many('purchase.quotation', 'voch_ref' , string='Ref.Voucher No'),
            'spo':fields.many2one('res.users','Submit To', domain = [('is_approver','=',True)],),


code in qweb pdf report

<div class="col-xs-4 pull-right">
            <strong>Order Date:</strong>
            <p t-field="o.date_order" t-field-options='{"widget": "date"}'/>
            <strong>Ref Voucher No:</strong>
            <p t-field="o.vno_ref"/>

How can i display the values of many2many fields in the qweb pdf report. Anyone having an idea on this?Thanks


DaSaDiYa ChaiTAnYa February 2016

Just check the sale order report u will find the best solution for you

I sale order line having the tax_id which is part of many2many field.

You can access that field using below way

<tr t-foreach="o.order_line" t-as="l">
         <span t-esc="', '.join(map(lambda x: x.name, l.tax_id))"/>

same way you can implement that field on your own way for your Qweb View report rendering and then after check to print your PDF report

I hope my answer may helpful for you :)

Post Status

Asked in February 2016
Viewed 1,503 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life