Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7161 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
jsonb_path_query_array error แก้ไขแล้ว
1
มิ.ย. 24
3473
5
ธ.ค. 19
6524
1
มี.ค. 15
4617
2
ก.พ. 24
1112
1
ส.ค. 23
2641