Odoo Help


how fill zeros at left in a field in Odoo

Crysler Belisario Araujo Enoc
on 5/9/15, 5:12 PM 930 views

Hi, my question is about  how fill zeros at left in a field before save into BD...

my class:

class cliente(models.Model):

_inherit = 'res.partner'

Documento=fields.Selection((('V','V'),('E','E'),('J','J'),('P','P'),('G','G')),size=2, help="V=Venezolana , E= Extranjera , J= Juridico , P=Personal , G=Gubernamental", required=True)

cedula=fields.Char(size=11,default=None,string="Cedula De Identidad", help="acredita la identidad",required=True)

my views

<?xml version="1.0" encoding="UTF-8"?>




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

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_form"/>

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



<field name="Documento"/>

<field name="cedula"/>






<!-- este es un acceso directo a la barra principal del menu-->

<menuitem id="menucontactos" name="Contactos"/>

<record model="ir.actions.act_window" id="contact_list_action">

<field name="name">Contactos de la Empresa</field>

<field name="res_model">res.partner</field>

<field name="view_mode">tree,form</field>


<menuitem id="configuration_menu" name="Configuraciones"


<menuitem id="contact_menu" name="Contacts"






my idea is when press save button, fill zeros at left in a field cedula, Example:

anybody write 123 in field cedula:

cedula<= 123

then press save button



save into DB 00000123, not 123...

Thank you :D


Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 5 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 5/12/15, 4:17 AM

You could either use WRITE/CREATE method or on_change(preferable) method as Ahmed mentioned

cedula = 123
print '{0:08d}'.format(i)

--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 5/11/15, 4:12 AM

Hi, you can mange this with on_change method..

Regards ..

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 5/9/15, 5:12 PM
Seen: 930 times
Last updated: 5/12/15, 4:17 AM