<commit_before># -*- coding: utf-8 -*-
#
# Copyright 2016 Taŭga Tecnologia
#    <NAME> <<EMAIL>>
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#

from __future__ import division, print_function, unicode_literals

from odoo import api, fields, models


class AccountMove(models.Model):
    _inherit = 'account.move'

    is_brazilian_move = fields.Boolean(
        string=u'Is a Brazilian Move?',
        compute='_compute_is_brazilian_move',
        store=True,
    )
    sped_empresa_id = fields.Many2one(
        comodel_name='sped.empresa',
        string='Empresa',
        related='journal_id.sped_empresa_id',
        store=True,
        readonly=True,
        default=lambda self: self.env.user.company_id.sped_empresa_id,
    )
    sped_participante_id = fields.Many2one(
        comodel_name='sped.participante',
        string='Participante',
    )
    partner_id = fields.Many2one(
        comodel_name='res.partner',
        string='Partner',
        compute='_onchange_sped_participante_id',
    )
    sped_documento_id = fields.Many2one(
        comodel_name='sped.documento',
        string='Documento Fiscal',
        ondelete='restrict',
    )

    @api.depends('journal_id', 'company_id', 'currency_id', 'sped_empresa_id')
    def _compute_is_brazilian_move(self):
        for move in self:
            if self.sped_documento_id:
                move.is_brazilian_move = True
            elif move.company_id.country_id:
                if move.sped_empresa_id:
                    move.is_brazilian_move = True

            if move.is_brazilian_move:
                #
                # Brazilian moves, by law, must always be in BRL
                #
                move.currency_id = self.env.ref('base.BRL').id
                continue

            move.is_brazilian_move = False

    @api.depends('sped_participante_id')
    def _onchange_sped_participante_id(self):
        for move in self:
            if move.sped_participante_id:
                move.partner_id = move.sped_participante_id.partner_id
            else:
                move.partner_id = False
<commit_msg>[FIX] compute_is_brazilian_move error Expected singleton<commit_after># -*- coding: utf-8 -*-
#
# Copyright 2016 Taŭga Tecnologia
#    <NAME> <<EMAIL>>
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#

from __future__ import division, print_function, unicode_literals

from odoo import api, fields, models


class AccountMove(models.Model):
    _inherit = 'account.move'

    is_brazilian_move = fields.Boolean(
        string=u'Is a Brazilian Move?',
        compute='_compute_is_brazilian_move',
        store=True,
    )
    sped_empresa_id = fields.Many2one(
        comodel_name='sped.empresa',
        string='Empresa',
        related='journal_id.sped_empresa_id',
        store=True,
        readonly=True,
        default=lambda self: self.env.user.company_id.sped_empresa_id,
    )
    sped_participante_id = fields.Many2one(
        comodel_name='sped.participante',
        string='Participante',
    )
    partner_id = fields.Many2one(
        comodel_name='res.partner',
        string='Partner',
        compute='_onchange_sped_participante_id',
    )
    sped_documento_id = fields.Many2one(
        comodel_name='sped.documento',
        string='Documento Fiscal',
        ondelete='restrict',
    )

    @api.depends('journal_id', 'company_id', 'currency_id', 'sped_empresa_id')
    def _compute_is_brazilian_move(self):
        for move in self:
            if move.sped_documento_id:
                move.is_brazilian_move = True
            elif move.company_id.country_id:
                if move.sped_empresa_id:
                    move.is_brazilian_move = True

            if move.is_brazilian_move:
                #
                # Brazilian moves, by law, must always be in BRL
                #
                move.currency_id = self.env.ref('base.BRL').id
                continue

            move.is_brazilian_move = False

    @api.depends('sped_participante_id')
    def _onchange_sped_participante_id(self):
        for move in self:
            if move.sped_participante_id:
                move.partner_id = move.sped_participante_id.partner_id
            else:
                move.partner_id = False

{'fraction_non_alphanumeric': 0.0959513222560262, 'fraction_numerical': 0.00468055230517201, 'mean_word_length': 2.2851652574942354, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '2003244', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1376, 'n_words': 230}