mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] make an onchange for location_id, fix readme
This commit is contained in:
@@ -1,24 +1,29 @@
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, 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,
|
||||
string='Location',
|
||||
comodel_name='stock.location',
|
||||
)
|
||||
|
||||
@api.onchange('picking_type_id')
|
||||
def _onchange_picking_type_id(self):
|
||||
if (self.picking_type_id and
|
||||
self.picking_type_id.default_location_src_id):
|
||||
self.location_id = self.picking_type_id.default_location_src_id
|
||||
|
||||
|
||||
class MrpBomLine(models.Model):
|
||||
_inherit = "mrp.bom.line"
|
||||
|
||||
location_id = fields.Many2one(
|
||||
related='bom_id.picking_type_id.default_location_src_id',
|
||||
related='bom_id.location_id',
|
||||
readonly=True,
|
||||
store=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user