Elouan Le Bars
5 years ago
9 changed files with 5 additions and 292 deletions
-
1easy_my_coop_document/__init__.py
-
35easy_my_coop_document/__manifest__.py
-
1easy_my_coop_document/models/__init__.py
-
80easy_my_coop_document/models/document.py
-
5easy_my_coop_document/security/ir.model.access.csv
-
39easy_my_coop_document/views/easy_my_coop_document_menu.xml
-
126easy_my_coop_document/views/easy_my_coop_document_views.xml
-
2easy_my_coop_website_document/__manifest__.py
-
8easy_my_coop_website_document/controllers/main.py
@ -1 +0,0 @@ |
|||
from . import models |
@ -1,35 +0,0 @@ |
|||
|
|||
# Copyright 2018 Rémy Taymans <remytaymans@gmail.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
# migrate in v12 and isolate from emc |
|||
# add manager group or use relevant existing group |
|||
# add ir.model.access rules for that user |
|||
'name': 'Easy My Coop Document', |
|||
|
|||
'summary': """ |
|||
Manage the documents of your cooperative. |
|||
""", |
|||
'description': """ |
|||
""", |
|||
|
|||
'author': 'Rémy Taymans', |
|||
'license': 'AGPL-3', |
|||
'version': '12.0.1.0.0', |
|||
'website': "https://github.com/coopiteasy/vertical-cooperative", |
|||
|
|||
'category': 'Cooperative Management', |
|||
|
|||
'depends': [ |
|||
'base', |
|||
'web', |
|||
'mail', |
|||
], |
|||
|
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'views/easy_my_coop_document_menu.xml', |
|||
'views/easy_my_coop_document_views.xml', |
|||
] |
|||
} |
@ -1 +0,0 @@ |
|||
from . import document |
@ -1,80 +0,0 @@ |
|||
|
|||
# Copyright 2018 Rémy Taymans <remytaymans@gmail.com> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
|
|||
from odoo import models, fields, api |
|||
|
|||
|
|||
class Document(models.Model): |
|||
_name = 'easy_my_coop.document' |
|||
_description = "Document" |
|||
_order = 'document_date desc, name' |
|||
_inherit = 'mail.thread' |
|||
|
|||
name = fields.Char("Name", required=True) |
|||
description = fields.Text("Description") |
|||
document = fields.Binary('Document', attachment=True, required=True) |
|||
filename = fields.Char("Document File Name") |
|||
mimetype = fields.Char("Mime-Type", compute='_mimetype') |
|||
file_size = fields.Integer("File Size", compute='_file_size') |
|||
document_date = fields.Date("Document Date", |
|||
default=fields.Date.today()) |
|||
category = fields.Many2one('easy_my_coop.document.category', |
|||
string="Category") |
|||
published = fields.Boolean("Published?") |
|||
publication_date = fields.Datetime("Publication Date", |
|||
compute='_publication_date', |
|||
store=True) |
|||
public = fields.Boolean("Public?") |
|||
|
|||
@api.depends('document') |
|||
def _mimetype(self): |
|||
for doc in self: |
|||
attachment_mgr = self.env['ir.attachment'].sudo() |
|||
attachment = attachment_mgr.search_read( |
|||
[('res_model', '=', self._name), |
|||
('res_id', '=', doc.id), |
|||
('res_field', '=', 'document')], |
|||
fields=['mimetype', 'file_size'], |
|||
limit=1, |
|||
)[0] |
|||
doc.mimetype = attachment['mimetype'] |
|||
|
|||
@api.depends('document') |
|||
def _file_size(self): |
|||
for doc in self: |
|||
attachment_mgr = self.env['ir.attachment'].sudo() |
|||
attachment = attachment_mgr.search_read( |
|||
[('res_model', '=', self._name), |
|||
('res_id', '=', doc.id), |
|||
('res_field', '=', 'document')], |
|||
fields=['mimetype', 'file_size'], |
|||
limit=1, |
|||
)[0] |
|||
doc.file_size = attachment['file_size'] |
|||
|
|||
@api.depends('published') |
|||
def _publication_date(self): |
|||
for doc in self: |
|||
if doc.published and not doc.publication_date: |
|||
doc.publication_date = fields.Datetime.now() |
|||
if not doc.published: |
|||
doc.publication_date = False |
|||
|
|||
|
|||
class Category(models.Model): |
|||
_name = 'easy_my_coop.document.category' |
|||
_description = "Category" |
|||
_order = 'name' |
|||
|
|||
name = fields.Char("Name", required=True) |
|||
description = fields.Text("Description") |
|||
parent_id = fields.Many2one('easy_my_coop.document.category', |
|||
string="Parent Category") |
|||
child_ids = fields.One2many('easy_my_coop.document.category', |
|||
'parent_id', |
|||
string="Child Categories") |
|||
document_ids = fields.One2many('easy_my_coop.document', |
|||
'category', |
|||
string="Documents") |
@ -1,5 +0,0 @@ |
|||
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_easy_my_coop_document_user_group,access_easy_my_coop_document,model_easy_my_coop_document,base.group_user,1,0,0,0 |
|||
access_easy_my_coop_document_category_user_group,access_easy_my_coop_document_category,model_easy_my_coop_document_category,base.group_user,1,0,0,0 |
|||
access_easy_my_coop_document_manager,access_easy_my_coop_document,model_easy_my_coop_document,,1,1,1,1 |
|||
access_easy_my_coop_document_category_manager,access_easy_my_coop_document_category,model_easy_my_coop_document_category,,1,1,1,1 |
@ -1,39 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
Copyright 2018 Rémy Taymans <remytaymans@gmail.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
<odoo> |
|||
<data> |
|||
|
|||
<!-- Action to open document list --> |
|||
<act_window id="action_easy_my_coop_document" |
|||
name="Document" |
|||
res_model="easy_my_coop.document" |
|||
view_mode="tree,form" /> |
|||
|
|||
<!-- Action to open category list --> |
|||
<act_window id="action_easy_my_coop_document_category" |
|||
name="Categories" |
|||
res_model="easy_my_coop.document.category" |
|||
view_mode="tree,form" /> |
|||
|
|||
<!-- Root menu for document --> |
|||
<menuitem id="menu_main_easy_my_coop_document" |
|||
name="Documents" |
|||
sequence="45" /> |
|||
|
|||
<!-- Menu item to open Document list --> |
|||
<menuitem id="menu_document" |
|||
name="Documents" |
|||
parent="menu_main_easy_my_coop_document" |
|||
action="action_easy_my_coop_document" /> |
|||
|
|||
<!-- Menu item to open Category list --> |
|||
<menuitem id="menu_category" |
|||
name="Categories" |
|||
parent="menu_main_easy_my_coop_document" |
|||
action="action_easy_my_coop_document_category" /> |
|||
|
|||
</data> |
|||
</odoo> |
@ -1,126 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
Copyright 2018 Rémy Taymans <remytaymans@gmail.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
<odoo> |
|||
<data> |
|||
|
|||
<!-- Document form view --> |
|||
<record id="view_form_document" model="ir.ui.view"> |
|||
<field name="name">Document Form</field> |
|||
<field name="model">easy_my_coop.document</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Documents"> |
|||
<sheet> |
|||
<div class="oe_title"> |
|||
<label for="name" class="oe_edit_only"/> |
|||
<h1><field name="name"/></h1> |
|||
</div> |
|||
<group> |
|||
<group> |
|||
<field name="filename" invisible="1"/> |
|||
<field name="document" filename="filename"/> |
|||
<field name="document_date"/> |
|||
<field name="description"/> |
|||
</group> |
|||
<group> |
|||
<field name="public"/> |
|||
<field name="category"/> |
|||
</group> |
|||
</group> |
|||
<group> |
|||
<field name="published"/> |
|||
<field name="publication_date" readonly="True"/> |
|||
</group> |
|||
</sheet> |
|||
<!-- Communication --> |
|||
<div class="oe_chatter"> |
|||
<field name="message_follower_ids" widget="mail_followers" /> |
|||
<field name="message_ids" widget="mail_thread" /> |
|||
</div> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Document tree view --> |
|||
<record id="view_tree_document" model="ir.ui.view"> |
|||
<field name="name">Document Tree</field> |
|||
<field name="model">easy_my_coop.document</field> |
|||
<field name="arch" type="xml"> |
|||
<tree decoration-muted="not published"> |
|||
<field name="name"/> |
|||
<field name="document" filename="filename"/> |
|||
<field name="document_date"/> |
|||
<field name="description"/> |
|||
<field name="public"/> |
|||
<field name="category"/> |
|||
<field name="published"/> |
|||
<field name="publication_date"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Document search view --> |
|||
<record id="view_search_document" model="ir.ui.view"> |
|||
<field name="name">Document Search</field> |
|||
<field name="model">easy_my_coop.document</field> |
|||
<field name="arch" type="xml"> |
|||
<search> |
|||
<field name="name"/> |
|||
<field name="category"/> |
|||
<filter name="public" string="Public" domain="[('public', '=', True)]"/> |
|||
<filter name="published" string="Published" domain="[('published', '=', True)]"/> |
|||
<filter name="category" string="Category" context="{'group_by': 'category'}"/> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Category form view --> |
|||
<record id="view_form_category" model="ir.ui.view"> |
|||
<field name="name">Category Form</field> |
|||
<field name="model">easy_my_coop.document.category</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Categories"> |
|||
<sheet> |
|||
<div class="oe_title"> |
|||
<label for="name" class="oe_edit_only"/> |
|||
<h1><field name="name"/></h1> |
|||
</div> |
|||
<group> |
|||
<field name="description"/> |
|||
<field name="parent_id"/> |
|||
</group> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Category tree view --> |
|||
<record id="view_tree_category" model="ir.ui.view"> |
|||
<field name="name">Category Tree</field> |
|||
<field name="model">easy_my_coop.document.category</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="name"/> |
|||
<field name="description"/> |
|||
<field name="parent_id"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Category search view --> |
|||
<record id="view_search_category" model="ir.ui.view"> |
|||
<field name="name">Category Search</field> |
|||
<field name="model">easy_my_coop.document.category</field> |
|||
<field name="arch" type="xml"> |
|||
<search> |
|||
<field name="name"/> |
|||
<filter name="parent_category" string="Parent Category" |
|||
context="{'group_by': 'parent_id'}"/> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue