Skip to content

Commit

Permalink
Merge pull request #232 from ecosoft-odoo/15.0-add-request_document_e…
Browse files Browse the repository at this point in the history
…xception

[15.0][ADD] request_document_exception
  • Loading branch information
Saran440 authored Dec 16, 2024
2 parents 78ad157 + 428bcfb commit dd16d69
Show file tree
Hide file tree
Showing 16 changed files with 702 additions and 0 deletions.
60 changes: 60 additions & 0 deletions request_document_exception/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
============================
Request Document - Exception
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b878ce5aa176b7326e8d73f33a04da7bee313624e74af77ef285c43bc3dcc444
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-ecosoft--odoo%2Fecosoft--addons-lightgray.png?logo=github
:target: https://github.com/ecosoft-odoo/ecosoft-addons/tree/15.0/request_document_exception
:alt: ecosoft-odoo/ecosoft-addons

|badge1| |badge2| |badge3|

# TODO

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/ecosoft-odoo/ecosoft-addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/ecosoft-odoo/ecosoft-addons/issues/new?body=module:%20request_document_exception%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Ecosoft

Contributors
~~~~~~~~~~~~

* Saran Lim. <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `ecosoft-odoo/ecosoft-addons <https://github.com/ecosoft-odoo/ecosoft-addons/tree/15.0/request_document_exception>`_ project on GitHub.

You are welcome to contribute.
4 changes: 4 additions & 0 deletions request_document_exception/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
from . import wizard
18 changes: 18 additions & 0 deletions request_document_exception/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Ecosoft Co., Ltd (https://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Request Document - Exception",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"category": "Accounting & Finance",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/ecosoft-odoo/ecosoft-addons",
"depends": ["request_document", "base_exception"],
"data": [
"security/ir.model.access.csv",
"views/request_request_view.xml",
"wizard/request_exception_confirm_view.xml",
],
"installable": True,
}
5 changes: 5 additions & 0 deletions request_document_exception/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import exception_rule
from . import request_request
from . import request_document
19 changes: 19 additions & 0 deletions request_document_exception/models/exception_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ExceptionRule(models.Model):
_inherit = "exception.rule"

request_request_ids = fields.Many2many(
comodel_name="request.request", string="Requests"
)
model = fields.Selection(
selection_add=[
("request.request", "Request Sheet"),
("request.document", "Request Document"),
],
ondelete={"request.request": "cascade", "request.document": "cascade"},
)
24 changes: 24 additions & 0 deletions request_document_exception/models/request_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2024 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class RequestDocument(models.Model):
_name = "request.document"
_inherit = ["request.document", "base.exception.method"]

ignore_exception = fields.Boolean(
related="request_id.ignore_exception", store=True, string="Ignore Exceptions"
)

@api.model
def _reverse_field(self):
return "request_request_ids"

def _get_main_records(self):
return self.mapped("request_id")

def _detect_exceptions(self, rule):
records = super()._detect_exceptions(rule)
return records.mapped("request_id")
44 changes: 44 additions & 0 deletions request_document_exception/models/request_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class RequestRequest(models.Model):
_name = "request.request"
_inherit = ["request.request", "base.exception"]

@api.model
def _reverse_field(self):
return "request_request_ids"

def detect_exceptions(self):
all_exceptions = super().detect_exceptions()
lines = self.mapped("line_ids")
all_exceptions += lines.detect_exceptions()
return all_exceptions

@api.onchange("line_ids")
def onchange_ignore_exception(self):
if self.state == "submit":
self.ignore_exception = False

def action_submit(self):
if self.detect_exceptions() and not self.ignore_exception:
return self._popup_exceptions()
return super().action_submit()

@api.model
def _get_popup_action(self):
action = self.env.ref(
"request_document_exception.action_request_exception_confirm"
)
return action

def action_draft(self):
res = super().action_draft()
for rec in self:
rec.exception_ids = False
rec.main_exception_id = False
rec.ignore_exception = False
return res
3 changes: 3 additions & 0 deletions request_document_exception/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions request_document_exception/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Saran Lim. <[email protected]>
1 change: 1 addition & 0 deletions request_document_exception/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
2 changes: 2 additions & 0 deletions request_document_exception/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_request_exception_confirm_user,access_request_exception_confirm_user,model_request_exception_confirm,base.group_user,1,1,1,1
Loading

0 comments on commit dd16d69

Please sign in to comment.