diff --git a/account_exception/__init__.py b/account_exception/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/account_exception/demo/account_exception_demo.xml b/account_exception/demo/account_exception_demo.xml new file mode 100644 index 00000000..285e1c47 --- /dev/null +++ b/account_exception/demo/account_exception_demo.xml @@ -0,0 +1,13 @@ + + + + + No phone + No phone number on customer + 50 + account.move + if not invoice.partner_id.phone: failed=True + + + + diff --git a/account_exception/models/__init__.py b/account_exception/models/__init__.py new file mode 100644 index 00000000..400b3b45 --- /dev/null +++ b/account_exception/models/__init__.py @@ -0,0 +1,3 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from . import account_move diff --git a/account_exception/models/account_move.py b/account_exception/models/account_move.py new file mode 100644 index 00000000..76be6858 --- /dev/null +++ b/account_exception/models/account_move.py @@ -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') + diff --git a/account_exception/views/account_move_views.xml b/account_exception/views/account_move_views.xml new file mode 100644 index 00000000..8da66d6e --- /dev/null +++ b/account_exception/views/account_move_views.xml @@ -0,0 +1,66 @@ + + + + + Invoice Exception Rules + exception.rule + tree,form + + [('model', '=', 'account.move')] + {'active_test': False, 'default_model' : 'account.move'} + + + + + + account.move.form.inherit.exception + account.move + + + + + + + + + + + + + saccount.move.tree.inherit.exception + saccount.move + + + + + + + + + + account.invoice.select.inherit.exception + saccount.move + + + + + + + + + + diff --git a/account_exception/wizard/__init__.py b/account_exception/wizard/__init__.py new file mode 100644 index 00000000..5a31424a --- /dev/null +++ b/account_exception/wizard/__init__.py @@ -0,0 +1,25 @@ + + + + + Stock Exceptions Rules + stock.exception.confirm + + primary + + +