<commit_before>from osv import fields, osv
from openerp import netsvc

class lot_to_sale_order_line(osv.osv):
    _name='sale.order.line'
    _inherit='sale.order.line'
    ''''''
    def _sel_func(self, cr, uid, context=None):
        print '_sel_func'
        obj = self.pool.get('stock.production.lot')
        #sol = self.pool.get('sale.order.line').browse(cr, uid, context['active_id'], context)('product_id', '=', sol.product_id)
        ids = obj.search(cr, uid, [])
        res = obj.read(cr, uid, ids, ['name', 'id'], context)
        res = [(r['id'], r['name']) for r in res]
        return res
        
    _columns = {
        #'dd': fields.function(_get_date, method=True, type='char',store=True, string='Delivery date'),
        'prodlot_id': fields.many2one('stock.production.lot', 'Lot', selection=_sel_func)
    }
    
    _defaults = {
        #'delivery_date':  lambda self, cr, uid, ctx: self._get_delivery_date(cr,uid,'sale.order.line', ctx),
    }

lot_to_sale_order_line()

class sales_order_with_lot(osv.osv):
    _name='sale.order'
    _inherit='sale.order'
        
    def action_button_confirm(self, cr, uid, ids, context=None):
        # Call superclass handler
        print 'action_button_confirm'
        # check that selected lot has correct product
        sos = self.pool.get('sale.order').browse(cr, uid, ids, context)
        for so in sos:
            for sol in so.order_line:
                if sol.prodlot_id:
                    if not sol.product_id.id == sol.prodlot_id.product_id.id:
                        raise osv.except_osv('Error', 'Production lot and product do not match')
        
        res = super(sales_order_with_lot, self).action_button_confirm(cr, uid, ids, context)<commit_msg>classes are now subclassing osv.osv<commit_after>from osv import fields, osv
from openerp import netsvc

class lot_to_sale_order_line(osv.osv):
    _name='sale.order.line'
    _inherit='sale.order.line'
    ''''''
    def _sel_func(self, cr, uid, context=None):
        print '_sel_func'
        obj = self.pool.get('stock.production.lot')
        #sol = self.pool.get('sale.order.line').browse(cr, uid, context['active_id'], context)('product_id', '=', sol.product_id)
        ids = obj.search(cr, uid, [])
        res = obj.read(cr, uid, ids, ['name', 'id'], context)
        res = [(r['id'], r['name']) for r in res]
        return res
    
    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
        print 'product_id_change'
        print 'product ' + str(product)
        res = super(lot_to_sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name='', partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
        return res
    
    _columns = {
        #'dd': fields.function(_get_date, method=True, type='char',store=True, string='Delivery date'),
        'prodlot_id': fields.many2one('stock.production.lot', 'Lot', selection=_sel_func)
    }
    
    _defaults = {
        #'delivery_date':  lambda self, cr, uid, ctx: self._get_delivery_date(cr,uid,'sale.order.line', ctx),
    }

lot_to_sale_order_line()

class sales_order_with_lot(osv.osv):
    _name='sale.order'
    _inherit='sale.order'
        
    def action_button_confirm(self, cr, uid, ids, context=None):
        # Call superclass handler
        print 'action_button_confirm'
        # check that selected lot has correct product
        sos = self.pool.get('sale.order').browse(cr, uid, ids, context)
        for so in sos:
            for sol in so.order_line:
                if sol.prodlot_id:
                    if not sol.product_id.id == sol.prodlot_id.product_id.id:
                        raise osv.except_osv('Error', 'Production lot and product do not match')
        
        res = super(sales_order_with_lot, self).action_button_confirm(cr, uid, ids, context)
{'fraction_non_alphanumeric': 0.1354016354016354, 'fraction_numerical': 0.000962000962000962, 'mean_word_length': 3.0854616895874263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '612536', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1381, 'n_words': 298}