From e9e7c63727a12cae27592201f47d069501fec869 Mon Sep 17 00:00:00 2001
From: Kishan Gajjar <kig@odoo.com>
Date: Fri, 31 Mar 2017 12:44:49 +0530
Subject: [PATCH] [IMP] project,survey,mass_mailing: Add kanban views for all
 menuitems used in mobile

Purpose
=======

Improve readability on mobile

Specification
=============

Activate Kanban view on those so it could be displayed by default on mobile instead of view list

List of impacted modules:

- mass_mailing: kanban for mailing lists

- mass_mailing : kanban for contacts

- marketing_campaign: kanban for campaigns

- marketing_campaign : kanban for segment

- survey: kanban for answers

- project : kanban for config >> project(reuse project dashbord kanban)

- project_issue_sheet: kanban for stages
---
 .../views/marketing_campaign_views.xml        | 68 +++++++++++++++++-
 .../mass_mailing/views/mass_mailing_views.xml | 72 ++++++++++++++++++-
 addons/project/views/project_views.xml        | 33 ++++++++-
 addons/survey/views/survey_views.xml          | 47 +++++++++++-
 4 files changed, 214 insertions(+), 6 deletions(-)

diff --git a/addons/marketing_campaign/views/marketing_campaign_views.xml b/addons/marketing_campaign/views/marketing_campaign_views.xml
index 6a95cbf132ef..a87fb0b96bf0 100644
--- a/addons/marketing_campaign/views/marketing_campaign_views.xml
+++ b/addons/marketing_campaign/views/marketing_campaign_views.xml
@@ -146,12 +146,44 @@
         </field>
     </record>
 
+    <record id="marketing_campaign_view_kanban" model="ir.ui.view">
+        <field name="name">marketing.campaign.kanban</field>
+        <field name="model">marketing.campaign</field>
+        <field name="arch" type="xml">
+            <kanban class="o_kanban_mobile">
+                <field name="name"/>
+                <field name="object_id"/>
+                <field name="state"/>
+                <templates>
+                    <t t-name="kanban-box">
+                        <div t-attf-class="oe_kanban_card oe_kanban_global_click">
+                            <div class="mb4">
+                                <strong><field name="name"/></strong>
+                            </div>
+                            <div class="row">
+                                <div class="col-xs-6 text-muted">
+                                    <field name="object_id"/>
+                                </div>
+                                <div class="col-xs-6">
+                                    <span class="pull-right text-right">
+                                        <field name="state" widget="kanban_label_selection" options="{'classes': {'draft': 'info', 'running': 'default',
+                                        'done': 'success', 'cancelled': 'danger'}}"/>
+                                    </span>
+                                </div>
+                            </div>
+                        </div>
+                    </t>
+                </templates>
+            </kanban>
+        </field>
+    </record>
+
     <record model="ir.actions.act_window" id="action_marketing_campaign_form">
         <field name="name">Campaigns</field>
         <field name="type">ir.actions.act_window</field>
         <field name="res_model">marketing.campaign</field>
         <field name="view_type">form</field>
-        <field name="view_mode">tree,form,diagram</field>
+        <field name="view_mode">tree,kanban,form,diagram</field>
         <field name="view_id" ref="view_marketing_campaign_tree"/>
         <field name="context">{'group_by': []}</field>
         <field name="search_view_id" ref="view_marketing_campaign_search"/>
@@ -230,6 +262,38 @@
         </field>
     </record>
 
+    <record id="marketing_campaign_segment_view_kanban" model="ir.ui.view">
+        <field name="name">marketing.campaign.segment.kanban</field>
+        <field name="model">marketing.campaign.segment</field>
+        <field name="arch" type="xml">
+            <kanban class="o_kanban_mobile">
+                <field name="name"/>
+                <field name="object_id"/>
+                <field name="state"/>
+                <templates>
+                    <t t-name="kanban-box">
+                        <div t-attf-class="oe_kanban_card oe_kanban_global_click">
+                            <div class="mb4">
+                                <strong><field name="name"/></strong>
+                            </div>
+                            <div class="row">
+                                <div class="col-xs-6 text-muted">
+                                    <field name="object_id"/>
+                                </div>
+                                <div class="col-xs-6">
+                                    <span class="pull-right text-right">
+                                        <field name="state" widget="kanban_label_selection" options="{'classes': {'draft': 'info', 'running': 'default',
+                                        'done': 'success', 'cancelled': 'danger'}}"/>
+                                    </span>
+                                </div>
+                            </div>
+                        </div>
+                    </t>
+                </templates>
+            </kanban>
+        </field>
+    </record>
+
     <record id="view_marketing_campaign_segment_search" model="ir.ui.view">
         <field name="name">marketing.campaign.segment.search</field>
         <field name="model">marketing.campaign.segment</field>
