diff --git a/default_warehouse_from_sale_team/__manifest__.py b/default_warehouse_from_sale_team/__manifest__.py index cdfb41a308e..c95d01c0b6f 100644 --- a/default_warehouse_from_sale_team/__manifest__.py +++ b/default_warehouse_from_sale_team/__manifest__.py @@ -19,6 +19,7 @@ "views/ir_sequence_views.xml", "views/res_users_views.xml", "views/stock_picking_type_views.xml", + "views/stock_picking_views.xml", "security/res_groups_security.xml", "security/ir_rule_security.xml", ], diff --git a/default_warehouse_from_sale_team/models/stock_picking.py b/default_warehouse_from_sale_team/models/stock_picking.py index 6787bcb699e..9d74e422933 100644 --- a/default_warehouse_from_sale_team/models/stock_picking.py +++ b/default_warehouse_from_sale_team/models/stock_picking.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api, fields, models class StockPicking(models.Model): @@ -6,3 +6,18 @@ class StockPicking(models.Model): _inherit = ["default.warehouse.mixin", "stock.picking"] warehouse_id = fields.Many2one(related="picking_type_id.warehouse_id") + is_editable = fields.Boolean(compute="_compute_is_editable") + + @api.depends_context("uid") + def _compute_is_editable(self): + # Using intersection operator to keep original env + editable_records = self & self._filter_access_rules_python("write") + editable_records.is_editable = True + (self - editable_records).is_editable = False + + @api.depends("is_editable") + def _compute_show_check_availability(self): + res = super()._compute_show_check_availability() + non_editable = self - self.filtered("is_editable") + non_editable.show_check_availability = False + return res diff --git a/default_warehouse_from_sale_team/views/stock_picking_views.xml b/default_warehouse_from_sale_team/views/stock_picking_views.xml new file mode 100644 index 00000000000..07f2537140e --- /dev/null +++ b/default_warehouse_from_sale_team/views/stock_picking_views.xml @@ -0,0 +1,30 @@ + + + + + stock.picking.form.inherit.default.warehouse + stock.picking + + + + + + + + + + + + + + + + + +