UI improvements

This commit is contained in:
Akim Juillerat
2017-09-28 12:00:02 +02:00
parent 95296101df
commit bba9133c04
2 changed files with 19 additions and 2 deletions

View File

@@ -11,7 +11,8 @@ class AccountAccountTag(models.Model):
_inherit = 'account.account.tag'
tag_category_id = fields.Many2one('account.account.tag.category',
'tag_ids', ondelete='set null')
string='Tag category',
ondelete='set null')
category_color = fields.Integer(related='tag_category_id.color')
@@ -85,6 +86,10 @@ class AccountAccountTagCategory(models.Model):
'the same model as this category (%s)'
) % self.applicability)
@api.multi
def name_get(self):
return [(cat.id, cat.name) for cat in self]
class AccountAccount(models.Model):

View File

@@ -2,7 +2,8 @@
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class AccountTagCategoryUpdateTags(models.TransientModel):
@@ -28,6 +29,17 @@ class AccountTagCategoryUpdateTags(models.TransientModel):
@api.multi
def save_tags_to_category(self):
categorized_tags = self.tag_ids.filtered(
lambda t: t.tag_category_id and
t.tag_category_id != self.tag_category_id)
if categorized_tags:
tags_error = ["- %s (%s)" % (t.name, t.tag_category_id.name)
for t in categorized_tags]
raise ValidationError(_('Following tags are already defined on '
'another tag category : \n %s') %
"\n".join(tags_error)
)
self.tag_category_id.write({
'tag_ids': [(6, False, self.tag_ids.ids)]
})