Skip to Content

Contributors

Re: Please share your thoughts on the use of `x_` prefix for custom fields in Odoo

I think only Elon Musk needs to use "x_" to identify a field...

Il giorno lun 17 giu 2024 alle ore 13:43 Pedro M. Baeza <notifications@odoo-community.org> ha scritto:
IMO, that prefix must only apply to fields created through UI / Odoo Studio, not on community modules. And if you have to maintain that DB, I advise you to forbid both Odoo Studio and manual field creation.

Regards.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe



--

Francesco Apruzzese

Profilo professionale: http://it.linkedin.com/in/francescoapruzzese

Il contenuto di questo messaggio elettronico è riservato e tutelato dal segreto professionale ed è rivolto esclusivamente al/ai destinatario/i identificato/i. Pertanto è proibito leggerlo, copiarlo, divulgarlo o utilizzarlo da parte di chiunque salvo il/i destinatario/i. Se non siete il destinatario, vi invitiamo a cancellare il messaggio ed eventuali allegati dandocene immediatamente comunicazione scritta a mezzo posta elettronica.
This e-mail and any attachments are confidential and may contain information intended for the addressee(s) only. Reading, copying, disclosure or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail.

Non stampare questa email se non strettamente necessario. Aiuta te ed aiuta l'ambiente.


by Francesco Apruzzese - 01:56 - 17 Jun 2024

Reference

  • Please share your thoughts on the use of `x_` prefix for custom fields in Odoo

    Hello Odoo contributors,

    I'd love to hear your opinion on whether or not one should consistently prefix custom fields and models with `x_`. While there are valid reasons to do so, this convention is either not general or often overlooked in the community. Please share your insights on ir ir when it is required and why it may be missing from some guidelines (e.g., https://www.odoo.com/documentation/17.0/contributing/development/coding_guidelines.html#). I'd really love discuss this topic to enhance our common understanding and best practices in the Odoo ecosystem. Thank you for sharing your opinions

    Best regards,
    Frederik

    Hint: Daniel Reis for instance claims "The field name field entry must start with the x_ prefix. This is mandatory for models and fields created from the developer tools. Customizations made through addon modules don't have this limitation."  in https://subscription.packtpub.com/book/business-and-other/9781800200067/2/ch02lvl1sec09/adding-a-custom-field-to-a-model and Odoo itself pretends "Custom model names must start with x_."  in https://www.odoo.com/documentation/17.0/developer/reference/external_api.html but leaves the convention unaddressed in https://www.odoo.com/documentation/17.0/contributing/development/coding_guidelines.html#

    For whom it may concern: SAP is requiring similar prefixes since very early versions of its ABAP programming and costumization iterface https://help.sap.com/doc/saphelp_snc700_ehp01/7.0.1/en-US/c5/e4ade6453d11d189430000e829fbbd/content.htm?no_cache=true

    -- 
    Dr.-Ing. Frederik Kramer
    Geschäftsführer
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel:   +49 (0) 4181 13503 12
    Fax:   +49 (0) 4181 13503 10
    Mobil: +49 (0) 179 3901819
    
    Email: frederik.kramer@initos.com
    Internet: www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht Tostedt, HRB 205226
    USt-IdNr.: DE815580155
    Steuer-Nr: 15/200/53247

    by Frederik Kramer - 12:16 - 17 Jun 2024