mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
UI improvements
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
@@ -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)]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user