İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1084 Görünümler

I have created Page inside crm known "Product Info" alongside with 3 fields: combined_name, product_image and file. So, I try click inside file filed line, a button appeared: "Upload Your File". But It only appear when I click inside the blank filed. Else it remain invisible. So how can i solve it?
here my .xml code:

   

        wise.crm.lead.form.inherit

        crm.lead

       

       

           

               

               

               

                   

                  

                   

                   

                   

               

           

       

       

   

   


Avatar
Vazgeç
En İyi Yanıt

Hi 

You can try this code,


for  fields (python file)
from odoo import models, fields

class CrmLead(models.Model):
    _inherit = 'crm.lead'

    combined_name = fields.Char(string='Combined Name')
    file_attachment = fields.Binary(string='File Attachment', attachment=True)
    file_name = fields.Char(string='File Name')
    product_image = fields.Binary(string='Product Image', attachment=True)

and add function

def upload_file_action(self):
        return {
            'name': 'Upload File',
            'type': 'ir.actions.act_window',
            'view_mode': 'form',
            'view_id': self.env.ref('your_module_name.upload_file_wizard_form_view').id,
            'view_type': 'form',
            'res_model': 'your.module.upload.file.wizard',
            'target': 'new',
            'context': {'default_lead_id': self.id}
        }

xml file:

<record id="view_crm_lead_form" model="ir.ui.view">

    <field name="name">crm.lead.form.inherit</field>

    <field name="model">crm.lead</field>

    <field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>

    <field name="arch" type="xml">

        <xpath expr="//sheet/notebook" position="inside">

            <page string="Product Info">

                <field name="combined_name"/>

                    <field name="file_attachment" widget="binary" filename="file_name"/>

                    <field name="product_image" widget="image" class="oe_left oe_avatar"/>

                    <button string="Upload File" type="object" name="upload_file_action" class="oe_highlight"/>

            </page>

            

        </xpath>

    </field>

</record>


Hope it helps

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 24
1384
1
Oca 24
1176
2
Oca 24
1213
2
Ağu 25
1068
0
May 25
603