[IMP] various: Make some small tree views editable

Purpose
=======

Some formviews are useless since there are so few relevant fields https://nimb.ws/1EdMV7

For instance, to create a new lost reason the user is forced to:
1. Hit create
2. Type in the name of the record
3. Hit save
4. Go back to the treeview
While he could simply type them away in an editable treeview.

The goal of this task is to allow for creation/edition of records in such models
directly from the treeview.

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

Modify tree views from a given list of models for which the
treeview has to be made editable bottom.

If not specified otherwise, the content treeview should stay the same.

If a field is readonly/required/etc. in the formview, it should be in the
editable treeview as well.

Relabeling has to be done of the field itself, not in the view.

TaskID: 2026126

closes odoo/odoo#34577

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
RomainLibert
2019-07-15 12:47:03 +00:00
committed by Yannick Tivisse
parent 14067543d0
commit 8514ef827e
29 changed files with 137 additions and 43 deletions
+2 -2
View File
@@ -41,7 +41,7 @@ class AccountAccountTag(models.Model):
_name = 'account.account.tag'
_description = 'Account Tag'
name = fields.Char(required=True)
name = fields.Char('Tag Name', required=True)
applicability = fields.Selection([('accounts', 'Accounts'), ('taxes', 'Taxes')], required=True, default='accounts')
color = fields.Integer('Color Index')
active = fields.Boolean(default=True, help="Set active to false to hide the Account Tag without removing it.")
@@ -506,7 +506,7 @@ class AccountJournalGroup(models.Model):
_name = 'account.journal.group'
_description = "Account Journal Group"
name = fields.Char(required=True, translate=True)
name = fields.Char("Group Name", required=True, translate=True)
company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company)
account_journal_ids = fields.Many2many('account.journal', string="Journals")
sequence = fields.Integer(default=10)
@@ -6,7 +6,7 @@
<field name="name">account.incoterms.tree</field>
<field name="model">account.incoterms</field>
<field name="arch" type="xml">
<tree string="Incoterms">
<tree string="Incoterms" editable="bottom">
<field name="active" invisible="1"/>
<field name="code"/>
<field colspan="4" name="name"/>
+14 -2
View File
@@ -180,10 +180,10 @@
<field name="model">account.journal.group</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<tree>
<tree editable="bottom">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="account_journal_ids" widget="many2many_tags"/>
<field name="account_journal_ids" widget="many2many_tags" options="{'noCreate': True}"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
@@ -388,6 +388,18 @@ action = model.setting_init_bank_account_action()
</form>
</field>
</record>
<record id="account_tag_view_tree" model="ir.ui.view">
<field name="name">Tags</field>
<field name="model">account.account.tag</field>
<field name="arch" type="xml">
<tree string="Tags">
<field name="name"/>
<field name="applicability"/>
</tree>
</field>
</record>
<record id="account_tag_action" model="ir.actions.act_window">
<field name="name">Account Tags</field>
<field name="res_model">account.account.tag</field>
+3 -3
View File
@@ -1611,7 +1611,7 @@ class Lead(models.Model):
from crm_lead_tag_rel rel
inner join crm_lead_tag t on rel.tag_id = t.id
inner join crm_lead l on l.id = rel.lead_id
where (l.probability = 0 or l.probability >= 100)
where (l.probability = 0 or l.probability >= 100)
and l.create_date > %%s
%s
group by l.probability, l.active, t.id"""
@@ -1726,7 +1726,7 @@ class Tag(models.Model):
_name = "crm.lead.tag"
_description = "Lead Tag"
name = fields.Char('Name', required=True, translate=True)
name = fields.Char('Tag Name', required=True, translate=True)
color = fields.Integer('Color Index')
_sql_constraints = [
@@ -1738,5 +1738,5 @@ class LostReason(models.Model):
_name = "crm.lost.reason"
_description = 'Opp. Lost Reason'
name = fields.Char('Name', required=True, translate=True)
name = fields.Char('Description', required=True, translate=True)
active = fields.Boolean('Active', default=True)
+12 -1
View File
@@ -31,8 +31,9 @@
<field name="name">crm.lead.tag.tree</field>
<field name="model">crm.lead.tag</field>
<field name="arch" type="xml">
<tree string="Lead Tags">
<tree string="Lead Tags" editable="bottom">
<field name="name"/>
<field name="color" groups="base.group_no_one"/>
</tree>
</field>
</record>
@@ -855,6 +856,16 @@
</field>
</record>
<record id="crm_lost_reason_view_tree" model="ir.ui.view">
<field name="name">crm.lost.reason.tree</field>
<field name="model">crm.lost.reason</field>
<field name="arch" type="xml">
<tree string="Channel" editable="bottom">
<field name="name"/>
</tree>
</field>
</record>
<!--
MASS MAILING
-->
+1 -1
View File
@@ -366,7 +366,7 @@ class FleetVehicleTag(models.Model):
_name = 'fleet.vehicle.tag'
_description = 'Vehicle Tag'
name = fields.Char(required=True, translate=True)
name = fields.Char('Tag Name', required=True, translate=True)
color = fields.Integer('Color Index')
_sql_constraints = [('name_uniq', 'unique (name)', "Tag name already exists !")]
@@ -489,6 +489,16 @@
</field>
</record>
<record id="fleet_vehicle_tag_view_view_tree" model="ir.ui.view">
<field name="name">fleet.vehicle.tag.tree</field>
<field name="model">fleet.vehicle.tag</field>
<field name="arch" type="xml">
<tree string="Vehicle Tags" editable="bottom">
<field name="name"/>
</tree>
</field>
</record>
<record id="fleet_vehicle_tag_action" model="ir.actions.act_window">
<field name="name">Vehicle Tags</field>
<field name="res_model">fleet.vehicle.tag</field>
+1 -1
View File
@@ -9,7 +9,7 @@ class EmployeeCategory(models.Model):
_name = "hr.employee.category"
_description = "Employee Category"
name = fields.Char(string="Employee Tag", required=True)
name = fields.Char(string="Tag Name", required=True)
color = fields.Integer(string='Color Index')
employee_ids = fields.Many2many('hr.employee', 'employee_category_rel', 'category_id', 'emp_id', string='Employees')
@@ -21,7 +21,7 @@
<field name="model">hr.employee.category</field>
<field eval="8" name="priority"/>
<field name="arch" type="xml">
<tree string="Employees Tags">
<tree string="Employees Tags" editable="bottom">
<field name="name"/>
</tree>
</field>
@@ -7,7 +7,7 @@
<field name="name">hr.attendance.tree</field>
<field name="model">hr.attendance</field>
<field name="arch" type="xml">
<tree string="Employee attendances">
<tree string="Employee attendances" editable="bottom">
<field name="employee_id"/>
<field name="check_in"/>
<field name="check_out"/>
@@ -175,7 +175,7 @@
<!-- Menus -->
<menuitem id="menu_hr_attendance_root" name="Attendances" sequence="90" groups="hr_attendance.group_hr_attendance" web_icon="hr_attendance,static/description/icon.png"/>
<menuitem id="menu_hr_attendance_my_attendances" name="Check In / Check Out" parent="menu_hr_attendance_root" sequence="10" groups="hr_attendance.group_hr_attendance" action="hr_attendance_action_my_attendances"/>
<menuitem id="menu_hr_attendance_manage_attendances" name="Manage Attendances" parent="menu_hr_attendance_root" sequence="20" groups="hr_attendance.group_hr_attendance_user"/>
@@ -84,7 +84,7 @@ class RecruitmentDegree(models.Model):
('name_uniq', 'unique (name)', 'The name of the Degree of Recruitment must be unique!')
]
name = fields.Char("Degree", required=True, translate=True)
name = fields.Char("Degree Name", required=True, translate=True)
sequence = fields.Integer("Sequence", default=1, help="Gives the sequence order when displaying a list of degrees.")
@@ -484,7 +484,7 @@ class ApplicantCategory(models.Model):
_name = "hr.applicant.category"
_description = "Category of applicant"
name = fields.Char("Name", required=True)
name = fields.Char("Tag Name", required=True)
color = fields.Integer(string='Color Index', default=10)
_sql_constraints = [
@@ -770,6 +770,17 @@ action = act
</field>
</record>
<record id="hr_applicant_category_view_tree" model="ir.ui.view">
<field name="name">hr.applicant.category.tree</field>
<field name="model">hr.applicant.category</field>
<field name="arch" type="xml">
<tree string="Tags" editable="bottom">
<field name="name"/>
<field name="color" groups="base.group_no_one"/>
</tree>
</field>
</record>
<!-- Tag Action -->
<record id="hr_applicant_category_action" model="ir.actions.act_window">
<field name="name">Tags</field>
@@ -792,8 +803,8 @@ action = act
<field name="name">hr.recruitment.degree.tree</field>
<field name="model">hr.recruitment.degree</field>
<field name="arch" type="xml">
<tree string="Degree">
<field name="sequence" invisible="1"/>
<tree string="Degree" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
+16 -1
View File
@@ -170,6 +170,17 @@
</field>
</record>
<record id="hr_resume_line_type_tree_view" model="ir.ui.view">
<field name="name">hr.resume.line.type.tree.view</field>
<field name="model">hr.resume.line.type</field>
<field name="arch" type="xml">
<tree name="Resumé Line Types" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
</record>
<record id="hr_resume_type_action" model="ir.actions.act_window">
<field name="name">Resumé Line Types</field>
<field name="res_model">hr.resume.line.type</field>
@@ -287,7 +298,11 @@
</h1>
</div>
<group string="Skills">
<field name="skill_ids" nolabel="1" context="{'default_skill_type_id': id}"/>
<field name="skill_ids" nolabel="1" context="{'default_skill_type_id': id}">
<tree editable="bottom">
<field name="name"/>
</tree>
</field>
</group>
<group string="Levels">
<field name="skill_level_ids" nolabel="1" context="{'default_skill_type_id': id}"/>
+1 -1
View File
@@ -401,7 +401,7 @@ class MaintenanceTeam(models.Model):
_name = 'maintenance.team'
_description = 'Maintenance Teams'
name = fields.Char(required=True, translate=True)
name = fields.Char('Team Name', required=True, translate=True)
active = fields.Boolean(default=True)
company_id = fields.Many2one('res.company', string='Company',
default=lambda self: self.env.company)
@@ -779,9 +779,10 @@
<field name="name">maintenance.team.tree</field>
<field name="model">maintenance.team</field>
<field name="arch" type="xml">
<tree string="Maintenance Team">
<tree string="Maintenance Team" editable="bottom">
<field name="name"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="member_ids" widget="many2many_tags" options="{'color_field': 'color', 'noCreate': True}"/>
<field name="company_id" groups="base.group_multi_company" options="{'noCreate': True}"/>
</tree>
</field>
</record>
+1 -1
View File
@@ -220,7 +220,7 @@ class MrpWorkcenterProductivityLoss(models.Model):
_description = "Workcenter Productivity Losses"
_order = "sequence, id"
name = fields.Char('Reason', required=True)
name = fields.Char('Blocking Reason', required=True)
sequence = fields.Integer('Sequence', default=1)
manual = fields.Boolean('Is a Blocking Reason', default=True)
loss_id = fields.Many2one('mrp.workcenter.productivity.loss.type', domain=([('loss_type', 'in', ['quality', 'availability'])]), string='Category')
+2 -2
View File
@@ -458,9 +458,9 @@
<field name="name">mrp.workcenter.productivity.loss.tree</field>
<field name="model">mrp.workcenter.productivity.loss</field>
<field name="arch" type="xml">
<tree string="Workcenter Productivity Loss">
<tree string="Workcenter Productivity Loss" editable='bottom'>
<field name="sequence" widget="handle"/>
<field name="name" string="Blocking Reasons"/>
<field name="name"/>
<field name="loss_type" string="Category"/>
</tree>
</field>
@@ -97,4 +97,15 @@
</field>
</record>
<record id="product_uom_categ_tree_view" model="ir.ui.view">
<field name="name">uom.category.tree.inherit</field>
<field name="model">uom.category</field>
<field name="inherit_id" ref="uom.product_uom_categ_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='measure_type']" position="after">
<field name="is_pos_groupable" groups="base.group_no_one"/>
</xpath>
</field>
</record>
</odoo>
+1 -1
View File
@@ -978,7 +978,7 @@ class ProjectTags(models.Model):
_name = "project.tags"
_description = "Project Tags"
name = fields.Char(required=True)
name = fields.Char('Tag Name', required=True)
color = fields.Integer(string='Color Index')
_sql_constraints = [
+10
View File
@@ -904,6 +904,16 @@
</field>
</record>
<record model="ir.ui.view" id="project_tags_tree_view">
<field name="name">Tags</field>
<field name="model">project.tags</field>
<field name="arch" type="xml">
<tree string="Tags" editable="bottom">
<field name="name"/>
</tree>
</field>
</record>
<record id="project_tags_action" model="ir.actions.act_window">
<field name="name">Tags</field>
<field name="res_model">project.tags</field>
+12
View File
@@ -76,6 +76,18 @@
</form>
</field>
</record>
<record id="product_uom_categ_tree_view" model="ir.ui.view">
<field name="name">uom.category.tree</field>
<field name="model">uom.category</field>
<field name="arch" type="xml">
<tree string="Units of Measure categories" editable="bottom">
<field name="name"/>
<field name="measure_type"/>
</tree>
</field>
</record>
<record id="product_uom_categ_form_action" model="ir.actions.act_window">
<field name="name">Unit of Measure Categories</field>
<field name="type">ir.actions.act_window</field>
+1 -1
View File
@@ -10,7 +10,7 @@ class UtmMedium(models.Model):
_description = 'UTM Medium'
_order = 'name'
name = fields.Char(string='Channel Name', required=True)
name = fields.Char(string='Medium Name', required=True)
active = fields.Boolean(default=True)
+4 -4
View File
@@ -16,7 +16,7 @@
<field name="name">utm.campaign.view.tree</field>
<field name="model">utm.campaign</field>
<field name="arch" type="xml">
<tree string="Campaign">
<tree string="Campaign" editable="bottom">
<field name="name"/>
</tree>
</field>
@@ -57,9 +57,9 @@
<field name="name">utm.medium.view.tree</field>
<field name="model">utm.medium</field>
<field name="arch" type="xml">
<tree string="Mediums">
<tree string="Mediums" editable="bottom">
<field name="name"/>
<field name="active"/>
<field name="active" invisible="1"/>
</tree>
</field>
</record>
@@ -98,7 +98,7 @@
<field name="name">utm.source.view.tree</field>
<field name="model">utm.source</field>
<field name="arch" type="xml">
<tree string="Source">
<tree string="Source" editable="bottom">
<field name="name"/>
</tree>
</field>
@@ -23,8 +23,9 @@
<field name="name">res.partner.activation.tree</field>
<field name="model">res.partner.activation</field>
<field name="arch" type="xml">
<tree string="Activation">
<field name="name" />
<tree string="Activation" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
</record>
@@ -34,11 +34,11 @@
<field name="model">res.partner.tag</field>
<field eval="6" name="priority"/>
<field name="arch" type="xml">
<tree string="Website Tags">
<tree string="Website Tags" editable="bottom">
<field name="name"/>
<field name="classname"/>
<field name="website_published"/>
<field name="active"/>
<field name="active" invisible="1"/>
</tree>
</field>
</record>
@@ -11,7 +11,7 @@ class TrackTag(models.Model):
_description = 'Event Track Tag'
_order = 'name'
name = fields.Char('Tag')
name = fields.Char('Tag Name', required=True)
track_ids = fields.Many2many('event.track', string='Tracks')
color = fields.Integer(string='Color Index')
@@ -24,7 +24,7 @@ class TrackLocation(models.Model):
_name = "event.track.location"
_description = 'Event Track Location'
name = fields.Char('Room')
name = fields.Char('Location')
class TrackStage(models.Model):
@@ -275,7 +275,7 @@
<field name="model">event.sponsor.type</field>
<field name="arch" type="xml">
<tree string="Event Sponsor Type" editable="bottom">
<field name="sequence"/>
<field name="sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
+2 -2
View File
@@ -101,10 +101,10 @@
<field name="name">res.country.state.tree</field>
<field name="model">res.country.state</field>
<field name="arch" type="xml">
<tree string="State">
<tree string="State" editable="bottom">
<field name="name"/>
<field name="code"/>
<field name="country_id"/>
<field name="country_id" options="{'noCreate': True}"/>
</tree>
</field>
</record>
+3 -3
View File
@@ -7,7 +7,7 @@
<field name="name">res.partner.title.tree</field>
<field name="model">res.partner.title</field>
<field name="arch" type="xml">
<tree string="Partner Titles">
<tree string="Partner Titles" editable="bottom">
<field name="name"/>
<field name="shortcut"/>
</tree>
@@ -722,10 +722,10 @@
<field name="model">res.partner.industry</field>
<field eval="6" name="priority"/>
<field name="arch" type="xml">
<tree string="Industry">
<tree string="Industry" editable="bottom">
<field name="name"/>
<field name="full_name"/>
<field name="active"/>
<field name="active" invisible="1"/>
</tree>
</field>
</record>