Hi all.
I am loosing my hair in a so simple operation.
In ResPartner I have name like "corp_town1" , "corp_town2"
I want to create a new compte field split_name who'll contain
name.split('_')[0] (only corp)
from odoo import models, fields, api
class ResPartner(models.Model):
_inherit = 'res.partner'
split_name = fields.Char(compute="_split_name", store=True)
#
@api.depends('name')
def _split_name(self):
for r in self:
if not r.name:
r.split_name=""
else:
init_name=r.name
self.split_name = init_name.split('_')[0]
Any help welcome
regards