[IMP] *: add archive/unarchive feature on some models

Add the statbutton, search filter, and enable the kanban column archiving on
models `res.partner`, `crm.lead`, `event.event`, `hr.employee`, `hr.applicant`,
`mail.mass_mailing`, `mail.mass_mailing.list`, `product.product`,
`project.project`, `project.task`, `project.issue`.
This commit is contained in:
Raphael Collet
2015-09-02 14:29:42 +02:00
parent 8af431d906
commit ed95043d7e
12 changed files with 96 additions and 34 deletions
+10 -15
View File
@@ -106,25 +106,24 @@
<header>
<button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action"
help="Convert to Opportunity" class="oe_highlight"/>
<button name="action_set_unactive" string="Archive"
type="object" class="oe_highlight"
attrs="{'invisible': ['|', ('active','=',False), ('probability', '&lt;', 100)]}"/>
<button name="action_set_won" string="Mark Won"
type="object" class="oe_highlight"
attrs="{'invisible': ['|', ('active','=',False), ('probability', '=', 100)]}"/>
<button name="action_set_lost" string="Mark Lost"
type="object" class="oe_highlight"
attrs="{'invisible': [('active', '=', False)]}"/>
<button name="action_set_active" string="Unarchive"
type="object" class="oe_highlight"
attrs="{'invisible': [('active', '=', True)]}"/>
<field name="stage_id" widget="statusbar" clickable="True"
domain="['&amp;', ('team_ids', '=', team_id), '|', ('type', '=', type), ('type', '=', 'both')]"
options="{'fold_field': 'fold'}"
on_change="onchange_stage_id(stage_id)"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"
attrs="{'invisible': [('active', '=', True), ('probability', '&lt;', 100)]}">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
</div>
<div class="label label-danger pull-right" attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}">Lost</div>
<div class="label label-success pull-right" attrs="{'invisible': [('probability', '&lt;', 100)]}">Won</div>
<div class="oe_title">
@@ -192,7 +191,6 @@
</group>
<group string="Opportunity" name="misc">
<field name="probability" groups="base.group_no_one"/>
<field name="active"/>
</group>
<group string="Analysis" groups="base.group_no_one">
<field name="date_open"/>
@@ -408,9 +406,6 @@
<field name="arch" type="xml">
<form string="Opportunities">
<header>
<button name="action_set_unactive" string="Archive"
type="object" class="oe_highlight"
attrs="{'invisible': ['|', ('active','=',False), ('probability', '&lt;', 100)]}"/>
<button name="action_set_won" string="Mark Won"
type="object" class="oe_highlight"
attrs="{'invisible': ['|', ('active','=',False), ('probability', '=', 100)]}"/>
@@ -418,9 +413,6 @@
type="action" class="oe_highlight"
context="{'default_lead_id': active_id}"
attrs="{'invisible': [('active', '=', False)]}"/>
<button name="action_set_active" string="Unarchive"
type="object" class="oe_highlight"
attrs="{'invisible': [('active', '=', True)]}"/>
<field name="stage_id" widget="statusbar" clickable="True"
options="{'fold_field': 'fold'}"
domain="['&amp;', ('team_ids', '=', team_id), '|', ('type', '=', type), ('type', '=', 'both')]"
@@ -428,6 +420,10 @@
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"
attrs="{'invisible': [('active', '=', True), ('probability', '&lt;', 100)]}">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
<button class="oe_stat_button" type="object"
context="{'partner_id': partner_id}"
name="action_schedule_meeting" icon="fa-calendar">
@@ -553,7 +549,6 @@
<field name="source_id" />
</group>
<group string="Misc" name="Misc">
<field name="active"/>
<field name="day_open" groups="base.group_no_one"/>
<field name="day_close" groups="base.group_no_one"/>
<field name="referred"/>
+1
View File
@@ -31,6 +31,7 @@ class event_event(models.Model):
name = fields.Char(
string='Name', translate=True, required=True,
readonly=False, states={'done': [('readonly', True)]})
active = fields.Boolean(default=True, track_visibility="onchange")
user_id = fields.Many2one(
'res.users', string='Responsible',
default=lambda self: self.env.user,
+6
View File
@@ -66,6 +66,11 @@
</header>
<sheet>
<div class="oe_button_box" name="button_box" groups="base.group_user">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
<button name="%(event.act_event_registration_from_event)d"
type="action"
class="oe_stat_button oe_event_attendee_button"
@@ -230,6 +235,7 @@
<separator/>
<filter string="Unconfirmed" name="draft" domain="[('state','=','draft')]" help="Events in New state"/>
<filter string="Confirmed" domain="[('state','=','confirm')]" help="Confirmed events"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<separator/>
<filter string="My Events" help="My Events" domain="[('user_id','=',uid)]"/>
<separator/>
+8 -2
View File
@@ -20,7 +20,13 @@
<field name="arch" type="xml">
<form string="Employee">
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_button_box" name="button_box" groups="base.group_hr_user">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<field name="image" widget='image' class="oe_avatar" options='{"preview_image":"image_medium"}'/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
@@ -75,7 +81,6 @@
<page string="HR Settings" groups="base.group_hr_user">
<group>
<group string='Status' name="active_group">
<field name="active"/>
<field name="company_id" groups="base.group_multi_company" on_change="onchange_company(company_id)"/>
<field name="user_id" on_change="onchange_user(name, image, user_id)" string="Related User"
context="{'default_groups_ref': ['base.group_user']}"/>
@@ -120,6 +125,7 @@
<field name="category_ids" groups="base.group_hr_user"/>
<field name="job_id" />
<filter string="Important Messages" name="message_needaction" domain="[('message_needaction','=',True)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<group expand="0" string="Group By">
<filter string="Manager" domain="[]" context="{'group_by':'parent_id'}"/>
<filter string="Coach" domain="[]" context="{'group_by':'coach_id'}"/>
@@ -107,6 +107,11 @@
attrs="{'invisible': [('emp_id', '=', False)]}">
<field name="employee_name" widget="statinfo" string="Employee"/>
</button>
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
@@ -142,7 +147,6 @@
<field name="medium_id" groups="base.group_no_one" />
<field name="source_id"/>
<field name="reference"/>
<field name="active" invisible="1"/>
</group>
<group string="Job">
<field name="survey" invisible="1"/>
@@ -214,6 +218,7 @@
domain="[('date_action','&lt;&gt;',False)]" help="Filter and view on next actions and date"/>
<separator/>
<filter string="Important Messages" name="message_needaction" domain="[('message_needaction','=',True)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<field name="job_id"/>
<field name="department_id"/>
<field name="user_id"/>
@@ -269,6 +274,7 @@
<field name="categ_ids"/>
<field name="message_needaction_counter"/>
<field name="attachment_number"/>
<field name="active"/>
<templates>
<t t-name="kanban-tooltip">
<ul class="oe_kanban_tooltip">
@@ -40,6 +40,7 @@ class MassMailingList(osv.Model):
_columns = {
'name': fields.char('Mailing List', required=True),
'active': fields.boolean('Active'),
'create_date': fields.datetime('Creation Date'),
'contact_nbr': fields.function(
_get_contact_nbr, type='integer',
@@ -61,6 +62,7 @@ class MassMailingList(osv.Model):
<p class="o_message_paragraph">Join our Marketing newsletter and get <strong>this white paper instantly</strong></p>"""
_defaults = {
'active': True,
'popup_content': _get_default_popup_content,
}
@@ -475,6 +477,7 @@ class MassMailing(osv.Model):
_columns = {
'name': fields.char('Subject', required=True),
'active': fields.boolean('Active'),
'email_from': fields.char('From', required=True),
'create_date': fields.datetime('Creation Date'),
'sent_date': fields.datetime('Sent Date', oldname='date', copy=False),
@@ -597,6 +600,7 @@ class MassMailing(osv.Model):
return res
_defaults = {
'active': True,
'state': 'draft',
'email_from': lambda self, cr, uid, ctx=None: self.pool['mail.message']._get_default_from(cr, uid, context=ctx),
'reply_to': lambda self, cr, uid, ctx=None: self.pool['mail.message']._get_default_from(cr, uid, context=ctx),
@@ -230,6 +230,7 @@
<search string="Mailing Lists">
<field name="name"/>
<field name="create_date"/>
<filter name="inactive" string="Archived" domain="[('active','=',False)]"/>
<group expand="0" string="Group By">
<filter string="Creation Month" name="group_create_date"
context="{'group_by': 'create_date'}"/>
@@ -258,6 +259,11 @@
<form string="Contact List">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
<button name="%(mass_mailing.action_view_mass_mailing_contacts_from_list)d"
type="action" icon="fa-user" class="oe_stat_button">
<field name="contact_nbr" string="Recipients" widget="statinfo"/>
@@ -308,6 +314,7 @@
<search string="Mass Mailings">
<field name="name" string="Mailings"/>
<field name="mass_mailing_campaign_id"/>
<filter name="inactive" string="Archived" domain="[('active','=',False)]"/>
<group expand="0" string="Group By">
<filter string="Status" name="group_state"
context="{'group_by': 'state'}"/>
@@ -432,6 +439,11 @@
type="action" class="oe_stat_button">
<field name="bounced_ratio" string="Bounced" widget="percentpie"/>
</button>
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<group>
+8 -2
View File
@@ -40,6 +40,7 @@
<filter string="Products" name="consumable" domain="[('type','=','consu')]" help="Products your store in the inventory"/>
<separator/>
<filter string="Can be Sold" name="filter_to_sell" domain="[('sale_ok','=',1)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<field string="Attributes" name="attribute_line_ids"/>
<field name="pricelist_id" widget="selection" context="{'pricelist': self}" filter_domain="[]" groups="product.group_sale_pricelist"/> <!-- Keep widget=selection on this field to pass numeric `self` value, which is not the case for regular m2o widgets! -->
</search>
@@ -80,7 +81,13 @@
<field name="is_product_variant" invisible="1"/>
<field name='product_variant_count' invisible='1'/>
<field name="id" invisible="True"/>
<div class="oe_button_box" name="button_box"/>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" groups="base.group_no_one"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<field name="image_medium" widget="image" class="oe_avatar"/>
<div class="oe_title">
<label class="oe_edit_only" for="name" string="Product Name"/>
@@ -99,7 +106,6 @@
<field name="type" on_change="onchange_type(type, context)"/>
</group>
<group name="group_standard_price">
<field name="active" groups="base.group_no_one"/>
<field name="list_price"/>
<label for="standard_price" groups="base.group_user"/>
<div name="standard_price_uom" groups="base.group_user">
+21 -8
View File
@@ -35,6 +35,7 @@
<filter string="New" name="draft" domain="[('stage_id.sequence', '&lt;=', 1)]"/>
<separator/>
<filter string="Important Messages" name="message_needaction" domain="[('message_needaction','=',True)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<group expand="0" string="Group By">
<filter string="Project" name="project" context="{'group_by':'project_id'}"/>
<filter string="Task" context="{'group_by':'name'}"/>
@@ -76,9 +77,6 @@
<field name="arch" type="xml">
<form string="Project">
<header>
<button name="set_template" string="Set as Template" type="object" states="open" groups="base.group_user"/>
<button string="New Project Based on Template" name="duplicate_template" type="object" states="template" class="oe_highlight" groups="base.group_user"/>
<button name="reset_project" string="Reset as Project" type="object" states="template" class="oe_highlight" groups="base.group_user"/>
<field name="state" widget="statusbar" clickable="True"/>
</header>
<sheet string="Project">
@@ -91,6 +89,13 @@
<button class="oe_stat_button" name="attachment_tree_view" type="object" icon="fa-files-o">
<field string="Documents" name="doc_count" widget="statinfo"/>
</button>
<button name="toggle_active" type="object"
confirm="(Un)archiving a project automatically (un)archives its tasks and issues. Do you want to proceed?"
class="oe_stat_button" icon="fa-archive"
attrs="{'invisible':[('state','in',['open', 'pending'])]}">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title">
<h1>
@@ -121,7 +126,6 @@
</group>
<group string="Configuration" groups="base.group_no_one">
<field name="sequence" groups="base.group_no_one"/>
<field name="active" attrs="{'invisible':[('state','in',['open', 'pending', 'template'])]}"/>
</group>
</group>
</page>
@@ -165,6 +169,7 @@
<filter string="Followed by Me" domain="[('message_is_follower','=',True)]"/>
<separator/>
<filter string="Important Messages" name="message_needaction" domain="[('message_needaction','=',True)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<field name="user_id" string="Project Manager"/>
<field name="partner_id" string="Contact" filter_domain="[('partner_id', 'child_of', self)]"/>
<group expand="0" string="Group By">
@@ -245,14 +250,21 @@
options="{'fold_field': 'fold'}"/>
</header>
<sheet string="Task">
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" groups="base.group_user"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
<field name="kanban_state" widget="kanban_state_selection"
options='{
"states_legend_field": "stage_id",
"states_legend": {"normal": "legend_normal", "blocked": "legend_blocked", "done": "legend_done"}}'/>
</div>
<div class="oe_title">
<h1 class="o_row">
<field name="priority" widget="priority"/>
<field name="name" placeholder="Task Title..."/>
<field name="kanban_state" widget="kanban_state_selection"
options='{
"states_legend_field": "stage_id",
"states_legend": {"normal": "legend_normal", "blocked": "legend_blocked", "done": "legend_done"}}'/>
</h1>
</div>
<group>
@@ -325,6 +337,7 @@
<field name="message_needaction_counter"/>
<field name="tag_ids"/>
<field name="displayed_image_id"/>
<field name="active"/>
<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">
+9 -3
View File
@@ -12,6 +12,13 @@
options="{'fold_field': 'fold'}"/>
</header>
<sheet string="Issue">
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" groups="base.group_no_one"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="row">
<h1 class="col-xs-11">
<field name="name" class="oe_inline" placeholder="Issue Summary..."/>
@@ -59,9 +66,6 @@
<field name="inactivity_days"/>
<field name="days_since_creation"/>
</group>
<group groups="base.group_no_one">
<field name="active"/>
</group>
</group>
</page>
</notebook>
@@ -122,6 +126,7 @@
<separator/>
<filter string="Create Day" context="{'group_by':'create_date:day'}" help="Create Date"/>
<filter string="Last Message" name="group_message_last_post" context="{'group_by':'message_last_post:week'}"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
</group>
</search>
</field>
@@ -153,6 +158,7 @@
<field name="user_id"/>
<field name="date_deadline"/>
<field name="message_needaction_counter"/>
<field name="active"/>
<templates>
<t t-name="kanban-tooltip">
<ul class="oe_kanban_tooltip">
+2 -1
View File
@@ -666,7 +666,8 @@ class resource_resource(osv.osv):
_columns = {
'name': fields.char("Name", required=True),
'code': fields.char('Code', size=16, copy=False),
'active' : fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the resource record without removing it."),
'active' : fields.boolean('Active', track_visibility='onchange',
help="If the active field is set to False, it will allow you to hide the resource record without removing it."),
'company_id' : fields.many2one('res.company', 'Company'),
'resource_type': fields.selection([('user','Human'),('material','Material')], 'Resource Type', required=True),
'user_id' : fields.many2one('res.users', 'User', help='Related user name for the resource to manage its access.'),
+8 -2
View File
@@ -141,7 +141,13 @@
<field name="arch" type="xml">
<form string="Partners">
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" groups="base.group_no_one"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
<div class="oe_title">
<field name="is_company" invisible="1"/>
@@ -311,7 +317,6 @@
<group string="Misc">
<field name="ref"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="active"/>
</group>
</group>
</page>
@@ -335,6 +340,7 @@
<separator/>
<filter string="Customers" name="customer" domain="[('customer','=',1), ('parent_id', '=', False)]"/>
<filter string="Vendors" name="supplier" domain="[('supplier','=',1), ('parent_id', '=', False)]"/>
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
<separator/>
<field name="category_id" string="Tag" filter_domain="[('category_id','ilike', self)]"/>
<field name="user_id"/>