@@ -259,7 +323,7 @@
         <field name="type">ir.actions.act_window</field>
         <field name="res_model">marketing.campaign.segment</field>
         <field name="view_type">form</field>
-        <field name="view_mode">tree,form</field>
+        <field name="view_mode">tree,kanban,form</field>
         <field name="view_id" ref="view_marketing_campaign_segment_tree"/>
         <field name="search_view_id" ref="view_marketing_campaign_segment_search"/>
         <field name="context">{'group_by': []}</field>
diff --git a/addons/mass_mailing/views/mass_mailing_views.xml b/addons/mass_mailing/views/mass_mailing_views.xml
index 6dc48798c86c..89f78bf15457 100644
--- a/addons/mass_mailing/views/mass_mailing_views.xml
+++ b/addons/mass_mailing/views/mass_mailing_views.xml
@@ -65,6 +65,50 @@
             </field>
         </record>
 
+        <record id="view_mail_mass_mailing_contact_kanban" model="ir.ui.view">
+            <field name="name">mail.mass_mailing.contact.kanban</field>
+            <field name="model">mail.mass_mailing.contact</field>
+            <field name="arch" type="xml">
+                <kanban>
+                    <field name="name"/>
+                    <field name="company_name"/>
+                    <field name="email"/>
+                    <field name="message_bounce"/>
+                    <templates>
+                        <t t-name="kanban-box">
+                            <div t-attf-class="oe_kanban_global_click">
+                                <div>
+                                    <field name="tag_ids"/>
+                                </div>
+                                <div class="row">
+                                    <div class="col-xs-8">
+                                        <strong>
+                                            <t t-esc="record.name.value"/>
+                                        </strong>
+                                    </div>
+                                    <div class="col-xs-4">
+                                        <span class="badge pull-right" title="Number of bounced email.">
+                                            <i class="fa fa-exclamation-triangle"/> <t t-esc="record.message_bounce.value" title=""/>
+                                        </span>
+                                    </div>
+                                </div>
+                                <div class="row">
+                                    <div class="col-xs-6">
+                                        <strong>
+                                            <t t-esc="record.email.value"/>
+                                        </strong>
+                                    </div>
+                                    <div class="col-xs-6">
+                                        <t t-esc="record.company_name.value"/>
+                                    </div>
+                                </div>
+                            </div>
+                        </t>
+                    </templates>
+                </kanban>
+            </field>
+        </record>
+
         <record model="ir.ui.view" id="view_mail_mass_mailing_contact_form">
             <field name="name">mail.mass_mailing.contact.form</field>
             <field name="model">mail.mass_mailing.contact</field>
@@ -132,7 +176,7 @@
             <field name="name">Contacts</field>
             <field name="res_model">mail.mass_mailing.contact</field>
             <field name="view_type">form</field>
-            <field name="view_mode">tree,form,graph,pivot</field>
+            <field name="view_mode">tree,kanban,form,graph,pivot</field>
             <field name="context">{'search_default_not_opt_out': 1}</field>
         </record>
 
@@ -184,6 +228,30 @@
             </field>
         </record>
 
+        <record id="view_mail_mass_mailing_list_kanban" model="ir.ui.view">
+            <field name="name">mail.mass_mailing.list.kanban</field>
+            <field name="model">mail.mass_mailing.list</field>
+            <field name="arch" type="xml">
+                <kanban class="o_kanban_mobile">
+                    <field name="name"/>
+                    <field name="contact_nbr"/>
+                    <templates>
+                        <t t-name="kanban-box">
+                            <div t-attf-class="oe_kanban_global_click">
+                                <div>
+                                    <strong><t t-esc="record.name.value"/></strong>
+                                    <span class="pull-right badge">
+                                        <i class="fa fa-user"/>
+                                        <t t-esc="record.contact_nbr.value"/>
+                                    </span>
+                                </div>
+                            </div>
+                        </t>
+                    </templates>
+                </kanban>
+            </field>
+        </record>
+
         <record model="ir.ui.view" id="view_mail_mass_mailing_list_form">
             <field name="name">mail.mass_mailing.list.form</field>
             <field name="model">mail.mass_mailing.list</field>
@@ -216,7 +284,7 @@
             <field name="name">Mailing Lists</field>
             <field name="res_model">mail.mass_mailing.list</field>
             <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
