Browse Source

Mar 7 :[UPDT] Updated 'website_signup_approval'

pull/317/merge
AjmalCybro 2 months ago
parent
commit
6572c69cd0
  1. 2
      user_warehouse_restriction/__manifest__.py
  2. 5
      user_warehouse_restriction/doc/RELEASE_NOTES.md
  3. 1
      user_warehouse_restriction/models/res_config_settings.py
  4. 2
      user_warehouse_restriction/models/res_users.py
  5. 1
      user_warehouse_restriction/models/stock_picking.py
  6. 49
      user_warehouse_restriction/models/stock_warehouse.py
  7. 2
      website_signup_approval/__manifest__.py
  8. 7
      website_signup_approval/doc/RELEASE_NOTES.md
  9. 1
      website_signup_approval/views/res_config_settings_views.xml
  10. 6
      website_signup_approval/views/res_users_approve_views.xml

2
user_warehouse_restriction/__manifest__.py

@ -21,7 +21,7 @@
###############################################################################
{
'name': "User Warehouse Restriction",
'version': '17.0.2.0.1',
'version': '17.0.2.0.2',
'category': 'Warehouse',
'summary': """Restrict Warehouses and location for users.""",
'description': """This module helps you to restrict warehouse and stock

5
user_warehouse_restriction/doc/RELEASE_NOTES.md

@ -15,3 +15,8 @@
#### Version 17.0.2.0.1
#### UPDT
- Incorporated condition when modifying Warehouse Restriction.
#### 6.03.2025
#### Version 17.0.2.0.2
#### UPDT
- Incorporated condition when modifying Allowed Users.

1
user_warehouse_restriction/models/res_config_settings.py

@ -39,6 +39,7 @@ class ResConfigSettings(models.TransientModel):
@api.onchange('group_user_warehouse_restriction')
def _onchange_group_user_warehouse_restriction(self):
print("_onchange_group_user_warehouse_restriction")
"""This method is triggered when the 'group_user_warehouse_restriction'
field is changed. if it's true, assigns the current user as the
allowed user of all existing warehouses."""

2
user_warehouse_restriction/models/res_users.py

@ -46,9 +46,11 @@ class ResUsers(models.Model):
def write(self, vals):
self.clear_caches()
print(vals)
return super(ResUsers, self).write(vals)
def _compute_check_user(self):
print("_compute_check_user")
"""To determine if the user has warehouse location restrictions.
Sets the check_user field accordingly."""
restriction_group_id = self.env.ref(

1
user_warehouse_restriction/models/stock_picking.py

@ -29,6 +29,7 @@ class StockPicking(models.Model):
@api.onchange('location_id', 'location_dest_id')
def _onchange_location_id(self):
print("_onchange_location_id")
"""Domain for location_id and location_dest_id."""
if self.env['ir.config_parameter'].sudo().get_param('user_warehouse_restriction.group_user_warehouse_restriction'):
return {

49
user_warehouse_restriction/models/stock_warehouse.py

@ -20,6 +20,7 @@
#
###############################################################################
from odoo import api, fields, models
from odoo.exceptions import ValidationError
class StockWarehouse(models.Model):
@ -40,18 +41,46 @@ class StockWarehouse(models.Model):
@api.onchange('restrict_location', 'user_ids')
def _onchange_restrict_location(self):
"""Triggered when the 'restrict_location' or 'user_ids' fields
are modified. It updates the 'restrict_location' field for selected
users when restricting stock location access."""
for rec in self.user_ids:
if not self.company_id:
return
current_user = self.env.user
if current_user not in self.user_ids and self.restrict_location:
self.user_ids = [(4, current_user.id)]
# Filter valid users with access to the warehouse’s company
valid_users = self.user_ids.filtered(
lambda u: self.company_id in u.company_ids
)
if self.restrict_location:
rec._origin.write({'restrict_location': True,
'allowed_warehouse_ids': [
(4, self._origin.id)]})
elif not self.restrict_location:
rec._origin.write({'restrict_location': True,
'location_ids': False
valid_users.with_context(
allowed_company_ids=self.company_id.ids
).write({
'restrict_location': True,
'allowed_warehouse_ids': [(4, self._origin.id)],
})
else:
valid_users.with_context(
allowed_company_ids=valid_users.company_ids.ids
).write({
'restrict_location': True,
'location_ids': False,
})
def write(self, vals):
"""Override the write method to prevent the current user from being
removed from the user_ids Many2many field."""
res = super(StockWarehouse, self).write(vals)
if 'user_ids' in vals:
# Check if the current user is still in user_ids after the update
current_user = self.env.user
for warehouse in self:
if current_user not in warehouse.user_ids:
raise ValidationError(
"You cannot remove yourself from the allowed users "
"of this warehouse."
)
return res
def action_open_users_view(self):
"""Return user basic form view to give restricted location for users"""

2
website_signup_approval/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': "Website Signup Approval",
'version': '17.0.1.0.3',
'version': '17.0.1.0.4',
'summary': 'Approve signup request to login to the website',
'description': """This module approve or reject signup approval request of
users from website.User can upload their documents for approval.""",

7
website_signup_approval/doc/RELEASE_NOTES.md

@ -16,6 +16,11 @@
- Changed the Configuration from Sale Configuration to Website Configuration.
#### 05.08.2024
#### Version 17.0.1.0.2
#### Version 17.0.1.0.3
#### UPDT
- Added validation for the field in settings.
#### 05.08.2024
#### Version 17.0.1.0.4
#### UPDT
- Added validation for the field in settings.

1
website_signup_approval/views/res_config_settings_views.xml

@ -14,6 +14,7 @@
id="signup_approval"
invisible="auth_signup_uninvited == 'b2b'">
<div class="o_setting_left_pane">
<field name="auth_signup_uninvited" invisible="1"/>
<field name="auth_signup_approval"/>
</div>
<div class="o_setting_right_pane">

6
website_signup_approval/views/res_users_approve_views.xml

@ -13,7 +13,7 @@
</tree>
</field>
</record>
<!-- Res users approve model form view-->
<!-- Res users approve model form view-->
<record id="res_user_approve_view_form" model="ir.ui.view">
<field name="name">res.users.approve.view.form</field>
<field name="model">res.users.approve</field>
@ -63,7 +63,7 @@
</form>
</field>
</record>
<!-- Res users approve action-->
<!-- Res approve action-->
<record id="res_users_approve_action" model="ir.actions.act_window">
<field name="name">Portal Approval</field>
<field name="res_model">res.users.approve</field>
@ -71,7 +71,7 @@
<field name="view_mode">tree,form</field>
<field name="view_id" ref="res_user_approve_view_tree"/>
</record>
<!-- Res users approve menu-->
<!-- Res users approve menu-->
<menuitem id="res_users_approve_menu" parent="base.menu_users"
action="res_users_approve_action"/>
</odoo>

Loading…
Cancel
Save