<commit_before># -*- coding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2001-2015 <NAME>. (<http://www.micronaet.it>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

import os
import sys
import logging
import openerp
import openerp.netsvc as netsvc
import openerp.addons.decimal_precision as dp
from openerp.osv import fields, osv, expression, orm
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from openerp import SUPERUSER_ID, api
from openerp import tools
from openerp.tools.translate import _
from openerp.tools.float_utils import float_round as round
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT, 
    DEFAULT_SERVER_DATETIME_FORMAT, 
    DATETIME_FORMATS_MAP, 
    float_compare)


_logger = logging.getLogger(__name__)

class MrpMoveLavoration(orm.TransientModel):
    ''' Move from one lavoration to end in another date (and recalculate 
        parameters)
    '''
    
    _name = "mrp.production.move.lavoration.wizard"

    # --------------
    # Wizard button:
    # --------------
    def move_lavoration_item(self, cr, uid, ids, context=None):
        ''' Assign production to selected order line
        '''
        if context is None: 
            context = {}        
        active_id = context.get('active_id', False)    
        
        # Read wizard parameters:
        wizard_browse = self.browse(cr, uid, ids, context=context)[0]
        
        # Move lavoration after passed:
        lavoration_pool = self.pool.get('mrp.production.workcenter.line')
        

        return {'type':'ir.actions.act_window_close'}

    # ------------------
    # Defaults function:
    # ------------------
    def _get_info_in_plan(self, cr, uid, field, context=None):
        ''' Read workers in lavoration plan (first for now)
        '''
        if context is None: 
            context = {}
        try:    
            active_id = context.get('active_id', False)    
            wc_pool = self.pool.get('mrp.production.workcenter.line')
            wc_proxy = wc_pool.browse(cr, uid, active_id, context=context)
            
            # Planner:
            if field == 'workers':
                return wc_proxy.production_id.lavoration_ids[0].workers
            elif field == 'workcenter_id':
                return wc_proxy.production_id.lavoration_ids[0].line_id.id<commit_msg>Start prepare context parameter for procedure (to be modified also for this purpose)<commit_after># -*- coding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2001-2015 Micronaet S.r.l. (<http://www.micronaet.it>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

import os
import sys
import logging
import openerp
import openerp.netsvc as netsvc
import openerp.addons.decimal_precision as dp
from openerp.osv import fields, osv, expression, orm
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from openerp import SUPERUSER_ID, api
from openerp import tools
from openerp.tools.translate import _
from openerp.tools.float_utils import float_round as round
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT, 
    DEFAULT_SERVER_DATETIME_FORMAT, 
    DATETIME_FORMATS_MAP, 
    float_compare)


_logger = logging.getLogger(__name__)

class MrpMoveLavoration(orm.TransientModel):
    ''' Move from one lavoration to end in another date (and recalculate 
        parameters)
    '''
    
    _name = "mrp.production.move.lavoration.wizard"

    # --------------
    # Wizard button:
    # --------------
    def move_lavoration_item(self, cr, uid, ids, context=None):
        ''' Assign production to selected order line
        '''
        if context is None: 
            context = {}        
        active_id = context.get('active_id', False)    

        # Pool used:        
        mrp_pool = self.pool.get('mrp.production')
        wc_pool = self.pool.get('mrp.production.workcenter.line')

        # Read wizard parameters:
        wiz_proxy = self.browse(cr, uid, ids, context=context)[0]        

        # Get all lavorations to move:
        lavoration_ids = wc_pool.search(cr, uid, [
            ('production_id', '=', 
                wiz_proxy.scheduled_lavorarion_id.production_id.id),
            ('date_planned', '>=', 
                wiz_proxy.scheduled_lavorarion_id.date_planned),
            ], context=context)
        
        if not lavoration_ids: # maybe deleted or moved before confirmation
            return True
            
        move_context = context.copy()
        move_context.update({
            'move_lavoration_ids': lavoration_ids,
            'move_date': wiz_proxy.new_date,
            'move_workhour_id': wiz_proxy.workhour_id.id,
            'move_workcenter_id': wiz_proxy.wokrcenter_id.id,
            'move_workers': wiz_proxy.workers,
            'move_bom_id': wiz_proxy.bom_id.id,
            })
        
        mrp_pool.schedule_lavoration(cr, uid, [wiz_proxy.production_id.id], 
            context=move_context)

        return {'type':'ir.actions.act_window_close'}

    # ------------------
    # Defaults function:
    # ------------------
    def _get_info_in_plan(self, cr, uid, field, context=None):
        ''' Read workers in lavoration plan (first for now)
        '''
        if context is None: 
            context = {}
        try:    
            active_id = context.get('active_id', False)    
            wc_pool = self.pool.get('mrp.production.workcenter.line')
            wc_proxy = wc_pool.browse(cr, uid, active_id, context=context)
            
            # Planner:
            if field == 'workers':
                return wc_proxy.production_id.lavoration_ids[0].workers
            elif field == 'workcenter_id':
                return wc_proxy.production_id.lavoration_ids[0].line_id.id
{'fraction_non_alphanumeric': 0.14107094319108454, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 2.6813406703351674, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5655848', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1994, 'n_words': 597}