mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[WIP] account_exception: backup
H11044
This commit is contained in:
0
account_exception/__init__.py
Normal file
0
account_exception/__init__.py
Normal file
13
account_exception/demo/account_exception_demo.xml
Normal file
13
account_exception/demo/account_exception_demo.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="excep_no_phone" model="exception.rule">
|
||||
<field name="name">No phone</field>
|
||||
<field name="description">No phone number on customer</field>
|
||||
<field name="sequence">50</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="code">if not invoice.partner_id.phone: failed=True</field>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
3
account_exception/models/__init__.py
Normal file
3
account_exception/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import account_move
|
||||
45
account_exception/models/account_move.py
Normal file
45
account_exception/models/account_move.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ExceptionRule(models.Model):
|
||||
_inherit = 'exception.rule'
|
||||
|
||||
model = fields.Selection(
|
||||
selection_add=[
|
||||
('account.move', 'Invoice'),
|
||||
],
|
||||
ondelete={
|
||||
'account.move': 'cascade',
|
||||
},
|
||||
)
|
||||
invoice_ids = fields.Many2many(
|
||||
'account.move',
|
||||
string="Invoices")
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = ['account.move', 'base.exception']
|
||||
_name = "account.move"
|
||||
_order = 'main_exception_id asc, date desc, name desc, id desc'
|
||||
|
||||
@api.model
|
||||
def _exception_rule_eval_context(self, rec):
|
||||
res = super(AccountMove, self)._exception_rule_eval_context(rec)
|
||||
res['invoice'] = rec
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _reverse_field(self):
|
||||
return 'invoice_ids'
|
||||
|
||||
def action_post(self):
|
||||
self.ensure_one()
|
||||
if self.detect_exceptions():
|
||||
return self._popup_exceptions()
|
||||
return super().action_post()
|
||||
# TODO
|
||||
@api.model
|
||||
def _get_popup_action(self):
|
||||
return self.env.ref('stock_exception.action_stock_exception_confirm')
|
||||
|
||||
66
account_exception/views/account_move_views.xml
Normal file
66
account_exception/views/account_move_views.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="action_invoice_test_tree" model="ir.actions.act_window">
|
||||
<field name="name">Invoice Exception Rules</field>
|
||||
<field name="res_model">exception.rule</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="base_exception.view_exception_rule_tree"/>
|
||||
<field name="domain">[('model', '=', 'account.move')]</field>
|
||||
<field name="context">{'active_test': False, 'default_model' : 'account.move'}</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
action="action_invoice_test_tree"
|
||||
id="menu_invoice_test"
|
||||
sequence="10"
|
||||
parent="account.menu_finance_configuration"
|
||||
groups="base_exception.group_exception_rule_manager"
|
||||
/>
|
||||
|
||||
<record id="view_move_form" model="ir.ui.view">
|
||||
<field name="name">account.move.form.inherit.exception</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<sheet position="before">
|
||||
<div class="alert alert-danger" role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible': [('exceptions_summary','=',False)]}">
|
||||
<p><strong>There are exceptions blocking the post of this Invoice:
|
||||
</strong></p>
|
||||
<field name="exceptions_summary"/>
|
||||
<button name="action_ignore_exceptions" type="object" class="btn-danger"
|
||||
string="Ignore Exceptions" help="Click here to be able to post this Invoice regardless of the exceptions."
|
||||
groups="base_exception.group_exception_rule_manager"/>
|
||||
</div>
|
||||
</sheet>
|
||||
<xpath expr="//field[@name='origin']/.." position="inside">
|
||||
<field name="ignore_exception" states="done" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_tree" model="ir.ui.view">
|
||||
<field name="name">saccount.move.tree.inherit.exception</field>
|
||||
<field name="model">saccount.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="main_exception_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_invoice_filter" model="ir.ui.view">
|
||||
<field name="name">account.invoice.select.inherit.exception</field>
|
||||
<field name="model">saccount.move</field>
|
||||
<field name="inherit_id" ref="account.view_account_invoice_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="late" position="after">
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-emblem-important" name="tofix" string="Blocked by exceptions" domain="[('main_exception_id','!=',False)]"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
25
account_exception/wizard/__init__.py
Normal file
25
account_exception/wizard/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_stock_exception_confirm" model="ir.ui.view">
|
||||
<field name="name">Stock Exceptions Rules</field>
|
||||
<field name="model">stock.exception.confirm</field>
|
||||
<field name="inherit_id" ref="base_exception.view_exception_rule_confirm"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//footer" position="inside">
|
||||
<button class="oe_link" special="cancel" string="Cancel"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_invoice_exception_confirm" model="ir.actions.act_window">
|
||||
<field name="name">Blocked due to exceptions</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">invoice.exception.confirm</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_invoice_exception_confirm"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
26
account_exception/wizard/account_move_exception_confirm.py
Normal file
26
account_exception/wizard/account_move_exception_confirm.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class InvoiceExceptionConfirm(models.TransientModel):
|
||||
_name = 'invoice.exception.confirm'
|
||||
_inherit = ['exception.rule.confirm']
|
||||
_description = 'Invoice Exception Confirm Wizard'
|
||||
|
||||
related_model_id = fields.Many2one('account.move', 'Invoice')
|
||||
|
||||
def action_confirm(self):
|
||||
self.ensure_one()
|
||||
if self.ignore:
|
||||
self.related_model_id.ignore_exception = True
|
||||
res = super().action_confirm()
|
||||
if self.ignore:
|
||||
return self.related_model_id.action_post()
|
||||
else:
|
||||
return res
|
||||
|
||||
def _action_ignore(self):
|
||||
self.related_model_id.ignore_exception = True
|
||||
super()._action_ignore()
|
||||
return self.related_model_id.action_post()
|
||||
Reference in New Issue
Block a user