summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_location.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/stock_location.py')
-rw-r--r--indoteknik_custom/models/stock_location.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_location.py b/indoteknik_custom/models/stock_location.py
new file mode 100644
index 00000000..d075ff2a
--- /dev/null
+++ b/indoteknik_custom/models/stock_location.py
@@ -0,0 +1,40 @@
+from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
+
+class StockLocation(models.Model):
+ _inherit = 'stock.location'
+
+ rack_level = fields.Integer(
+ string='Sequence',
+ default=1,
+ help='Indicates the vertical rack level (1 = lowest, 4 = highest).'
+ )
+
+ # level = fields.Integer(
+ # string='Rack Level',
+ # default=1,
+ # help='Indicates the vertical rack level (1 = lowest, 4 = highest).'
+ # )
+
+ is_locked = fields.Boolean(
+ string="Locked",
+ default=False,
+ help="Jika dicentang, lokasi ini tidak dapat digunakan untuk reservasi atau penerimaan barang."
+ )
+
+ @api.constrains('rack_level')
+ def _check_rack_level(self):
+ for rec in self:
+ if rec.rack_level < 1 or rec.rack_level > 4:
+ raise ValidationError(_("Rack level harus antara 1 sampai 4."))
+
+ @api.constrains('is_locked')
+ def _sync_locked_quant(self):
+ Quant = self.env['stock.quant']
+ for rec in self:
+ quants = Quant.search([('location_id', '=', rec.id)])
+ if quants:
+ if rec.is_locked:
+ quants.write({'note': 'Locked'})
+ else:
+ quants.write({'note': False})