generated from OCA/oca-addons-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from ecosoft-odoo/15.0-add-request_document_e…
…xception [15.0][ADD] request_document_exception
- Loading branch information
Showing
16 changed files
with
702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Saran Lim. <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.