[FIX] account, mail: allow account custom sub model tracking
Steps to reproduce: - Create an invoice and confirm it - reset to draft - change the account of an aml (product sales -> asset) -> on the log note you will see the detail of the modification `Account: 400000 Product Sales -> 101000 Current Assets` - connect with Demo - go on the same invoice Issue: You will not see the details of the aml account change This is problematic since Accountant and auditors should be able to see it. Cause: Sub-model tracking is not supported. Although we override this constraint in accounting (refer to https://github.com/odoo/odoo/blob/f56de22f10d09e6e34b25cbff04bbb6bf0823e54/addons/account/models/account_move.py#L5058-L5071), it remains inaccessible for users other than base.system. This is because we attempt to locate the account_id field on the model account.move defined in tracking.mail_message_id. opw-3632295 closes odoo/odoo#155034 X-original-commit: 20f00a73cb280fd9a3636122c4a8a316abcee0d0 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
This commit is contained in:
@@ -44,3 +44,4 @@ from . import test_account_partner
|
||||
from . import test_setup_wizard
|
||||
from . import test_structured_reference
|
||||
from . import test_product
|
||||
from . import test_mail_tracking_value
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
|
||||
from odoo import Command
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.addons.mail.tests.common import MailCommon
|
||||
from odoo.tests import Form
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestTracking(AccountTestInvoicingCommon, MailCommon):
|
||||
|
||||
def test_aml_change_tracking(self):
|
||||
""" tests that the field_groups is correctly set """
|
||||
account_move = self.env['account.move'].create({
|
||||
'move_type': 'out_invoice',
|
||||
'partner_id': self.partner_a.id,
|
||||
'invoice_line_ids': [Command.create({'product_id': self.product_a.id, 'price_unit': 200.0})]
|
||||
})
|
||||
account_move.action_post()
|
||||
account_move.button_draft()
|
||||
old_value = account_move.invoice_line_ids.account_id
|
||||
|
||||
with Form(account_move) as account_move_form:
|
||||
with account_move_form.invoice_line_ids.edit(0) as line_form:
|
||||
line_form.account_id = self.company_data['default_account_assets']
|
||||
new_value = account_move.invoice_line_ids.account_id
|
||||
|
||||
self.flush_tracking()
|
||||
self.assertTracking(account_move.message_ids, [
|
||||
('account_id', 'many2one', old_value, new_value),
|
||||
])
|
||||
|
||||
tracking_value = account_move.message_ids.sudo().tracking_value_ids
|
||||
tracking_value._compute_field_groups()
|
||||
|
||||
self.assertEqual(tracking_value.field_groups, False, "There is no group on account.move.line.account_id")
|
||||
@@ -38,7 +38,7 @@ class MailTracking(models.Model):
|
||||
@api.depends('mail_message_id', 'field_id')
|
||||
def _compute_field_groups(self):
|
||||
for tracking in self:
|
||||
model = self.env[tracking.mail_message_id.model]
|
||||
model = self.env[tracking.field_id.model]
|
||||
field = model._fields.get(tracking.field_id.name)
|
||||
tracking.field_groups = field.groups if field else 'base.group_system'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user