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