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. 53
      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", 'name': "User Warehouse Restriction",
'version': '17.0.2.0.1', 'version': '17.0.2.0.2',
'category': 'Warehouse', 'category': 'Warehouse',
'summary': """Restrict Warehouses and location for users.""", 'summary': """Restrict Warehouses and location for users.""",
'description': """This module helps you to restrict warehouse and stock '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 #### Version 17.0.2.0.1
#### UPDT #### UPDT
- Incorporated condition when modifying Warehouse Restriction. - 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') @api.onchange('group_user_warehouse_restriction')
def _onchange_group_user_warehouse_restriction(self): def _onchange_group_user_warehouse_restriction(self):
print("_onchange_group_user_warehouse_restriction")
"""This method is triggered when the '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 field is changed. if it's true, assigns the current user as the
allowed user of all existing warehouses.""" 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): def write(self, vals):
self.clear_caches() self.clear_caches()
print(vals)
return super(ResUsers, self).write(vals) return super(ResUsers, self).write(vals)
def _compute_check_user(self): def _compute_check_user(self):
print("_compute_check_user")
"""To determine if the user has warehouse location restrictions. """To determine if the user has warehouse location restrictions.
Sets the check_user field accordingly.""" Sets the check_user field accordingly."""
restriction_group_id = self.env.ref( 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') @api.onchange('location_id', 'location_dest_id')
def _onchange_location_id(self): def _onchange_location_id(self):
print("_onchange_location_id")
"""Domain for location_id and location_dest_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'): if self.env['ir.config_parameter'].sudo().get_param('user_warehouse_restriction.group_user_warehouse_restriction'):
return { return {

53
user_warehouse_restriction/models/stock_warehouse.py

@ -20,6 +20,7 @@
# #
############################################################################### ###############################################################################
from odoo import api, fields, models from odoo import api, fields, models
from odoo.exceptions import ValidationError
class StockWarehouse(models.Model): class StockWarehouse(models.Model):
@ -40,18 +41,46 @@ class StockWarehouse(models.Model):
@api.onchange('restrict_location', 'user_ids') @api.onchange('restrict_location', 'user_ids')
def _onchange_restrict_location(self): def _onchange_restrict_location(self):
"""Triggered when the 'restrict_location' or 'user_ids' fields if not self.company_id:
are modified. It updates the 'restrict_location' field for selected return
users when restricting stock location access."""
for rec in self.user_ids: current_user = self.env.user
if self.restrict_location: if current_user not in self.user_ids and self.restrict_location:
rec._origin.write({'restrict_location': True, self.user_ids = [(4, current_user.id)]
'allowed_warehouse_ids': [
(4, self._origin.id)]}) # Filter valid users with access to the warehouse’s company
elif not self.restrict_location: valid_users = self.user_ids.filtered(
rec._origin.write({'restrict_location': True, lambda u: self.company_id in u.company_ids
'location_ids': False )
}) if self.restrict_location:
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): def action_open_users_view(self):
"""Return user basic form view to give restricted location for users""" """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", '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', 'summary': 'Approve signup request to login to the website',
'description': """This module approve or reject signup approval request of 'description': """This module approve or reject signup approval request of
users from website.User can upload their documents for approval.""", 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. - Changed the Configuration from Sale Configuration to Website Configuration.
#### 05.08.2024 #### 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 #### UPDT
- Added validation for the field in settings. - Added validation for the field in settings.

1
website_signup_approval/views/res_config_settings_views.xml

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

6
website_signup_approval/views/res_users_approve_views.xml

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

Loading…
Cancel
Save