Odoo10 - 如何删除表单视图中的模块名称? (参考下图)

Odoo10 - How to remove the module name in form view ? (Refer below picture)

如何在odoo 10的销售订单中删除编号1中的模块名称并将其更改为其他默认名称加上像So015这样的id

这个问题有两种可能:

  1. "name" 字段留空或
  2. 表单中没有 "name" 字段。

解决方案:

  1. 声明一个名为 "name" 或
  2. 的字段
  3. 使用“_rec_name”来克服这个错误。

请试试这个代码:

class Project(models.Model):
    _name = 'reg.project'

    name = fields.Char(string='Project Name', unique = True, required=True)

或此代码:

class Project(models.Model):
    _name = 'reg.project'
    _rec_name = 'sr_no'

    sr_no = fields.Char(string='Project Name', unique = True, required=True)

对于第一个问题,它是您的操作定义中缺少字段 name

<field name="name">Custom Shipping</field>

因此您必须确保您对此类模型的操作如下:

<!-- ACTION WINDOW FOR CUSTOM_SHIPPING.MODELS -->
<record id="action_custom_shipping_models" model="ir.actions.act_window">
  <field name="name">Custom Shipping</field>
  <field name="type">ir.actions.act_window</field>
  <field name="res_model">custom_shipping.models</field>
  <field name="view_type">form</field>
  <field name="view_mode">tree,form</field>
</record>
<!-- ACTION WINDOW FOR CUSTOM_SHIPPING.MODELS -->

要解决第二个问题,您可能需要以下定义

class custom_shipping(models.Model):
    _name = 'custom_shipping.models'
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _rec_name = 'sr_no'

    sr_no = fields.Char(string='Project Name', default='New' ,required=True)

    @api.model
    def create(self, vals):
        if vals.get('sr_no', 'New') == 'New':
            vals['sr_no'] = self.env['ir.sequence'].next_by_code('custom_shipping.number') or '/'
    return super(custom_shipping, self).create(vals)

除了这个xml

<!-- SEQUENCE FOR CUSTOM_SHIPPNIG.MODELS -->
<record id="seq_custom_shipping_models" model="ir.sequence">
  <field name="name">Custom Shipping Number</field>
  <field name="code">custom_shipping.number</field>
  <field name="prefix">SO</field>
  <field name="padding">5</field>
  <field name="company_id" eval="False"/>
</record>
<!-- SEQUENCE FOR CUSTOM_SHIPPNIG.MODELS -->

您只需在您的对象中添加 "name" 字段并获得您的解决方案...