<commit_before># -*- coding: utf-8 -*-
# Copyright (C) 2016  <NAME> - KMEE                                #
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import models, api


class ProcurementOrder(models.Model):
    _name = "procurement.order"
    _inherit = [
        _name,
        "stock.invoice.state.mixin",
    ]

    @api.model
    def _run_move_create(self, procurement):
        result = super(ProcurementOrder, self)._run_move_create(procurement)
        if (procurement.rule_id and procurement.rule_id.fiscal_category_id and
                result['partner_id']):
            ctx = dict(self.env.context)
            ctx.update({'use_domain': ('use_picking', '=', True)})
            partner = self.env['res.partner'].browse(result['partner_id'])
            company = (procurement.warehouse_id.company_id or
                       procurement.company_id)
            kwargs = {
                'partner_id': partner.id,
                'product_id': procurement.product_id.id,
                'partner_invoice_id':  partner.id,
                # TODO: Implement fuction to compute partner invoice id
                'partner_shipping_id': partner.id,
                'fiscal_category_id': (
                    procurement.rule_id.fiscal_category_id
                ),
                'company_id': company.id,
                'context': ctx,
            }

            obj_fp_rule = self.env['account.fiscal.position.rule']
            product_fc_id = obj_fp_rule.with_context(
                ctx).product_fiscal_category_map(
                    kwargs.get('product_id'),
                    kwargs.get('fiscal_category_id'),
                    partner.state_id.id)

            if product_fc_id:
                kwargs['fiscal_category_id'] = product_fc_id
                result['fiscal_category_id'] = product_fc_id
            else:
                result['fiscal_category_id'] = kwargs.get(
                    'fiscal_category_id')

            result_fr = obj_fp_rule.with_context(
                ctx).apply_fiscal_mapping(**kwargs)

            result.update({
                'fiscal_position': result_fr['value']['fiscal_position']})
        return result<commit_msg>[10.0][MIG] Code.<commit_after># -*- coding: utf-8 -*-
# Copyright (C) 2016  <NAME> - KMEE                                #
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import models, api


class ProcurementOrder(models.Model):
    _name = "procurement.order"
    _inherit = [
        _name,
        "stock.invoice.state.mixin",
    ]

    @api.model
    def _get_stock_move_values(self):
        result = super(ProcurementOrder, self)._get_stock_move_values()
        if (self.rule_id and self.rule_id.fiscal_category_id and
                result['partner_id']):
            ctx = dict(self.env.context)
            ctx.update({'use_domain': ('use_picking', '=', True)})
            partner = self.env['res.partner'].browse(result['partner_id'])
            company = (self.warehouse_id.company_id or
                       self.company_id)
            kwargs = {
                'partner_id': partner,
                'product_id': self.product_id,
                'partner_invoice_id':  partner,
                # TODO: Implement fuction to compute partner invoice id
                'partner_shipping_id': partner,
                'fiscal_category_id': (
                    self.rule_id.fiscal_category_id
                ),
                'company_id': company,
                'context': ctx,
            }

            obj_fp_rule = self.env['account.fiscal.position.rule']
            product_fc_id = obj_fp_rule.with_context(
                ctx).product_fiscal_category_map(
                    kwargs.get('product_id'),
                    kwargs.get('fiscal_category_id'),
                    partner.state_id.id)

            if product_fc_id:
                kwargs['fiscal_category_id'] = product_fc_id
                result['fiscal_category_id'] = product_fc_id.id
            else:
                result['fiscal_category_id'] = kwargs.get(
                    'fiscal_category_id').id

            fiscal_position = obj_fp_rule.with_context(
                ctx).apply_fiscal_mapping(**kwargs)

            if fiscal_position:
                result.update({'fiscal_position_id': fiscal_position.id})

        return result
{'fraction_non_alphanumeric': 0.10633946830265849, 'fraction_numerical': 0.004317200636219041, 'mean_word_length': 1.7256965944272447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '359184', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1288, 'n_words': 194}