Skip to content

Commit

Permalink
[IMP] portal_sale_distributor: restriction to portal users
Browse files Browse the repository at this point in the history
  • Loading branch information
lef-adhoc committed May 6, 2024
1 parent 877df9f commit 3cdcf89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 14 additions & 0 deletions portal_sale_distributor/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ msgstr "Ventas"
#: model:ir.ui.menu,name:portal_sale_distributor.sale_order
msgid "Sales Order"
msgstr "Pedidos de venta"

#. module: portal_sale_distributor
#. odoo-python
#: code:addons/portal_sale_distributor/models/product_product.py:0
#, python-format
msgid "Portal users may not archive records."
msgstr "Usuarios portales no pueden archivar registros."

#. module: portal_sale_distributor
#. odoo-python
#: code:addons/portal_sale_distributor/models/product_product.py:0
#, python-format
msgid "Portal users may not unarchive records."
msgstr "Usuarios portales no pueden desarchivar registros."
13 changes: 12 additions & 1 deletion portal_sale_distributor/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
from odoo import models, api, _
import json
from odoo.exceptions import ValidationError


class ProductProduct(models.Model):
Expand All @@ -24,3 +25,13 @@ def _get_view(self, view_id=None, view_type='form', **options):
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
return arch, view

def action_archive(self):
if self.env.user.has_group('portal_sale_distributor.group_portal_backend_distributor'):
raise ValidationError(_('Portal users may not archive records.'))
return super().action_archive()

def action_unarchive(self):
if self.env.user.has_group('portal_sale_distributor.group_portal_backend_distributor'):
raise ValidationError(_('Portal users may not unarchive records.'))
return super().action_unarchive()

0 comments on commit 3cdcf89

Please sign in to comment.