Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
855 Widoki

I want to extend the crm_lead_view_form and add certain customer data in a new tab.

My problem is that the custumer field is not mandatory, so I get an error when upgrading if there are leads without customer.

Is it possible with xml-attributes/options to load partner_id.new_custom_field only if partner_id is set?

Using Odoo 16.0 Enterprise Edition on odoo.sh and Docker (developing)


Awatar
Odrzuć
Najlepsza odpowiedź

Hi, 

If you're facing an error because the field new_custom_field does not exist in the crm.lead model, you need to add the field to the model and then use the related attribute to link it to the corresponding field in the res.partner model. Here's how you can modify your model:Add the new_custom_field field to the crm.lead model. Make sure to adjust the field type based on your requirements.from odoo import models, fields

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

    new_custom_field = fields.Char(string='New Custom Field', related='partner_id.new_custom_field')By using the related attribute, the new_custom_field in crm.lead will now get its value from the corresponding field in the res.partner model. Make sure to adapt the code according to your actual field types and requirements. 


Hope it helps

Awatar
Odrzuć