~sergio-incaser/openerp-spain/openerp-spain

« back to all changes in this revision

Viewing changes to extra_addons/stock_past/inventory.py

  • Committer: Jordi Esteve
  • Date: 2009-12-14 17:53:50 UTC
  • mfrom: (81.1.90 lp-openerp-spain-5.0)
  • Revision ID: jesteve@zikzakmedia.com-20091214175350-6vzzt3avtsof25a2
Recuperación del estado actual del repositorio de localización española de OpenERP: Aplicación de todos los merges pendientes desde la versión 81 (15-11-2008) hasta la actual (02-12-2009)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
from osv import fields,osv
3
3
 
4
4
class stock_inventory(osv.osv):
5
 
        _name = "stock.inventory"
6
 
        _inherit = 'stock.inventory'
7
 
        
8
 
        def action_done(self, cr, uid, ids, *args):
9
 
                for inv in self.browse(cr,uid,ids):
10
 
                        move_ids = []
11
 
                        move_line=[]
12
 
                        for line in inv.inventory_line_id:
13
 
                                pid=line.product_id.id
14
 
                                price=line.product_id.standard_price or 0.0
15
 
                                amount=self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id}, date_ref=inv.date)[pid]
16
 
                                change=line.product_qty-amount
17
 
                                if change:
18
 
                                        location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
19
 
                                        value = {
20
 
                                                'name': 'INV:'+str(line.inventory_id.id)+':'+line.inventory_id.name,
21
 
                                                'product_id': line.product_id.id,
22
 
                                                'product_uom': line.product_uom.id,
23
 
                                                'date': inv.date,
24
 
                                                'date_planned': inv.date,
25
 
                                                'state': 'assigned'
26
 
                                        }
27
 
                                        if change>0:
28
 
                                                value.update( {
29
 
                                                        'product_qty': change,
30
 
                                                        'location_id': location_id,
31
 
                                                        'location_dest_id': line.location_id.id,
32
 
                                                })
33
 
                                        else:
34
 
                                                value.update( {
35
 
                                                        'product_qty': -change,
36
 
                                                        'location_id': line.location_id.id,
37
 
                                                        'location_dest_id': location_id,
38
 
                                                })
39
 
                                        move_ids.append(self.pool.get('stock.move').create(cr, uid, value))
40
 
                        if len(move_ids):
41
 
                                self.pool.get('stock.move').action_done(cr, uid, move_ids)
42
 
                        self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S'), 'move_ids': [(6,0,move_ids)]})
43
 
                return True
 
5
    _name = "stock.inventory"
 
6
    _inherit = 'stock.inventory'
 
7
 
 
8
    def action_done(self, cr, uid, ids, *args):
 
9
        for inv in self.browse(cr,uid,ids):
 
10
            move_ids = []
 
11
            move_line=[]
 
12
            for line in inv.inventory_line_id:
 
13
                pid=line.product_id.id
 
14
                price=line.product_id.standard_price or 0.0
 
15
                amount=self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id}, date_ref=inv.date)[pid]
 
16
                change=line.product_qty-amount
 
17
                if change:
 
18
                    location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
 
19
                    value = {
 
20
                        'name': 'INV:'+str(line.inventory_id.id)+':'+line.inventory_id.name,
 
21
                        'product_id': line.product_id.id,
 
22
                        'product_uom': line.product_uom.id,
 
23
                        'date': inv.date,
 
24
                        'date_planned': inv.date,
 
25
                        'state': 'assigned'
 
26
                    }
 
27
                    if change>0:
 
28
                        value.update( {
 
29
                            'product_qty': change,
 
30
                            'location_id': location_id,
 
31
                            'location_dest_id': line.location_id.id,
 
32
                        })
 
33
                    else:
 
34
                        value.update( {
 
35
                            'product_qty': -change,
 
36
                            'location_id': line.location_id.id,
 
37
                            'location_dest_id': location_id,
 
38
                        })
 
39
                    move_ids.append(self.pool.get('stock.move').create(cr, uid, value))
 
40
            if len(move_ids):
 
41
                self.pool.get('stock.move').action_done(cr, uid, move_ids)
 
42
            self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S'), 'move_ids': [(6,0,move_ids)]})
 
43
        return True
44
44
 
45
45
stock_inventory()
46
46
 
47
47
 
48
48
class stock_inventory_line(osv.osv):
49
 
        _name = "stock.inventory.line"
50
 
        _inherit = 'stock.inventory.line'
51
 
        
52
 
        def on_change_product_id(self, cr, uid, ids, location_id, product, date_inv, uom=False):
53
 
                if not product:
54
 
                        return {}
55
 
                if not uom:
56
 
                        prod = self.pool.get('product.product').browse(cr, uid, [product], {'uom': uom})[0]
57
 
                        uom = prod.uom_id.id
58
 
                amount=self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom}, date_ref=date_inv)[product]
59
 
                result = {'product_qty':amount, 'product_uom':uom}
60
 
                return {'value':result}
 
49
    _name = "stock.inventory.line"
 
50
    _inherit = 'stock.inventory.line'
 
51
 
 
52
    def on_change_product_id(self, cr, uid, ids, location_id, product, date_inv, uom=False):
 
53
        if not product:
 
54
            return {}
 
55
        if not uom:
 
56
            prod = self.pool.get('product.product').browse(cr, uid, [product], {'uom': uom})[0]
 
57
            uom = prod.uom_id.id
 
58
        amount=self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom}, date_ref=date_inv)[product]
 
59
        result = {'product_qty':amount, 'product_uom':uom}
 
60
        return {'value':result}
61
61
stock_inventory_line()