mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] scrap_reason_code from v11 to v13
This commit is contained in:
committed by
Chandresh Thakkar
parent
c233777853
commit
0cc4e786c5
@@ -1,5 +1,3 @@
|
||||
# Copyright (C) 2019 IBM Corp.
|
||||
# Copyright (C) 2019 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import reason_code
|
||||
|
||||
@@ -6,11 +6,13 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class ReasonCode(models.Model):
|
||||
_name = 'reason.code'
|
||||
_description = 'Reason Code'
|
||||
_name = "reason.code"
|
||||
_description = "Reason Code"
|
||||
|
||||
name = fields.Char("Code", required=True)
|
||||
description = fields.Text("Description")
|
||||
location_id = fields.Many2one(
|
||||
'stock.location', string="Scrap Location",
|
||||
domain="[('scrap_location', '=', True)]")
|
||||
"stock.location",
|
||||
string="Scrap Location",
|
||||
domain="[('scrap_location', '=', True)]",
|
||||
)
|
||||
|
||||
@@ -6,6 +6,6 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
_inherit = "stock.move"
|
||||
|
||||
reason_code_id = fields.Many2one('reason.code', string='Reason code')
|
||||
reason_code_id = fields.Many2one("reason.code", string="Reason code")
|
||||
|
||||
@@ -6,35 +6,38 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockScrap(models.Model):
|
||||
_inherit = 'stock.scrap'
|
||||
_inherit = "stock.scrap"
|
||||
|
||||
reason_code_id = fields.Many2one(
|
||||
'reason.code', string='Reason Code',
|
||||
states={'done': [('readonly', True)]})
|
||||
"reason.code", string="Reason Code", states={"done": [("readonly", True)]}
|
||||
)
|
||||
scrap_location_id = fields.Many2one(
|
||||
'stock.location', 'Scrap Location',
|
||||
required=True, readonly=True)
|
||||
"stock.location", "Scrap Location", required=True, readonly=True
|
||||
)
|
||||
|
||||
def _prepare_move_values(self):
|
||||
res = super(StockScrap, self)._prepare_move_values()
|
||||
res['reason_code_id'] = self.reason_code_id.id
|
||||
res["reason_code_id"] = self.reason_code_id.id
|
||||
return res
|
||||
|
||||
@api.onchange('reason_code_id')
|
||||
@api.onchange("reason_code_id")
|
||||
def _onchange_reason_code_id(self):
|
||||
if self.reason_code_id.location_id:
|
||||
self.scrap_location_id = self.reason_code_id.location_id
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if 'reason_code_id' in vals:
|
||||
self.scrap_location_id = self.env['reason.code'].browse(
|
||||
vals.get('reason_code_id')).location_id
|
||||
if "reason_code_id" in vals:
|
||||
self.scrap_location_id = (
|
||||
self.env["reason.code"].browse(vals.get("reason_code_id")).location_id
|
||||
)
|
||||
return super(StockScrap, self).write(vals)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if 'reason_code_id' in vals:
|
||||
vals['scrap_location_id'] = self.env['reason.code'].browse(
|
||||
vals.get('reason_code_id')).location_id.id
|
||||
if "reason_code_id" in vals:
|
||||
vals["scrap_location_id"] = (
|
||||
self.env["reason.code"]
|
||||
.browse(vals.get("reason_code_id"))
|
||||
.location_id.id
|
||||
)
|
||||
return super(StockScrap, self).create(vals)
|
||||
|
||||
Reference in New Issue
Block a user