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:
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