代码之家  ›  专栏  ›  技术社区  ›  Dhouha

如何在QWeb报表中自定义合作伙伴T字段选项

  •  0
  • Dhouha  · 技术社区  · 6 年前

    我正在使用odoo 9,我想添加两个自定义字段 钢筋混凝土 代码tva 在报告中提供合作伙伴信息。我已经添加了rc和code_tva T字段选项 但没有区别。有什么帮助吗??

    合作伙伴视图.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>
    

    合作伙伴.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") 
    

    采购报告.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>
    

    1 回复  |  直到 6 年前
        1
  •  1
  •   Dhouha    6 年前

    我找到答案了

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