答案 0 :(得分:0)
这个问题有两次机会:
解决方案:
答案 1 :(得分:0)
请尝试以下代码:
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)
答案 2 :(得分:0)
对于第一个问题,您的操作定义中缺少字段名称。
<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 -->
答案 3 :(得分:0)
您只需在对象中添加“name”字段即可获得解决方案......