Skip to content

Commit

Permalink
[IMP] stock_manual_transfer: rename group's external ID
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
luisg123v committed Jun 20, 2024
1 parent b87952b commit d2782b0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion stock_manual_transfer/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
32 changes: 32 additions & 0 deletions stock_manual_transfer/migrations/17.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -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"
)
4 changes: 2 additions & 2 deletions stock_manual_transfer/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion stock_manual_transfer/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="group_stock_manual_transfer" model="res.groups">
<record id="group_user" model="res.groups">
<field name="name">Can make manual transfers</field>
<field name="users" eval="[Command.link(ref('base.user_root')), Command.link(ref('base.user_admin'))]" />
</record>
Expand Down
1 change: 0 additions & 1 deletion stock_manual_transfer/tests/test_stock_manual_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
6 changes: 3 additions & 3 deletions stock_manual_transfer/views/stock_manual_transfer_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
string="Make transfers"
invisible="state != 'draft'"
class="oe_highlight"
groups="stock_manual_transfer.group_stock_manual_transfer"
groups="stock_manual_transfer.group_user"
/>
<button
name="action_view_pickings"
type="object"
string="View Transfers"
invisible="not picking_ids"
class="oe_highlight"
groups="stock_manual_transfer.group_stock_manual_transfer"
groups="stock_manual_transfer.group_user"
/>
<field name="state" widget="statusbar" />
</header>
Expand Down Expand Up @@ -100,7 +100,7 @@
id="menu_stock_manual_transfer_act"
parent="stock.menu_stock_warehouse_mgmt"
sequence="40"
groups="stock_manual_transfer.group_stock_manual_transfer"
groups="stock_manual_transfer.group_user"
/>

</odoo>

0 comments on commit d2782b0

Please sign in to comment.