+            <field name="view_mode">tree,kanban,form</field>
             <field name="help" type="html">
                 <p class="oe_view_nocontent_create">
                     Click here to create a new mailing list.
diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml
index 286b24002299..8e97ed24b37c 100644
--- a/addons/project/views/project_views.xml
+++ b/addons/project/views/project_views.xml
@@ -328,7 +328,7 @@ action = model.activate_sample_project()
             <field name="res_model">project.project</field>
             <field name="view_type">form</field>
             <field name="domain">[]</field>
-            <field name="view_mode">list,form</field>
+            <field name="view_mode">list,kanban,form</field>
             <field name="search_view_id" ref="view_project_project_filter"/>
             <field name="context">{}</field>
             <field name="help" type="html">
@@ -734,10 +734,41 @@ action = model.activate_sample_project()
             </field>
         </record>
 
+        <record id="view_project_task_type_kanban" model="ir.ui.view">
+            <field name="name">project.task.type.kanban</field>
+            <field name="model">project.task.type</field>
+            <field name="arch" type="xml">
+                <kanban class="o_kanban_mobile">
+                    <field name="name"/>
+                    <field name="fold"/>
+                    <field name="description"/>
+                    <templates>
+                        <t t-name="kanban-box">
+                            <div t-attf-class="oe_kanban_global_click">
+                                <div class="row">
+                                    <div class="col-xs-6">
+                                        <strong><t t-esc="record.name.value"/></strong>
+                                    </div>
+                                    <div class="col-xs-6" title="Folded in Kanban">
+                                        <field name="fold" widget="boolean"/>
+                                    </div>
+                                </div>
+                                <t t-if="record.description.value">
+                                    <hr class="mt8 mb8"/>
+                                    <t t-esc="record.description.value"/>
+                                </t>
+                            </div>
+                        </t>
+                    </templates>
+                </kanban>
+            </field>
+        </record>
+
         <record id="open_task_type_form" model="ir.actions.act_window">
             <field name="name">Stages</field>
             <field name="res_model">project.task.type</field>
             <field name="view_type">form</field>
+            <field name="view_mode">tree,kanban,form</field>
             <field name="view_id" ref="task_type_tree"/>
             <field name="help" type="html">
               <p class="oe_view_nocontent_create">
diff --git a/addons/survey/views/survey_views.xml b/addons/survey/views/survey_views.xml
index 9fc6f534343c..1f502263a3f8 100644
--- a/addons/survey/views/survey_views.xml
+++ b/addons/survey/views/survey_views.xml
@@ -83,10 +83,55 @@
             </field>
         </record>
 
+        <record id="view_survey_user_input_kanban" model="ir.ui.view">
+            <field name="name">survey.user_input.kanban</field>
+            <field name="model">survey.user_input</field>
+            <field name="arch" type="xml">
+                <kanban>
+                    <field name="survey_id"/>
+                    <field name="date_create"/>
+                    <field name="partner_id"/>
+                    <field name="email"/>
+                    <field name="type"/>
+                    <field name="state"/>
+                    <templates>
+                        <t t-name="kanban-box">
+                            <div t-attf-class="oe_kanban_global_click">
+                                <div class="row mb8">
+                                    <div class="col-xs-8">
+                                        <strong>
+                                            <t t-esc="record.survey_id.value"/>
+                                        </strong>
+                                    </div>
+                                    <div class="col-xs-4">
+                                        <span class="pull-right badge">
+                                            <t t-esc="record.type.value"/>
+                                        </span>
+                                    </div>
+                                </div>
+                                <div class="row">
+                                    <div class="col-xs-8">
+                                        <strong>
+                                            <field name="date_create"/>
+                                        </strong>
+                                    </div>
+                                    <div class="col-xs-4">
+                                        <span class="pull-right">
+                                            <field name="state" widget="kanban_label_selection" options="{'classes': {'new': 'default', 'done': 'success', 'skip':'warning'}}"/>
+                                        </span>
+                                    </div>
+                                </div>
+                            </div>
+                        </t>
+                    </templates>
+                </kanban>
+            </field>
+        </record>
+
         <record model="ir.actions.act_window" id="action_survey_user_input">
             <field name="name">Answers</field>
             <field name="res_model">survey.user_input</field>
-            <field name="view_mode">tree,form</field>
+            <field name="view_mode">tree,kanban,form</field>
             <field name="view_id" ref="survey_user_input_tree"></field>
             <field name="search_view_id" ref="survey_user_input_search"/>
             <field name="context">{'search_default_group_by_survey': True}</field>
-- 
GitLab