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

The operation cannot be completed, probably due to the following:


- deletion: you may be trying to delete a record while other records still reference it -


creation/update: a mandatory field is not correctly set


[object with reference: name - name]




class Employee(models.Model):




    _name = "hr.employee"


    _description = "Employee"


    _order = 'name_related'


    _inherits = {'resource.resource': "resource_id"}


    # _inherit = 'res.partner'


    _inherit = ['mail.thread']


    _inherit = 'res.partner'


    firstname = fields.Char("First name")


    lastname = fields.Char("Last name")


    name = fields.Char(compute='comp_name', store=True)


    @api.depends('firstname','lastname')


    def comp_name(self):


        self.name = (self.firstname or '')+' '+(self.lastname or '')




 can i get any solution please??

頭像
捨棄
最佳答案

This because name is defined as required in Python, you can try these two solution

1- Make default value for field name, Example :

_defaults = {

        'name': '/',

        }


2- Check your function:  comp_name

頭像
捨棄
作者 最佳答案

I'm using version odoo 10. so,  what will be the exact thing for the  [object with reference: name - name]


thank you

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
6月 24
3480
5
12月 19
6529
1
3月 15
4619
2
2月 24
1114
1
8月 23
2642