[IMP] note: add button and search filters on kanban view for active/inactive notes. Add note.tag. Html field on form view.

bzr revid: chm@openerp.com-20120907091708-z9x8g9tzdu6e7oad
This commit is contained in:
Christophe Matthieu 2012-09-07 11:17:08 +02:00
parent 29dba2a64f
commit 481c300cc5
8 changed files with 212 additions and 148 deletions

View File

@ -44,6 +44,7 @@ Notes can be found in the 'Home' menu.
'pad',
],
'data': [
'security/res.groups.csv',
'security/note_security.xml',
'security/ir.model.access.csv',
'note_data.xml',

View File

@ -21,6 +21,7 @@
from openerp.osv import osv, fields
from tools.translate import _
import re
class note_stage(osv.osv):
""" Category of Note """
@ -39,6 +40,15 @@ class note_stage(osv.osv):
'sequence' : 1,
}
class note_tag(osv.osv):
_name = "note.tag"
_description = "User can make tags on his note."
_columns = {
'name' : fields.char('Tag name', size=64, required=True),
}
class note_note(osv.osv):
""" Note """
_name = 'note.note'
@ -52,7 +62,11 @@ class note_note(osv.osv):
def _get_note_first_line(self, cr, uid, ids, name, args, context=None):
res = {}
for note in self.browse(cr, uid, ids, context=context):
res[note.id] = (note.note or '').strip().split('\n')[0]
text_note = (note.note or '').strip().split('\n')[0]
text_note = re.sub(r'(<br[ /]*>|</p>|</div>)[\s\S]*','',text_note)
text_note = re.sub(r'<[^>]+>','',text_note)
res[note.id] = text_note
return res
def _get_default_stage_id(self,cr,uid,context=None):
@ -70,16 +84,42 @@ class note_note(osv.osv):
result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context)
return result
def onclick_note_is_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'active' : False, 'date_done' : fields.date.today() })
self.message_post(cr, uid, ids[0], body='This note is active', subject=False,
type='notification', parent_id=False, attachments=None, context=context)
return False
def onclick_note_not_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'active' : True })
self.message_post(cr, uid, ids[0], body='This note is done', subject=False,
type='notification', parent_id=False, attachments=None, context=context)
return False
_columns = {
'name': fields.function(_get_note_first_line, fnct_inv=_set_note_first_line, string='Note Summary', type="text"),
'note': fields.text('Pad Content'),
'name': fields.function(_get_note_first_line, fnct_inv=_set_note_first_line, string='Note Summary', type='text'),
'note': fields.html('Pad Content'),
'note_pad_url': fields.char('Pad Url', size=250),
'sequence': fields.integer('Sequence'),
# the stage_id depending on the uid
'stage_id': fields.many2one('note.stage', 'Stage'),
# ERROR for related & stage_ids => group_by for kanban
#'stage_id': fields.related('stage_ids', 'id', string='Stage', type="many2one", relation="note.stage"),
# stage per user
#'stage_ids': fields.many2many('note.stage','note_stage_rel','note_id','stage_id','Linked stages users'),
'active': fields.boolean('Active'),
# when the user unactivate the note, record de date for un display note after 1 days
'date_done': fields.date('Date done'),
'color': fields.integer('Color Index'),
# to be replaced by message_follower_ids
'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers')
# put tags on the note (optional)
'tag_ids' : fields.many2many('note.tag','note_tags_rel','note_id','tag_id','Tags'),
}
_defaults = {
@ -91,3 +131,4 @@ class note_note(osv.osv):
_group_by_full = {
'stage_id' : _read_group_stage_ids,
}

View File

@ -3,24 +3,22 @@
<data>
<record id="note_1" model="note.note">
<field name="note"><![CDATA[Buying list
* coffee
* fruits
* ice cream
* towels
]]>
<field name="note"><![CDATA[Customer report #349872
* Calendar app in Home
* The base_calendar module should create a menu in Home, like described above.
* This module should become a main application (in the first screen at installation)
* We should use the term Calendar, not Meeting.
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_01"/>
<field name="user_id" ref="base.user_root"/>
<field name="color">2</field>
</record>
<record id="note_2" model="note.note">
<field name="note"><![CDATA[Buying list
* more coffee
* tee
* sugar
* towels
<field name="note"><![CDATA[Call Fabien
* Followed by the telephone conversation and mail about D.544.3
]]>
</field>
<field name="note_pad"></field>
@ -29,26 +27,7 @@
</record>
<record id="note_3" model="note.note">
<field name="note"><![CDATA[Idea to develop
* Phasellus vel eros lorem, vel tristique risus.
* Cras elementum risus ut massa bibendum ac sollicitudin quam feugiat.
* Phasellus ullamcorper mauris quis lectus volutpat non dignissim elit lacinia.
Nulla vitae metus risus, nec placerat diam.
Proin quis nunc sodales dolor tempus eleifend.
Praesent iaculis libero ut orci egestas a dapibus libero ornare.
* Proin at nisl sit amet ante feugiat euismod nec at orci.
* Nam aliquam massa id neque tincidunt eu pellentesque neque euismod.
* Proin eget mi sit amet erat tempus pellentesque.
* Phasellus congue est lectus, vitae semper arcu.
* Suspendisse sodales tortor ut odio volutpat fringilla.
* Vestibulum mattis est quis risus dignissim sit amet faucibus nisl mattis.
* Pellentesque ullamcorper neque neque, vitae rhoncus massa.
Ut id magna massa, quis scelerisque sapien.
<field name="note"><![CDATA[Call Marc
]]>
</field>
<field name="note_pad"></field>
@ -57,10 +36,8 @@
</record>
<record id="note_4" model="note.note">
<field name="note"><![CDATA[Read some documentation about OpenERP before diving into the code
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
]]>
<field name="note"><![CDATA[Project N.947.5
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_02"/>
@ -68,34 +45,21 @@
</record>
<record id="note_5" model="note.note">
<field name="note"><![CDATA[New computer specs
* Motherboard
according to processor
* Processor
need to decide
* Graphic card
with great performance for games !
* Hard drive
big, for lot of internet backups
* Tower
silent, better when watching films
* Blueray drive ?
is it interesting yet ?
* Screen
a big one, full of pixels, of course !
]]>
<field name="note"><![CDATA[Shop for family dinner
* stuffed turkey
* wine
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_02"/>
<field name="user_id" ref="base.user_root"/>
<field name="color">3</field>
</record>
<record id="note_6" model="note.note">
<field name="note"><![CDATA[Read those books
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
]]>
<field name="note"><![CDATA[Idea to develop
* Create a module note_pad
it transforms the html editable note text field into widget='pad', similar to project_pad depends on 'note' and 'pad' modules
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_02"/>
@ -114,6 +78,52 @@
</record>
<record id="note_8" model="note.note">
<field name="note"><![CDATA[New computer specs
* Motherboard
according to processor
* Processor
need to decide
* Graphic card
with great performance for games !
* Hard drive
big, for lot of internet backups
* Tower
silent, better when watching films
* Blueray drive ?
is it interesting yet ?
* Screen
a big one, full of pixels, of course !
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_03"/>
<field name="user_id" ref="base.user_root"/>
<field name="color">3</field>
</record>
<record id="note_9" model="note.note">
<field name="note"><![CDATA[Read those books
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_02"/>
<field name="user_id" ref="base.user_root"/>
</record>
<record id="note_10" model="note.note">
<field name="note"><![CDATA[Read some documentation about OpenERP before diving into the code
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
]]>
</field>
<field name="note_pad"></field>
<field name="stage_id" ref="note_stage_03"/>
<field name="user_id" ref="base.user_root"/>
</record>
<record id="note_11" model="note.note">
<field name="note"><![CDATA[Read those books
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
@ -125,7 +135,7 @@
<field name="color">5</field>
</record>
<record id="note_9" model="note.note">
<record id="note_12" model="note.note">
<field name="note"><![CDATA[Read some documentation about OpenERP before diving into the code
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management
@ -137,7 +147,7 @@
<field name="color">7</field>
</record>
<record id="note_10" model="note.note">
<record id="note_13" model="note.note">
<field name="note"><![CDATA[Read those books
* Open ERP: a modern approach to integrated business management
* Open ERP for Retail and Industrial Management

View File

@ -54,29 +54,37 @@
<field name="stage_id"/>
<field name="active"/>
<field name="note"/>
<field name="follower_ids"/>
<field name="date_done"/>
<field name="message_follower_ids"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click oe_semantic_html_override">
<!-- dropdown menu -->
<div class="oe_dropdown_toggle oe_dropdown_kanban">
<span class="oe_e">í</span>
<ul class="oe_dropdown_menu">
<li><a type="edit">Edit...</a></li>
<li><a type="delete">Delete</a></li>
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
</ul>
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click oe_semantic_html_override ">
<div class="oe_dropdown_kanban">
<span>
<a name="onclick_note_is_done" type="object" t-if="record.active.raw_value" class="oe_e">D</a>
<a name="onclick_note_not_done" type="object" t-if="!record.active.raw_value" class="oe_e">C</a>
</span>
<!-- dropdown menu -->
<div class="oe_dropdown_toggle">
<span class="oe_e">í</span>
<ul class="oe_dropdown_menu">
<li><a type="edit">Edit...</a></li>
<li><a type="delete">Delete</a></li>
<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
</ul>
</div>
</div>
<!-- kanban note -->
<div class="oe_kanban_content">
<div t-attf-class="oe_kanban_content #{record.active.raw_value ? '' : 'note_text_line_through'}">
<!-- title -->
<field name="name"/>
</div>
<div class="oe_kanban_project_avatars">
<t t-foreach="record.follower_ids.raw_value" t-as="follower">
<img t-att-src="kanban_image('res.users', 'image_small', follower)" t-att-data-member_id="follower"/>
<div class="oe_right">
<t t-foreach="record.message_follower_ids.raw_value" t-as="follower">
<img t-att-src="kanban_image('res.partner', 'image_small', follower)" width="24" height="24" class="oe_kanban_avatar" t-att-data-member_id="follower"/>
</t>
</div>
</div>
@ -96,7 +104,8 @@
<header>
<field name="stage_id" domain="[('user_id','=',uid)]" widget="statusbar" clickable="1"/>
</header>
<field name="note"/>
<field name="note" widget="html" editor_width="100%%" editor_height="400px" nolabel="1"/>
<field name="tag_ids" widget="many2many_tags" group="group_note_tags" string="Tags"/>
<field name="note_pad_url" invisible="1"/>
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
@ -113,6 +122,8 @@
<search string="Notes">
<field name="note" string="Note"/>
<field name="stage_id"/>
<filter name="active_true" string="Active" domain="['|',('active', '=', True),('date_done','=',time.strftime('%%Y-%%m-%%d'))]"/>
<filter name="active_false" string="Old" domain="[('active', '=', False)]"/>
<group expand="0" string="Group By...">
<filter icon="terp-personal" string="Creator" help="By Creators" context="{'group_by':'create_uid'}"/>
<filter icon="terp-stock_symbol-selection" string="Stage" help="By Note Category" context="{'group_by':'stage_id'}"/>
@ -128,9 +139,10 @@
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="view_note_note_filter"/>
<field name="context">{'search_default_active_true':True}</field>
</record>
<menuitem name="Notes" id="note_notes" parent="note_my_stuff" sequence="20" action="action_note_note"/>
</data>
</openerp>
</openerp>

View File

@ -5,7 +5,7 @@
<field name="name">My notes</field>
<field ref="model_note_note" name="model_id"/>
<field eval="1" name="global"/>
<field name="domain_force">[('follower_ids','=',user.id)]</field>
<field name="domain_force">[('message_follower_ids','=',user.partner_id.id)]</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,3 @@
id,name,implied_ids/id
group_note_tags,Note : display tags,
group_note_fancy,Note : fancy mode,
1 id name implied_ids/id
2 group_note_tags Note : display tags
3 group_note_fancy Note : fancy mode

View File

@ -1,78 +1,73 @@
.openerp .oe_notes .oe_fold_column .oe_kanban_card {
text-decoration:none;
color:#000;
display:block;
padding:1em;
margin-right: 1em;
margin-bottom: 1em;
-moz-box-shadow:5px 5px 7px rgba(33,33,33,1);
-webkit-box-shadow: 5px 5px 7px rgba(33,33,33,.7);
box-shadow: 5px 5px 7px rgba(33,33,33,.7);
@charset "utf-8";
@font-face {
font-family: "mnmliconsRegular";
src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot");
src: url("/web/static/src/font/mnmliconsv21-webfont.woff") format("woff");
src: url("/web/static/src/font/mnmliconsv21-webfont.ttf") format("truetype");
src: url("/web/static/src/font/mnmliconsv21-webfont.svg") format("svg") active;
font-weight: normal;
font-style: normal;
}
.openerp .oe_notes .oe_kanban_record .oe_kanban_card {
-webkit-transform: rotate(-2deg);
-o-transform: rotate(-2deg);
-moz-transform:rotate(-2deg);
@font-face {
font-family: "EntypoRegular";
src: url("/web/static/src/font/entypo-webfont.eot") format("eot");
src: url("/web/static/src/font/entypo-webfont.eot?#iefix") format("embedded-opentype");
src: url("/web/static/src/font/entypo-webfont.woff") format("woff");
src: url("/web/static/src/font/entypo-webfont.ttf") format("truetype");
src: url("/web/static/src/font/entypo-webfont.svg") format("svg") active;
font-weight: normal;
font-style: normal;
}
.openerp .oe_notes .oe_kanban_record:nth-of-type(even) .oe_kanban_card {
-webkit-transform: rotate(1deg);
-o-transform: rotate(1deg);
-moz-transform:rotate(1deg);
@-moz-keyframes bounce {
0% {
-moz-transform: scale(0);
opacity: 0;
}
50% {
-moz-transform: scale(1.3);
opacity: 0.4;
}
75% {
-moz-transform: scale(0.9);
opacity: 0.7;
}
100% {
-moz-transform: scale(1);
opacity: 1;
}
}
.openerp .oe_notes .oe_kanban_record:nth-of-type(3n) .oe_kanban_card {
-webkit-transform: rotate(4deg);
-o-transform: rotate(4deg);
-moz-transform:rotate(4deg);
@-webkit-keyframes bounce {
0% {
-webkit-transform: scale(0);
opacity: 0;
}
50% {
-webkit-transform: scale(1.3);
opacity: 0.4;
}
75% {
-webkit-transform: scale(0.9);
opacity: 0.7;
}
100% {
-webkit-transform: scale(1);
opacity: 1;
}
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(even) .oe_kanban_record .oe_kanban_card {
-webkit-transform: rotate(2deg);
-o-transform: rotate(2deg);
-moz-transform:rotate(2deg);
.oe_kanban_color_2 {
background-color: red;
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(even) .oe_kanban_record:nth-of-type(even) .oe_kanban_card {
-webkit-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-moz-transform:rotate(-3deg);
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(even) .oe_kanban_record:nth-of-type(3n) .oe_kanban_card {
-webkit-transform: rotate(1deg);
-o-transform: rotate(1deg);
-moz-transform:rotate(1deg);
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(3n) .oe_kanban_record .oe_kanban_card {
-webkit-transform: rotate(-2deg);
-o-transform: rotate(-2deg);
-moz-transform:rotate(-2deg);
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(3n) .oe_kanban_record:nth-of-type(even) .oe_kanban_card {
-webkit-transform: rotate(1deg);
-o-transform: rotate(1deg);
-moz-transform:rotate(1deg);
}
.openerp .oe_notes .oe_kanban_column:nth-of-type(3n) .oe_kanban_record:nth-of-type(3n) .oe_kanban_card {
-webkit-transform: rotate(-1deg);
-o-transform: rotate(-1deg);
-moz-transform:rotate(-1deg);
}
.openerp .oe_notes .oe_kanban_column .oe_fold_column .oe_kanban_card:hover,
.openerp .oe_notes .oe_kanban_column .oe_fold_column .oe_kanban_card:focus {
box-shadow:10px 10px 7px rgba(0,0,0,.7);
-moz-box-shadow:10px 10px 7px rgba(0,0,0,.7);
-webkit-box-shadow: 10px 10px 7px rgba(0,0,0,.7);
-webkit-transform: rotate(0);
-moz-transform: rotate(0);
-o-transform: rotate(0);
position:relative;
z-index:5;
.oe_kanban_column .note_text_line_through {
text-decoration: line-through;
}

View File

@ -131,7 +131,9 @@ $sheet-max-width: 860px
.oe_kanban_color_2
background-color:red
background-color: red
// au BufWritePost,FileWritePost *.sass :!sass --style expanded --line-numbers <afile> > "%:p:r.css"
.oe_kanban_column .note_text_line_through
text-decoration: line-through