-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3e035e
commit 6ff976c
Showing
11 changed files
with
513 additions
and
64 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
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,52 @@ | ||
===================== | ||
OpenG2P Profile Image | ||
===================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:7bdf68b1fba30669d416a0928115edd95a9cfb1ee7091d4b593a0506ac530e20 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/github-OpenG2P%2Fopeng2p--registry-lightgray.png?logo=github | ||
:target: https://github.com/OpenG2P/openg2p-registry/tree/17.0-develop/g2p_profile_image | ||
:alt: OpenG2P/openg2p-registry | ||
|
||
|badge1| |badge2| | ||
|
||
G2P Profile Image | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OpenG2P/openg2p-registry/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/OpenG2P/openg2p-registry/issues/new?body=module:%20g2p_profile_image%0Aversion:%2017.0-develop%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 | ||
~~~~~~~ | ||
|
||
* OpenG2P | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `OpenG2P/openg2p-registry <https://github.com/OpenG2P/openg2p-registry/tree/17.0-develop/g2p_profile_image>`_ 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 |
---|---|---|
@@ -1 +1 @@ | ||
from . import models | ||
from . import models |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
from . import profile_image,document_file | ||
from . import profile_image, document_file |
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 |
---|---|---|
@@ -1,32 +1,36 @@ | ||
from odoo import api, fields, models | ||
from odoo import _, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class G2PDocumentFile(models.Model): | ||
_inherit = "storage.file" | ||
def create(self,vals): | ||
if type(vals) is dict: | ||
|
||
def create(self, vals): | ||
if isinstance(vals, dict): | ||
self._check_profile_tag(vals) | ||
elif type(vals) is list: | ||
elif isinstance(vals, list): | ||
for i in range(len(vals)): | ||
vals_obj = vals[i] | ||
self._check_profile_tag(vals_obj) | ||
|
||
|
||
|
||
return super(G2PDocumentFile,self).create(vals) | ||
return super().create(vals) | ||
|
||
def _check_profile_tag(self, vals_obj): | ||
profile_tag = self.env['g2p.document.tag'].get_tag_by_name('Profile Image') | ||
profile_tag = self.env["g2p.document.tag"].get_tag_by_name("Profile Image") | ||
profile_tag_id = profile_tag.id | ||
tags_ids = vals_obj.get('tags_ids', []) | ||
tags_ids = vals_obj.get("tags_ids", []) | ||
has_profile_tag = any(tag[1] == profile_tag_id for tag in tags_ids) | ||
|
||
if has_profile_tag: | ||
existing_file = self.search([ | ||
('registrant_id', '=', vals_obj.get('registrant_id')), | ||
('tags_ids', 'in', [profile_tag.id]) | ||
], limit=1) | ||
existing_file = self.search( | ||
[("registrant_id", "=", vals_obj.get("registrant_id")), ("tags_ids", "in", [profile_tag.id])], | ||
limit=1, | ||
) | ||
|
||
if existing_file: | ||
raise UserError("Profile image already exists. To change your profile picture, hover over your current image and click the edit button.") | ||
raise UserError( | ||
_( | ||
"Profile image already exists. To change your profile picture," | ||
"hover over your current image and click the edit button." | ||
) | ||
) |
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
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 @@ | ||
G2P Profile Image |
Oops, something went wrong.