From d2782b0fc7b3c0a9f954d7c08a135009ba376f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez?= Date: Thu, 20 Jun 2024 22:52:42 +0000 Subject: [PATCH] [IMP] stock_manual_transfer: rename group's external ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename group's external ID, from: `group_stock_manual_transferp` → `group_user` to follow usual naming conventions. The reason for the old name is first implementation of this was not as a standalone module. In addition, IDs and names of model access rights are also modified to follow conventions. --- stock_manual_transfer/i18n/es.po | 2 +- .../migrations/17.0.1.0.0/pre-migration.py | 32 +++++++++++++++++++ .../security/ir.model.access.csv | 4 +-- stock_manual_transfer/security/res_groups.xml | 2 +- .../tests/test_stock_manual_transfer.py | 1 - .../views/stock_manual_transfer_views.xml | 6 ++-- 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 stock_manual_transfer/migrations/17.0.1.0.0/pre-migration.py diff --git a/stock_manual_transfer/i18n/es.po b/stock_manual_transfer/i18n/es.po index ce0f5e0e63c..3553263f179 100644 --- a/stock_manual_transfer/i18n/es.po +++ b/stock_manual_transfer/i18n/es.po @@ -51,7 +51,7 @@ msgid "Attachment Count" msgstr "Recuento de archivos adjuntos" #. module: stock_manual_transfer -#: model:res.groups,name:stock_manual_transfer.group_stock_manual_transfer +#: model:res.groups,name:stock_manual_transfer.group_user msgid "Can make manual transfers" msgstr "Puede realizar transferencias manuales" diff --git a/stock_manual_transfer/migrations/17.0.1.0.0/pre-migration.py b/stock_manual_transfer/migrations/17.0.1.0.0/pre-migration.py new file mode 100644 index 00000000000..a16651b0e50 --- /dev/null +++ b/stock_manual_transfer/migrations/17.0.1.0.0/pre-migration.py @@ -0,0 +1,32 @@ +import logging + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + rename_external_ids(cr) + + +def rename_external_ids(cr): + """Rename group's external ID, from group_stock_manual_transfer → group_user + + This to follow usual naming conventions. The reason for the old name is first implementation + of this was not as a standalone module. + """ + cr.execute( + """ + UPDATE + ir_model_data + SET + name = 'group_user', + write_uid = 1, + write_date = NOW() at time zone 'UTC' + WHERE + module = 'stock_manual_transfer' + AND name = 'group_stock_manual_transfer'; + """ + ) + if cr.rowcount: + _logger.info( + "Group's external ID renamed: stock_manual_transfer.group_stock_manual_transfer -> stock_manual_transfer.group_user" + ) diff --git a/stock_manual_transfer/security/ir.model.access.csv b/stock_manual_transfer/security/ir.model.access.csv index 4e77d2a4822..3fb2bca54e8 100644 --- a/stock_manual_transfer/security/ir.model.access.csv +++ b/stock_manual_transfer/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_stock_can_stock_manual_transfer,stock_can_stock_manual_transfer,model_stock_manual_transfer,group_stock_manual_transfer,1,1,1,1 -access_stock_can_stock_manual_transfer_line,stock_can_stock_manual_transfer_line,model_stock_manual_transfer_line,group_stock_manual_transfer,1,1,1,1 +access_stock_manual_transfer,access_stock_manual_transfer,model_stock_manual_transfer,group_user,1,1,1,1 +access_stock_manual_transfer_line,access_stock_manual_transfer_line,model_stock_manual_transfer_line,group_user,1,1,1,1 diff --git a/stock_manual_transfer/security/res_groups.xml b/stock_manual_transfer/security/res_groups.xml index a5fc362765d..2442d32a02e 100644 --- a/stock_manual_transfer/security/res_groups.xml +++ b/stock_manual_transfer/security/res_groups.xml @@ -1,7 +1,7 @@ - + Can make manual transfers diff --git a/stock_manual_transfer/tests/test_stock_manual_transfer.py b/stock_manual_transfer/tests/test_stock_manual_transfer.py index 0ea035f2f5c..864dd9f90a0 100644 --- a/stock_manual_transfer/tests/test_stock_manual_transfer.py +++ b/stock_manual_transfer/tests/test_stock_manual_transfer.py @@ -15,7 +15,6 @@ def setUpClass(cls): cls.warehouse_route_reception = cls.env.ref("stock_manual_transfer.demo_wh_route_reception") cls.today = fields.Date.context_today(cls.company) cls.location_suppliers = cls.env.ref("stock.stock_location_suppliers") - cls.manual_transfer_group = cls.env.ref("stock_manual_transfer.group_stock_manual_transfer") def create_manual_transfer(self): transfer = Form(self.env["stock.manual_transfer"]) diff --git a/stock_manual_transfer/views/stock_manual_transfer_views.xml b/stock_manual_transfer/views/stock_manual_transfer_views.xml index dedbc285873..3e356707853 100644 --- a/stock_manual_transfer/views/stock_manual_transfer_views.xml +++ b/stock_manual_transfer/views/stock_manual_transfer_views.xml @@ -14,7 +14,7 @@ string="Make transfers" invisible="state != 'draft'" class="oe_highlight" - groups="stock_manual_transfer.group_stock_manual_transfer" + groups="stock_manual_transfer.group_user" />