
from odoo import fields, models


class MrpBom(models.Model):
    _inherit = "mrp.bom"

    location_id = fields.Many2one(
        related='picking_type_id.default_location_dest_id',
        store=True,
    )


class MrpBomLine(models.Model):
    _inherit = "mrp.bom.line"

    location_id = fields.Many2one(
        related='bom_id.picking_type_id.default_location_src_id',
        store=True,
    )


from odoo import fields, models


class MrpBom(models.Model):
    _inherit = "mrp.bom"

    location_id = fields.Many2one(
        related='picking_type_id.default_location_dest_id',
        readonly=True,
        store=True,
    )


class MrpBomLine(models.Model):
    _inherit = "mrp.bom.line"

    location_id = fields.Many2one(
        related='bom_id.picking_type_id.default_location_src_id',
        readonly=True,
        store=True,
    )

Make the related location readonly
[IMP] Make the related location readonly

  
  from odoo import fields, models
  
  
  class MrpBom(models.Model):
      _inherit = "mrp.bom"
  
      location_id = fields.Many2one(
          related='picking_type_id.default_location_dest_id',
+         readonly=True,
          store=True,
      )
  
  
  class MrpBomLine(models.Model):
      _inherit = "mrp.bom.line"
  
      location_id = fields.Many2one(
          related='bom_id.picking_type_id.default_location_src_id',
+         readonly=True,
          store=True,
      )
  
Make the related location readonly
## Code Before:

from odoo import fields, models


class MrpBom(models.Model):
    _inherit = "mrp.bom"

    location_id = fields.Many2one(
        related='picking_type_id.default_location_dest_id',
        store=True,
    )


class MrpBomLine(models.Model):
    _inherit = "mrp.bom.line"

    location_id = fields.Many2one(
        related='bom_id.picking_type_id.default_location_src_id',
        store=True,
    )

## Instruction:
Make the related location readonly
## Code After:

from odoo import fields, models


class MrpBom(models.Model):
    _inherit = "mrp.bom"

    location_id = fields.Many2one(
        related='picking_type_id.default_location_dest_id',
        readonly=True,
        store=True,
    )


class MrpBomLine(models.Model):
    _inherit = "mrp.bom.line"

    location_id = fields.Many2one(
        related='bom_id.picking_type_id.default_location_src_id',
        readonly=True,
        store=True,
    )
