[IMP] note: search, css

bzr revid: chm@openerp.com-20120917123054-futj80nzfo725kiv
This commit is contained in:
Christophe Matthieu
2012-09-17 14:30:54 +02:00
parent 378b77a5e4
commit 313c4ef511
4 changed files with 30 additions and 22 deletions
+12 -5
View File
@@ -22,6 +22,7 @@
from openerp.osv import osv, fields
from tools.translate import _
import re
from openerp.tools.misc import html2plaintext
class note_stage(osv.osv):
""" Category of Note """
@@ -60,6 +61,10 @@ class note_note(osv.osv):
rec_id = self.create(cr, uid, {'memo': name}, context=context)
return self.name_get(cr, uid, [rec_id], context)[0]
def _from_xml(self, mappings):
return chr(int( mappings.group(1) ))
#read the first line (convert hml into text)
def _get_note_first_line(self, cr, uid, ids, name="", args={}, context=None):
res = {}
@@ -67,13 +72,14 @@ class note_note(osv.osv):
text_note = (note.memo or '').strip().split('\n')[0]
text_note = re.sub(r'(\S?)(<br[ /]*>|<[/]?p>|<[/]?div>|<table>)[\s\S]*',r'\1',text_note)
text_note = re.sub(r'<[^>]+>','',text_note)
text_note = html2plaintext(text_note)
res[note.id] = text_note
return res
#unactivate a sticky note and record the date
def onclick_note_is_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'active' : False, 'date_done' : fields.date.today() })
self.write(cr, uid, ids, { 'open' : False, 'date_done' : fields.date.today() })
self.message_post(cr, uid, ids[0], body='This sticky note is active', subject=False,
type='notification', parent_id=False, attachments=None, context=context)
@@ -82,7 +88,7 @@ class note_note(osv.osv):
#activate a Sticky note
def onclick_note_not_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'active' : True })
self.write(cr, uid, ids, { 'open' : True })
self.message_post(cr, uid, ids[0], body='This sticky note is close', subject=False,
type='notification', parent_id=False, attachments=None, context=context)
@@ -124,7 +130,8 @@ class note_note(osv.osv):
_columns = {
'name': fields.function(_get_note_first_line,
string='Sticky note Summary',
type='text', store=True),
type='text',
store=True),
'memo': fields.html('Pad Content'),
'sequence': fields.integer('Sequence'),
@@ -140,7 +147,7 @@ class note_note(osv.osv):
# stage per user
'stage_ids': fields.many2many('note.stage','note_stage_rel','note_id','stage_id','Linked stages users'),
'active': fields.boolean('Active'),
'open': fields.boolean('Active'),
# when the user unactivate the Sticky note, record de date for un display Sticky note after 1 days
'date_done': fields.date('Date done'),
'color': fields.integer('Color Index'),
@@ -151,7 +158,7 @@ class note_note(osv.osv):
}
_defaults = {
'active' : 1,
'open' : 1,
'stage_id' : _get_default_stage_id,
'memo': " "
}
-9
View File
@@ -115,14 +115,5 @@
<field name="color">7</field>
</record>
<record id="note_13" model="note.note">
<field name="memo"><![CDATA[Read those books
<br/><br/>* Open ERP: a modern approach to integrated business management
<br/>* Open ERP for Retail and Industrial Management
]]>
</field>
<field name="stage_id" ref="note_stage_03"/>
</record>
</data>
</openerp>
+9 -8
View File
@@ -51,7 +51,7 @@
<field name="sequence"/>
<field name="name"/>
<field name="stage_id"/>
<field name="active"/>
<field name="open"/>
<field name="memo"/>
<field name="date_done"/>
<field name="current_partner_id"/>
@@ -65,8 +65,8 @@
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_global_click_edit oe_semantic_html_override oe_kanban_card #{record.group_fancy==1 ? 'oe_kanban_card_fancy' : ''}">
<div class="oe_dropdown_kanban">
<span>
<a name="onclick_note_is_done" type="object" t-if="record.active.raw_value" class="oe_e">W</a>
<a name="onclick_note_not_done" type="object" t-if="!record.active.raw_value" class="oe_e">è</a>
<a name="onclick_note_is_done" type="object" t-if="record.open.raw_value" class="oe_e">W</a>
<a name="onclick_note_not_done" type="object" t-if="!record.open.raw_value" class="oe_e">è</a>
</span>
<!-- dropdown menu -->
@@ -80,7 +80,7 @@
</div>
<!-- kanban memo -->
<div t-attf-class="oe_kanban_content #{record.active.raw_value ? '' : 'note_text_line_through'}">
<div t-attf-class="oe_kanban_content #{record.open.raw_value ? '' : 'note_text_line_through'}">
<!-- title -->
<field name="name"/>
</div>
@@ -107,7 +107,7 @@
<field name="arch" type="xml">
<tree string="Stages">
<field name="name"/>
<field name="active"/>
<field name="open"/>
<field name="stage_id"/>
<field name="tag_ids" widget="many2many_tags" groups="note.group_note_tags"/>
</tree>
@@ -143,8 +143,9 @@
<field name="memo" string="Sticky note"/>
<field name="stage_id"/>
<field name="tag_ids" groups="note.group_note_tags"/>
<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)]"/>
<filter name="open_true" string="Active" domain="[('open', '=', True)]"/>
<filter name="open_today" string="Today" domain="['|',('open', '=', True),('date_done','=',time.strftime('%%Y-%%m-%%d'))]"/>
<filter name="open_false" string="Older" domain="[('open', '=', False)]"/>
<group expand="0" string="Group By...">
<filter icon="terp-stock_symbol-selection" string="Stage" help="By sticky note Category" context="{'group_by':'stage_id'}"/>
</group>
@@ -188,7 +189,7 @@
<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>
<field name="context">{'search_default_open_true':True}</field>
</record>
<menuitem name="Sticky notes" id="note_notes" parent="note_my_stuff" sequence="20" action="action_note_note"/>
+9
View File
@@ -1,12 +1,21 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="note_note_rule_global" model="ir.rule">
<field name="name">Only followers can access a sticky notes</field>
<field model="ir.model" ref="model_note_note" name="model_id"/>
<field name="domain_force">['|',('message_follower_ids','=',False),('message_follower_ids','=',user.partner_id.id)]</field>
<field eval="True" name="global"/>
</record>
<record id="note_stage_rule_global" model="ir.rule">
<field name="name">Each user have his stage name</field>
<field model="ir.model" ref="model_note_stage" name="model_id"/>
<field name="domain_force">['|',('user_id','=',False),('user_id','=',user.id)]</field>
<field eval="True" name="global"/>
</record>
</data>
</openerp>