Skip to content

Commit

Permalink
[MIG] pos_user_restriction: migrate to 17.0
Browse files Browse the repository at this point in the history
Migration notes:

1. Removed bypassing group check, since set_cashbox_pos in 16.0+
does not call has_groups method [1]

2. Removed hack in res_users.py, which should not be the case,
since in res.users' write method has_group is replaced with
_is_internal [2]

3. Removed several ir.model.access records for removed models:

- account.bank.statement.cashbox [3]
- account.cashbox.line [3]
- cash.box.out [4]

[1] odoo/odoo#113151
[2] odoo/odoo@dae28c4#diff-16e37db365c1ea1f2e6c79aeb60c80f68f1a5c75970e8e3f198eb18af56278dd
[3] odoo/odoo@4fb0933
[4] odoo/odoo@7e23eda

In this commit we remove bypassing group check
  • Loading branch information
em230418 committed Oct 25, 2024
1 parent fd5e78e commit 02b15f7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
7 changes: 0 additions & 7 deletions pos_user_restriction/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
class PosSession(models.Model):
_inherit = "pos.session"

def set_cashbox_pos(self, cashbox_value, notes):
if self.env.user.has_group(
"pos_user_restriction.group_assigned_points_of_sale_user"
):
self = self.with_context(bypass_pos_user=True)
return super().set_cashbox_pos(cashbox_value, notes)

def get_closing_control_data(self):
if self.env.user.has_group(
"pos_user_restriction.group_assigned_points_of_sale_user"
Expand Down
9 changes: 0 additions & 9 deletions pos_user_restriction/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from odoo import api, models
from odoo.tools import ormcache


class ResUsers(models.Model):
Expand All @@ -14,11 +13,3 @@ def has_group(self, group_ext_id):
else:
res = super().has_group(group_ext_id)
return res

# HACK: To clear cache called from res.users write method
@api.model
@ormcache("self._uid", "group_ext_id")
def _has_group(self, group_ext_id):
return super()._has_group(group_ext_id)

has_group.clear_cache = _has_group.clear_cache
6 changes: 3 additions & 3 deletions pos_user_restriction/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ access_pos_config_user,pos.config user,point_of_sale.model_pos_config,group_assi
access_product_category_pos_user,pos.category user,point_of_sale.model_pos_category,group_assigned_points_of_sale_user,1,0,0,0
access_barcode_nomenclature_pos_user,barcode.nomenclature.pos.user,barcodes.model_barcode_nomenclature,group_assigned_points_of_sale_user,1,0,0,0
access_barcode_rule_pos_user,barcode.rule.pos.user,barcodes.model_barcode_rule,group_assigned_points_of_sale_user,1,0,0,0
access_bank_statement_cashbox_user,account.bank.statement.cashbox user,account.model_account_bank_statement_cashbox,group_assigned_points_of_sale_user,1,1,1,0
access_account_cashbox_line_user,account.cashbox.line user,account.model_account_cashbox_line,group_assigned_points_of_sale_user,1,1,1,0
access_account_cash_rounding_pos_user,account.cash.rounding.pos.user,account.model_account_cash_rounding,group_assigned_points_of_sale_user,1,0,0,0
access_pos_payment_method_user,pos.payment.method user,point_of_sale.model_pos_payment_method,group_assigned_points_of_sale_user,1,0,0,0
access_decimal_precision_user,decimal.precision,base.model_decimal_precision,group_assigned_points_of_sale_user,1,0,0,0
access_money_in_out_wizard,access.money.in.out.wizard,point_of_sale.model_cash_box_out,group_assigned_points_of_sale_user,1,1,1,0
access_pos_payment_user,pos.payment user,point_of_sale.model_pos_payment,group_assigned_points_of_sale_user,1,1,1,1
access_pos_bill_user,pos.bill,point_of_sale.model_pos_bill,group_assigned_points_of_sale_user,1,1,1,1
access_pos_close_session_wizard,access.pos.close.session.wizard,point_of_sale.model_pos_close_session_wizard,group_assigned_points_of_sale_user,1,1,1,0
access_pos_printer,pos.printer.user,point_of_sale.model_pos_printer,group_assigned_points_of_sale_user,1,0,0,0
access_pos_combo_user,pos.combo user,point_of_sale.model_pos_combo,group_assigned_points_of_sale_user,1,0,0,0
access_pos_combo_line_user,pos.combo.line user,point_of_sale.model_pos_combo_line,group_assigned_points_of_sale_user,1,0,0,0

0 comments on commit 02b15f7

Please sign in to comment.