This question has been flagged
2 Replies
4309 Views

Good day everyone,

usind this code I've added a related custom field inheriting a odoo module repair.order and is working fine and the field is properly added to the table in the database.

class RepairOder(models.Model):
    _inherit = 'repair.order'
    sale_order_name = fields.Char(related='service_sale_order_id.name', copy=False, readonly=True, store=True)


Then using this code added a related custom field inheriting repar.fee to point to repair.order custom field

class RepairFee(models.Model):
    _inherit = 'repair.fee'
    so_name = fields.Char(related='repair_id.sale_order_name',readonly=True,store=True)


but it always throws the following error.

self._setup_related_full(model)
 File "/odoo13c/odoo13c-server/odoo/fields.py", line 486, in _setup_related_full
   field = target._fields[name]
KeyError: 'sale_order_name'

Any idea what could b wrong with this code?  thanks in advance


Avatar
Discard
Best Answer

Hi Avash,

Please try this,

class Repair(models.Model):

    _inherit = 'repair.order'

    sale_order_name = fields.Char(related='your_custom_field.name',

                                  copy=False, readonly=True, store=True)

class RepairFee(models.Model):

    _inherit = 'repair.fee'

       so_name = fields.Char(related='repair_id.sale_order_name',readonly=True,store=True)

Added dependency in manifest file for 'repair' module and update the module.

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Discard
Author Best Answer

Hello Jainesh, thanks for reply

Dependency is already on manifest, but still shows same error.   weird cuz if I define another related field to existing repair standar field no error for those fields. so it looks like errors only with custom fields defined in repair model.

for example these 3 related fields works just fine.

class RepairFee(models.Model):
    _inherit = 'repair.fee'
    currency_id = fields.Many2one(related='repair_id.pricelist_id.currency_id',readonly=True,store=True)
    user_id = fields.Many2one(related='repair_id.user_id',readonly=True,store=True)
    date_repair = fields.Datetime(related='repair_id.date_repair',readonly=True,store=True)





Avatar
Discard