<commit_before># -*- coding: utf-8 -*-
# Copyright YEAR(S), AUTHOR(S)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models


class StockPicking(models.Model):
    _inherit = 'stock.picking'

    @api.model
    def picking_account_move_generate(self, move, credit_account_id,
                                      debit_account_id, journal_id):
        quant_obj = self.env['stock.quant']
        move_obj = self.env['account.move']
        if move.location_id.usage == 'production' and \
                move.location_dest_id.usage == 'production':
            return

        reference = False
        if move.picking_id:
            reference = move.picking_id.name or False
        elif move.production_id:
            reference = move.production_id.name or False
        elif move.raw_material_production_id:
            reference = move.raw_material_production_id.name or False
        elif move.inventory_id:
            reference = move.name or False
        else:
            reference = "W/O Reference"

        cost = move.get_price_unit(move)
        qty = move.product_uom_qty

        move_lines = quant_obj._prepare_account_move_line(
            move, qty, cost, credit_account_id,
            debit_account_id)

        date = self._context.get('force_period_date',
                                 fields.datetime.now()
                                 )
        new_move = move_obj.create({
            'journal_id': journal_id,
            'line_ids': move_lines,
            'date': date,
            'ref': reference
        })
        new_move.post()
        move.acc_move_id = new_move

    @api.multi
    def picking_prepare_account_move(self):
        quant_obj = self.env['stock.quant']
        for pick in self:
            move_ids = []
            for move in pick.move_lines:
                location_from = move.location_id
                location_to = move.location_dest_id
                company_from = location_from._location_owner(location_from)
                company_to = location_to._location_owner(location_to)
<commit_msg>se valida que el move esten en done par crear el asiento contable<commit_after># -*- coding: utf-8 -*-
# Copyright YEAR(S), AUTHOR(S)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models


class StockPicking(models.Model):
    _inherit = 'stock.picking'

    @api.model
    def picking_account_move_generate(self, move, credit_account_id,
                                      debit_account_id, journal_id):
        quant_obj = self.env['stock.quant']
        move_obj = self.env['account.move']
        if move.location_id.usage == 'production' and \
                move.location_dest_id.usage == 'production':
            return

        reference = False
        if move.picking_id:
            reference = move.picking_id.name or False
        elif move.production_id:
            reference = move.production_id.name or False
        elif move.raw_material_production_id:
            reference = move.raw_material_production_id.name or False
        elif move.inventory_id:
            reference = move.name or False
        else:
            reference = "W/O Reference"

        cost = move.get_price_unit(move)
        qty = move.product_uom_qty

        move_lines = quant_obj._prepare_account_move_line(
            move, qty, cost, credit_account_id,
            debit_account_id)

        date = self._context.get('force_period_date',
                                 fields.datetime.now()
                                 )
        new_move = move_obj.create({
            'journal_id': journal_id,
            'line_ids': move_lines,
            'date': date,
            'ref': reference
        })
        new_move.post()
        move.acc_move_id = new_move

    @api.multi
    def picking_prepare_account_move(self):
        quant_obj = self.env['stock.quant']
        for pick in self:
            move_ids = []
            for move in pick.move_lines:
                if move.state != 'done':
                    continue
                location_from = move.location_id
                location_to = move.location_dest_id
                company_from = location_from._location_owner(location_from)
                company_to = location_to._location_owner(location_to)

{'fraction_non_alphanumeric': 0.08657810352725608, 'fraction_numerical': 0.001374255611543747, 'mean_word_length': 1.8486627527723418, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3135271', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1218, 'n_words': 252}