This question has been flagged
1 Reply
22576 Views

I'm using odoo 9 and I want to add two customized fields RC and Code_TVA in a report for the partner information . I have added Rc and Code_TVA in t-field-options but there is no difference. Any Help please ??

partner_view.xml

<?xml version="1.0" encoding="utf-8"?>
 <openerp>
 <data>
  <record id="res_partner_view_purchase_buttons_TVA_RC" model="ir.ui.view">
    <field name="name">num.TVA.RC.res.partner.view.purchase.</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='website']" position="after">
                    <field name="Code_TVA" select="1" placeholder="Code TVA"/>
                    <field name="RC" select="1" placeholder="Num RC"/>
        </xpath>
    </field>
  </record>
</data>
</openerp>

Partner.py

 # -*- coding: utf-8 -*-
 from openerp import fields,models,api
 from openerp import tools

 import openerp.addons.decimal_precision as dp
 from openerp.tools.translate import _


 class partner(models.Model):
 _inherit = 'res.partner'
 Code_TVA = fields.Char(string="Code de TVA")
 RC = fields.Char(string="Num Registre de Commerce") 

purchase_report.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
   <template id="report_purchasequotation_document" inherit_id="purchase.report_purchasequotation_document">
     <xpath expr="//div[@class='col-xs-5 col-xs-offset-1']" position="replace">
     <div class="col-xs-5 col-xs-offset-1">
            <div t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;, &quot;phone&quot;, &quot;fax&quot;, &quot;Code_TVA&quot;, &quot;RC&quot;], &quot;no_marker&quot;: true, &quot;phone_icons&quot;: true}"/>
                <p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>

        </div>

     </xpath>

</template>
Avatar
Discard
Best Answer

Hello Dhouha,

You can write as following to display fields of partner with partner address

<div class="col-xs-5 col-xs-offset-1">
	<div t-field="o.partner_id"
		t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true, "phone_icons": true}'/>
		<p t-if="o.partner_id.Code_TVA">Code_TVA: <span t-field="o.partner_id.Code_TVA"/></p>
		<p t-if="o.partner_id.RC">RC: <span t-field="o.partner_id.RC"/></p>
		<p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
		
</div>

Thanks,



Avatar
Discard
Author

It works thank yo very much