mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[ADD] base_exception_user,sale_exception_user,stock_exception: allow certain users to ignore exceptions, add exceptions on delivery orders
This commit is contained in:
2
base_exception_user/__init__.py
Normal file
2
base_exception_user/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import models
|
||||||
|
from . import wizard
|
||||||
24
base_exception_user/__manifest__.py
Normal file
24
base_exception_user/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Exception Rule User',
|
||||||
|
'version': '13.0.1.0.0',
|
||||||
|
'author': 'Hibou Corp.',
|
||||||
|
'license': 'OPL-1',
|
||||||
|
'category': 'Generic Modules',
|
||||||
|
'summary': 'Allow users to ignore exceptions',
|
||||||
|
'description': """
|
||||||
|
Allow users to ignore exceptions
|
||||||
|
""",
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'depends': [
|
||||||
|
'base_exception',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'security/base_exception_security.xml',
|
||||||
|
'views/base_exception_views.xml',
|
||||||
|
'wizard/base_exception_confirm_view.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
||||||
1
base_exception_user/models/__init__.py
Normal file
1
base_exception_user/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import base_exception
|
||||||
7
base_exception_user/models/base_exception.py
Normal file
7
base_exception_user/models/base_exception.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class ExceptionRule(models.Model):
|
||||||
|
_inherit = 'exception.rule'
|
||||||
|
|
||||||
|
allow_user_ignore = fields.Boolean('Allow User Ignore')
|
||||||
13
base_exception_user/security/base_exception_security.xml
Normal file
13
base_exception_user/security/base_exception_security.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="group_exception_rule_user" model="res.groups">
|
||||||
|
<field name="name">Exception user</field>
|
||||||
|
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="base_exception.group_exception_rule_manager" model="res.groups">
|
||||||
|
<field name="implied_ids" eval="[(4, ref('base_exception_user.group_exception_rule_user'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
26
base_exception_user/views/base_exception_views.xml
Normal file
26
base_exception_user/views/base_exception_views.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_exception_rule_tree" model="ir.ui.view">
|
||||||
|
<field name="name">exception.rule.tree.inherit.user</field>
|
||||||
|
<field name="model">exception.rule</field>
|
||||||
|
<field name="inherit_id" ref="base_exception.view_exception_rule_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='model']" position="after">
|
||||||
|
<field name="allow_user_ignore" widget="boolean_toggle"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_exception_rule_form" model="ir.ui.view">
|
||||||
|
<field name="name">exception.rule.form.inherit.user</field>
|
||||||
|
<field name="model">exception.rule</field>
|
||||||
|
<field name="inherit_id" ref="base_exception.view_exception_rule_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='domain']" position="after">
|
||||||
|
<field name="allow_user_ignore" widget="boolean_toggle"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
1
base_exception_user/wizard/__init__.py
Normal file
1
base_exception_user/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import base_exception_confirm
|
||||||
36
base_exception_user/wizard/base_exception_confirm.py
Normal file
36
base_exception_user/wizard/base_exception_confirm.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import html
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ExceptionRuleConfirm(models.AbstractModel):
|
||||||
|
_inherit = 'exception.rule.confirm'
|
||||||
|
|
||||||
|
show_ignore_button = fields.Boolean('Allow User Ignore', compute='_compute_show_ignore_button')
|
||||||
|
|
||||||
|
@api.depends('exception_ids')
|
||||||
|
def _compute_show_ignore_button(self):
|
||||||
|
for wiz in self:
|
||||||
|
wiz.show_ignore_button = (self.env.user.has_group('base_exception_user.group_exception_rule_user') and
|
||||||
|
all(wiz.exception_ids.mapped('allow_user_ignore')))
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
if self.ignore and 'message_ids' in self.related_model_id:
|
||||||
|
exceptions_summary = '<ul>%s</ul>' % ''.join(
|
||||||
|
['<li>%s: <i>%s</i></li>' % tuple(map(html.escape, (e.name, e.description))) for e in
|
||||||
|
self.exception_ids])
|
||||||
|
msg = '<p><strong>Exceptions ignored:</strong></p>' + exceptions_summary
|
||||||
|
self.related_model_id.message_post(body=msg)
|
||||||
|
return super().action_confirm()
|
||||||
|
|
||||||
|
|
||||||
|
def action_ignore(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.show_ignore_button:
|
||||||
|
if 'message_ids' in self.related_model_id:
|
||||||
|
msg = '<p><strong>Exceptions ignored:</strong></p>' + self.related_model_id.exceptions_summary
|
||||||
|
self.related_model_id.message_post(body=msg)
|
||||||
|
return self._action_ignore()
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _action_ignore(self):
|
||||||
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
18
base_exception_user/wizard/base_exception_confirm_view.xml
Normal file
18
base_exception_user/wizard/base_exception_confirm_view.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_exception_rule_confirm" model="ir.ui.view">
|
||||||
|
<field name="name">Exceptions Rules</field>
|
||||||
|
<field name="model">exception.rule.confirm</field>
|
||||||
|
<field name="inherit_id" ref="base_exception.view_exception_rule_confirm"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='ignore']" position="after">
|
||||||
|
<field name="show_ignore_button" invisible="1"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_confirm']" position="after">
|
||||||
|
<button name="action_ignore" string="Ignore" colspan="1" type="object" attrs="{'invisible': [('show_ignore_button', '=', False)]}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user