mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-22 15:32:07 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright 2023 ForgeFlow S.L. (http://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MrpBomChangeLocation(models.TransientModel):
|
||||
_name = "mrp.bom.change.location"
|
||||
_description = "MRP Bom Change Location"
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
bom_obj = self.env["mrp.bom"]
|
||||
bom_id = self.env.context.get("active_id", False)
|
||||
active_model = self.env.context["active_model"]
|
||||
|
||||
if not bom_id:
|
||||
return
|
||||
assert active_model == "mrp.bom", "Bad context propagation"
|
||||
|
||||
bom = bom_obj.browse(bom_id)
|
||||
res.update(
|
||||
{
|
||||
"location_id": bom.context_location_id.id,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location",
|
||||
)
|
||||
|
||||
def action_change_location(self):
|
||||
bom_id = self.env.context.get("active_id", False)
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "mrp.bom",
|
||||
"view_mode": "form",
|
||||
"res_id": bom_id,
|
||||
"context": {
|
||||
"location_id": self.location_id.id,
|
||||
"warehouse_id": self.location_id.warehouse_id.id,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue