Shravy
Shravy

Reputation: 666

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

purchase_quotation.py

class purchase_quotation(osv.Model):

    _name="purchase.quotation"
    _rec_name='vno'
    _columns={
        'name':fields.many2one('res.users','Name', readonly=True),
        'date':fields.date('Order Date', required=True),
        'vno':fields.char('Voucher No',size=40,readonly=1),
        'branch':fields.selection([
    ('blockA', 'Block A'),
        ('blockB', 'Block B'),
        ('admin', 'Admin'),

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

purchase_order.py

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"/>
</div>

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

Upvotes: 0

Views: 737

Answers (1)

DASADIYA CHAITANYA
DASADIYA CHAITANYA

Reputation: 2892

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">
     <td>
         <span t-esc="', '.join(map(lambda x: x.name, l.tax_id))"/>
     </td>
</tr>

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 :)

Upvotes: 1

Related Questions