From 2b6d12726a0256a679bf974d438de479f152a154 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Tue, 19 Sep 2023 18:06:53 +0200 Subject: [PATCH] [FIX] printing_auto*: bound to model And add security rule --- printing_auto_base/models/printing_auto.py | 1 + printing_auto_base/tests/common.py | 1 + printing_auto_stock_picking/__manifest__.py | 1 + .../models/stock_picking_type.py | 4 +++- printing_auto_stock_picking/security/ir_rule.xml | 13 +++++++++++++ .../views/stock_picking_type.xml | 5 ++++- 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 printing_auto_stock_picking/security/ir_rule.xml diff --git a/printing_auto_base/models/printing_auto.py b/printing_auto_base/models/printing_auto.py index fe1d13ac9c2..5f3ed8bf6dc 100644 --- a/printing_auto_base/models/printing_auto.py +++ b/printing_auto_base/models/printing_auto.py @@ -19,6 +19,7 @@ class PrintingAuto(models.Model): _description = "Printing Auto" name = fields.Char(string="Name", required=True) + model = fields.Char(string="Related Document Model", required=True) data_source = fields.Selection( [ diff --git a/printing_auto_base/tests/common.py b/printing_auto_base/tests/common.py index 310d4aff8d8..15739703b23 100644 --- a/printing_auto_base/tests/common.py +++ b/printing_auto_base/tests/common.py @@ -54,6 +54,7 @@ def setUpClass(cls): @classmethod def _create_printing_auto(cls, vals): + vals.setdefault("model", cls._name) return cls.env["printing.auto"].create(vals) @classmethod diff --git a/printing_auto_stock_picking/__manifest__.py b/printing_auto_stock_picking/__manifest__.py index b685f875579..3b6752370a7 100644 --- a/printing_auto_stock_picking/__manifest__.py +++ b/printing_auto_stock_picking/__manifest__.py @@ -8,6 +8,7 @@ "category": "Warehouse Management", "data": [ "security/ir.model.access.csv", + "security/ir_rule.xml", "views/stock_picking.xml", "views/stock_picking_type.xml", ], diff --git a/printing_auto_stock_picking/models/stock_picking_type.py b/printing_auto_stock_picking/models/stock_picking_type.py index 7ae139fce91..dbca36da747 100644 --- a/printing_auto_stock_picking/models/stock_picking_type.py +++ b/printing_auto_stock_picking/models/stock_picking_type.py @@ -9,5 +9,7 @@ class StockPickingType(models.Model): _inherit = "stock.picking.type" auto_printing_ids = fields.Many2many( - "printing.auto", string="Auto Printing Configuration" + "printing.auto", + string="Auto Printing Configuration", + domain=[("model", "=", "stock.picking.type")], ) diff --git a/printing_auto_stock_picking/security/ir_rule.xml b/printing_auto_stock_picking/security/ir_rule.xml new file mode 100644 index 00000000000..f8de7a6c52d --- /dev/null +++ b/printing_auto_stock_picking/security/ir_rule.xml @@ -0,0 +1,13 @@ + + + + stock picking auto print + + [("model", "=", "stock.picking.type")] + + + + + + + diff --git a/printing_auto_stock_picking/views/stock_picking_type.xml b/printing_auto_stock_picking/views/stock_picking_type.xml index 8c2e299322a..f957549f380 100644 --- a/printing_auto_stock_picking/views/stock_picking_type.xml +++ b/printing_auto_stock_picking/views/stock_picking_type.xml @@ -6,7 +6,10 @@ - +