17.0 security#23
Merged
Merged
Conversation
[ADD] added search for folders and added groups for documents action …
17.0 features
[ADD] added check base url
17.0 purchase folders
…cument_hub into 17.0-security
There was a problem hiding this comment.
Pull request overview
This PR expands the Document Hub module’s security model (new department groups + updated menu access and record rules) and introduces IMAP-based email attachment ingestion plus a new OWL widget to pick/link documents in many2many fields.
Changes:
- Add new security groups (Production, Sales, Everyone) and update access rules/menus accordingly.
- Add IMAP configuration + cron job to ingest email attachments as Document Hub documents.
- Introduce a new backend many2many field widget (
document_hub_documents) and supporting computed fields (e.g., attachment names).
Reviewed changes
Copilot reviewed 19 out of 27 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
__init__.py |
Initialize module Python package. |
__manifest__.py |
Add dependency (sale_offer), cron + settings view data, and backend assets bundle. |
.gitignore |
Add Python-oriented gitignore. |
README.md |
Add module documentation (but license statement needs alignment). |
LICENSE |
Add GPLv2 license text. |
data/cron_data.xml |
Add cron to poll external IMAP inbox. |
data/document_sequence.xml |
Add document sequences (includes hard-coded company id). |
data/folders_data.xml |
Add Purchases folder structure. |
data/tags_data.xml |
Add “From email” tag. |
i18n/pl.po |
Update Polish translations for new UI strings and data. |
models/__init__.py |
Load newly added models. |
models/document.py |
Add file_names compute and new visibility-related fields. |
models/folder.py |
Add new visibility flags + onchange behavior. |
models/inbox_mail.py |
Implement IMAP fetch + document creation from attachments (contains critical security issues). |
models/project.py |
Add computed document count on projects (currently compute bug). |
models/res_config_settings.py |
Add IMAP settings persistence (currently boolean parsing bug). |
models/sale_offer.py |
Sync sale offer attachments into Document Hub documents (uses sudo in security-sensitive flows). |
models/tag.py |
Add Tag model. |
security/document_hub_security.xml |
Add new groups + record rules (one rule references a missing field). |
security/ir.model.access.csv |
Update permissions; add access rows for new groups. |
static/description/icon.png |
Add module icon. |
static/src/document_picker_field/document_picker_field.esm.js |
Add OWL field component + registry registration. |
static/src/document_picker_field/document_picker_field.xml |
Add OWL template (currently contains a runtime error in t-key). |
views/config_views.xml |
Expose new visibility fields; restrict Configuration menu to manager. |
views/document_hub_views.xml |
Adjust partner widget + search filter naming. |
views/project_views.xml |
Expand button visibility to additional groups. |
views/res_config_settings_views.xml |
Add Document Hub IMAP settings UI + menu/action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+16
to
+33
| def set_values(self): | ||
| res = super(ResConfigSettings, self).set_values() | ||
| self.env['ir.config_parameter'].set_param('document_hub.active', self.imap_active) | ||
|
|
||
| if not self.imap_active: | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_host', False) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_port', 0) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_user', False) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_password', False) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_folder', False) | ||
| else: | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_host', self.imap_host) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_port', self.imap_port) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_user', self.imap_user) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_password', self.imap_password) | ||
| self.env['ir.config_parameter'].set_param('document_hub.imap_folder', self.imap_folder.id if self.imap_folder else '') | ||
|
|
||
| return res |
Comment on lines
+40
to
+59
| imap_active = ICPSudo.get_param('document_hub.active', False) | ||
| imap_host = ICPSudo.get_param('document_hub.imap_host', False) | ||
| imap_port = ICPSudo.get_param('document_hub.imap_port', default=0) | ||
| imap_user = ICPSudo.get_param('document_hub.imap_user', False) | ||
| imap_password = ICPSudo.get_param('document_hub.imap_password', False) | ||
| imap_folder_id_raw = ICPSudo.get_param('document_hub.imap_folder', False) | ||
|
|
||
| try: | ||
| imap_folder_id = int(imap_folder_id_raw) | ||
| except (ValueError, TypeError): | ||
| imap_folder_id = False | ||
|
|
||
| res.update( | ||
| imap_active=bool(imap_active), | ||
| imap_host=imap_host, | ||
| imap_port=int(imap_port) if imap_port else 0, | ||
| imap_user=imap_user, | ||
| imap_password=imap_password, | ||
| imap_folder=self.env['document_hub.folder'].browse(imap_folder_id) if imap_folder_id else False, | ||
| ) |
Comment on lines
+37
to
+41
| context = ssl.create_default_context() | ||
| context.check_hostname = False | ||
| context.verify_mode = ssl.CERT_NONE | ||
|
|
||
| with imaplib.IMAP4_SSL(imap_host, imap_port, ssl_context=context) as mail: |
Comment on lines
+88
to
+94
| document = self.env['document_hub.document'].create({ | ||
| 'topic': subject, | ||
| 'description': _("Email from: <b>%s</b>, Subject: <b>%s</b>") % (sender, subject), | ||
| 'folder_id': folder.id if folder else False, | ||
| 'file_ids': [(6, 0, [attachment.id])], | ||
| 'tag_ids': [(6, 0, [self.env.ref('document_hub.tag_email').id])], | ||
| }) |
Comment on lines
+35
to
+42
| rel_visibility_administration = fields.Boolean(related='folder_id.visibility_administration') | ||
| rel_visibility_purchasing_and_logistics = fields.Boolean(related='folder_id.visibility_purchasing_and_logistics') | ||
| rel_visibility_marketing = fields.Boolean(related='folder_id.visibility_marketing') | ||
| rel_visibility_accounting = fields.Boolean(related='folder_id.visibility_accounting') | ||
| rel_visibility_pm = fields.Boolean(related='folder_id.visibility_pm',) | ||
| rel_visibility_hr = fields.Boolean(related='folder_id.visibility_hr',) | ||
| rel_visibility_salesman = fields.Boolean(related='folder_id.visibility_salesman',) | ||
| rel_visibility_everyone = fields.Boolean(related='folder_id.visibility_everyone',) |
Comment on lines
+22
to
+27
| <div t-if="props.showFilenames and rec.data.file_names" style="color: #7c8289c2; margin-top: 4px; font-size: 12px;"> | ||
| <div t-foreach="rec.data.file_names.split('\n')" t-as="fname" t-key="fname_index" | ||
| class="text-truncate"> | ||
| <t t-esc="fname"/> | ||
| </div> | ||
| </div> |
| #: model:document_hub.folder,parent_path:document_hub.folder_project_nda | ||
| msgid "Project: NDA" | ||
| msgstr "Projekt: NDA" | ||
| msgstr "Sprzedaż: NDA" |
Comment on lines
+49
to
+56
| @api.model_create_multi | ||
| def create(self, vals_list): | ||
| for vals in vals_list: | ||
| if vals.get('name', _('New')) == _('New'): | ||
| vals['name'] = (self.env['ir.sequence'].next_by_code('document_hub.document')) | ||
|
|
||
| res = super(Document, self.sudo()).create(vals_list) | ||
| return res |
Comment on lines
+13
to
+35
| Document = self.env['document_hub.document'] | ||
|
|
||
| doc = Document.sudo().search([('topic', '=', self.name)], limit=1) | ||
| offer_attachment_ids = self.attachment_ids.ids | ||
| inbox_folder_id = self.env.ref('document_hub.folder_administration_inbox') | ||
| project_folder_id = self.env.ref('document_hub.folder_project') | ||
|
|
||
| if not doc: | ||
| if self.project_id: | ||
| Document.sudo().create({ | ||
| 'topic': self.name, | ||
| 'folder_id': project_folder_id.id, | ||
| 'project_id': self.project_id.id, | ||
| 'file_ids': [(6, 0, offer_attachment_ids)], | ||
| }) | ||
| return | ||
| else: | ||
| Document.sudo().create({ | ||
| 'topic': self.name, | ||
| 'folder_id': inbox_folder_id.id, | ||
| 'file_ids': [(6, 0, offer_attachment_ids)], | ||
| }) | ||
| return |
Comment on lines
+48
to
+54
| Document = self.env['document_hub.document'] | ||
| doc = Document.sudo().search([('topic', '=', self.name)], limit=1) | ||
|
|
||
| if doc: | ||
| doc.sudo().write({ | ||
| 'file_ids': [(5, 0, 0)], | ||
| }) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.