<commit_before># Copyright 2019 Aleph Objects, Inc.
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).

from odoo import api, models


class AccountMoveLine(models.Model):
    _inherit = "account.move.line"

    @api.onchange(
        "amount_currency",
        "currency_id",
        "debit",
        "credit",
        "tax_ids",
        "account_id",
        "analytic_account_id",
        "analytic_tag_ids",
    )
    def _onchange_mark_recompute_taxes(self):
        for line in self:
            if line.purchase_line_id.usage_id.account_id:
                account = line.purchase_line_id.usage_id.account_id
            else:
                account = line._get_computed_account()
            line.account_id = account
        return super(AccountMoveLine, self)._onchange_mark_recompute_taxes()
<commit_msg>[13.0][FIX] purchase_product_usage: Change only account if usage is defined in POL<commit_after># Copyright 2019 Aleph Objects, Inc.
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).

from odoo import api, models


class AccountMoveLine(models.Model):
    _inherit = "account.move.line"

    @api.onchange(
        "amount_currency",
        "currency_id",
        "debit",
        "credit",
        "tax_ids",
        "account_id",
        "analytic_account_id",
        "analytic_tag_ids",
    )
    def _onchange_mark_recompute_taxes(self):
        for line in self:
            if line.purchase_line_id.usage_id.account_id:
                line.account_id = line.purchase_line_id.usage_id.account_id
        return super(AccountMoveLine, self)._onchange_mark_recompute_taxes()

{'fraction_non_alphanumeric': 0.10247349823321555, 'fraction_numerical': 0.015901060070671377, 'mean_word_length': 2.6148936170212767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780361', 'n_tokens_mistral': 581, 'n_tokens_neox': 542, 'n_words': 107}