Skip to Content
Menu
This question has been flagged
1 Reply
5413 Views

Hi,

I've added a new field to the database and have it displaying on the res.partner form. However, I wish to change the format and despite trying to figure it out by researching the web, I find I need some help.

The form code looks like this

...

<field name="x_NewspaperCopies"/>
<field name="x_ID"/>
...

The x_ID displays as for example 1,234 on the form.

I would like it to display ABC-00001234 as an example.

A hard prefix of ABC and the integer x_ID displayed as a number with 4 leading 0's.

This is a once only display request throughout the whole system and is only required on this one view.

Can anyone help me and show me how to use the format syntax for the x_ID field (Integer).

The version of Odoo is 10 Community

Thanks

Avatar
Discard
Best Answer

Hi,

you can use Char field for displaying your format. EIther you can keep the integer field for storing id and display it in Char field.

eg:

x_id_formated = fields.Char()
@api.onchange('x_id')
def onchange_x_id(self):
    """ """
    if self.x_id:
        self.x_id_formated = "ABC-0000{id}".format(id=self.x_id)


Avatar
Discard