跳至內容
選單
此問題已被標幟
1 回覆
275 瀏覽次數

Hello,

I have a question regarding custom fields in Odoo:

  1. I initially created some custom fields using Odoo Studio, and these fields already contain data.
  2. A developer advised me that it’s better to create a custom module for new fields, so that the environment is consistent across all my Odoo instances.
  3. I don’t want to delete the Studio-created fields since they already hold values. Instead, I have recreated the same fields in a custom module.



Is there a risk of conflict when deploying the custom module, given that the fields already exist in the database from Studio? 


Additionally, when deploying the fields through the module, I am seeing this warning:

WARNING server Field sale.order.line.x_custom_field: unknown parameter 'tracking', if this is an actual parameter you may want to override the method _valid_field_parameter on the relevant model in order to allow it

  • What does this warning mean, and how should I resolve it when moving fields from Studio to a custom module?


Any guidance or best practices for safely migrating Studio fields to a custom module would be greatly appreciated!


Thank you

頭像
捨棄
作者

Thanks for your confirmation !


最佳答案

Hi,


Moving a Studio Char field (x_custom_field) from Studio → custom module


Python Code:

from odoo import models, fields


class SaleOrderLine(models.Model):

    _inherit = "sale.order.line"


    # This redeclares the Studio field

    x_custom_field = fields.Char(

        string="Custom Field",

        tracking=True

    )



If your model doesn’t use chatter (no mail.thread):


Remove tracking=True to avoid the warning:


Python Code:

from odoo import models, fields


class SaleOrderLine(models.Model):

    _inherit = "sale.order.line"


    x_custom_field = fields.Char(string="Custom Field")


As long as the field name (x_custom_field) and type (Char, Many2one, etc.) match what Studio made, Odoo will reuse the same DB column and your data is safe.


Hope it helps.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
10月 23
4351
0
6月 22
23
4
6月 25
4045
3
9月 24
1661
0
11月 23
1646