From a136db83129f0f428c5baf600e8f1ed35fdcca08 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Mon, 26 Jan 2026 12:11:12 +0700 Subject: add permission stock locations --- fixco_custom/models/stock_location.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 fixco_custom/models/stock_location.py (limited to 'fixco_custom/models/stock_location.py') diff --git a/fixco_custom/models/stock_location.py b/fixco_custom/models/stock_location.py new file mode 100644 index 0000000..e0e1264 --- /dev/null +++ b/fixco_custom/models/stock_location.py @@ -0,0 +1,21 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + +class StockLocation(models.Model): + _inherit = 'stock.location' + + @api.model_create_multi + def create(self, vals_list): + if self.env.user.id not in [15, 27, 10, 2]: + raise UserError(_("Only the administrator can create new stock locations.")) + return super().create(vals_list) + + def write(self, vals): + if self.env.user.id not in [15, 27, 10, 2]: + raise UserError(_("Only the administrator can modify stock locations.")) + return super().write(vals) + + def unlink(self): + if self.env.user.id not in [15, 27, 10, 2]: + raise UserError(_("Only the administrator can delete stock locations.")) + return super().unlink() -- cgit v1.2.3