2017-03-09 82 views
0

我不明白爲什麼我無法在Odoo中成功擴展此視圖。我試圖向銷售儀表板上的看板卡中的某個按鈕添加一些內容。在Odoo中擴展視圖不工作

基本視圖是crm.team.dashboard,並具有以下結構:

<?xml version="1.0"?> 
<kanban class="oe_background_grey o_kanban_dashboard o_salesteam_kanban" create="0" js_class="sales_team_dashboard"> 
       <field name="name"/> 
       <field name="user_id"/> 
       <field name="member_ids"/> 
       <field name="color"/> 
       <templates> 
        <t t-name="kanban-box"> 
         <div t-attf-class="#{kanban_color(record.color.raw_value)}"> 
          <div class="o_kanban_card_header"> 
           <div class="o_kanban_card_header_title"> 
            <div class="o_primary"><field name="name"/></div> 
           </div> 
           <div class="o_kanban_manage_button_section"> 
            <a class="o_kanban_manage_toggle_button" href="#">More <i class="fa fa-caret-down"/></a> 
           </div> 
          </div> 
          <div class="container o_kanban_card_content o_visible"> 
           <div class="row"> 
            <div class="col-xs-6 o_kanban_primary_left" name="to_replace_in_sale_crm"> 
            </div> 
            <div class="col-xs-6 o_kanban_primary_right"> 
            </div> 
           </div> 
          </div><div class="container o_kanban_card_manage_pane o_invisible"> 
           <div class="row"> 
            <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_view"> 
             <div class="o_kanban_card_manage_title"> 
              <span>View</span> 
             </div> 
            </div> 
            <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_new"> 
             <div class="o_kanban_card_manage_title"> 
              <span>New</span> 
             </div> 
            </div> 
            <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_reports"> 
             <div class="o_kanban_card_manage_title"> 
              <span>Reports</span> 
             </div> 
            </div> 
           </div> 

           <div t-if="widget.editable" class="o_kanban_card_manage_settings row" groups="sales_team.group_sale_manager"> 
            <div class="col-xs-8"> 
             <ul class="oe_kanban_colorpicker" data-field="color"/> 
            </div> 
            <div class="col-xs-4 text-right"> 
             <a type="edit">Settings</a> 
            </div> 
           </div> 
          </div> 
         </div> 
        </t> 
       </templates> 
      </kanban> 

有延伸這一個,增加了原來的「報價」按鈕,看板卡片的圖。這是crm.team.kanban視圖,它具有以下結構:

<?xml version="1.0"?> 
<data> 
      <xpath expr="//templates" position="before"> 
       <field name="use_quotations"/> 
       <field name="use_invoices"/> 
       <field name="invoiced"/> 
       <field name="invoiced_target"/> 
       <field name="currency_id"/> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_primary_right')]" position="inside"> 
       <div class="row mb4" t-if="record.use_invoices.raw_value"> 
        <div class="col-xs-8"> 
         <a name="266" type="action"> 
          Sales to Invoice 
         </a> 
        </div> 
        <div class="col-xs-4 text-right"> 
         <field name="sales_to_invoice_amount" widget="monetary"/> 
        </div> 
       </div> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_primary_left')]" position="inside"> 
       <button class="btn btn-primary" name="267" type="action">Quotations</button> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_primary_right')]" position="after"> 
       <div t-if="record.invoiced_target.raw_value" class="col-xs-12 o_kanban_primary_bottom" groups="sales_team.group_sale_manager"> 
        <field name="invoiced" widget="progress" title="Invoicing" options="{'current_value': 'invoiced', 'max_value': 'invoiced_target', 'editable': true, 'edit_max_value': true, 'on_change': 'update_invoiced_target'}"/> 
       </div> 
       <div t-if="!record.invoiced_target.raw_value" class="col-xs-12 o_kanban_primary_bottom text-center" groups="sales_team.group_sale_manager"> 
        <a href="#" class="sales_team_target_definition o_inline_link">Click to define a team target</a> 
       </div> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_manage_view')]" position="inside"> 
       <t t-if="record.use_quotations.raw_value"> 
        <div> 
         <a name="267" type="action" class="o_quotation_view_button">Quotations</a> 
        </div> 
        <div> 
         <a name="265" type="action">Sales Orders</a> 
        </div> 
       </t> 
       <div t-if="record.use_invoices.raw_value" groups="account.group_account_invoice"> 
        <a name="268" type="action">Invoices</a> 
       </div> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_manage_new')]" position="inside"> 
       <div t-if="record.use_quotations.raw_value"> 
        <a name="272" type="action"> 
         Quotation 
        </a> 
       </div> 
      </xpath> 

      <xpath expr="//div[contains(@class, 'o_kanban_manage_reports')]" position="inside"> 
       <t t-if="record.use_quotations.raw_value"> 
        <div> 
         <a name="269" type="action"> 
          Quotation 
         </a> 
        </div> 
        <div> 
         <a name="270" type="action"> 
          Sales 
         </a> 
        </div> 
       </t> 
       <div t-if="record.use_invoices.raw_value" groups="account.group_account_invoice"> 
        <a name="271" type="action"> 
         Invoices 
        </a> 
       </div> 
      </xpath> 

     </data> 

我的目標是在「語錄」按鈕添加一些額外的文本,所以說像「語錄(10)」。我創建了一個名爲x_crm.team.dashboard新的觀點,即從crm.team.dashboard繼承,並賦予它以下結構:

<?xml version="1.0"?> 
<data> 
    <xpath expr="//div[contains(@class, 'o_kanban_primary_left')]/button" position="inside"> 
     Quotations (Test) 
    </xpath> 
</data> 

然而,當我查看儀表盤,我的更改不會出現。我只看到原來的「報價」按鈕。我過去已經擴大了看法,它運行良好,但在這種情況下我似乎錯過了一些東西。

有沒有人有任何想法我做錯了什麼?

回答

0

試試這個

與ID crm.team.kanban

<xpath expr="//button[@name='267']" position="replace"> 
    <button class="btn btn-primary" name="267" type="action">Quotations (Test)</button> 
</xpath> 
+0

看起來問題實際上是我試圖在按鈕元素中使用'position =「裏面的''。 Odoo似乎不喜歡那樣。如果我保持一切並使用'position = replace',它就可以工作。我試圖避免重複按鈕的代碼來替換它,但似乎這是實現它的唯一方法。 – flyingL123

0

這結束了對我的工作擴展視圖。擴展crm.team.dashboard

<xpath expr="//div[contains(@class, 'o_kanban_primary_left')]/button" position="replace"> 
    <button class="btn btn-primary" name="267" type="action">Pending Orders (Test)</button> 
</xpath>