~numerigraphe-team/+junk/7.0-integration

« back to all changes in this revision

Viewing changes to stock_inventory_date_constraint/stock.py

  • Committer: Loïc BELLIER
  • Date: 2014-06-02 13:07:30 UTC
  • mfrom: (112.1.21 7.0)
  • Revision ID: lb@numerigraphe.com-20140602130730-z9wey29qnwvj8koo
[MERGE]: merge from dev branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
 
25
25
class StockInventoryCancelable(osv.osv):
26
 
    """Make inventories cancelable despite the constraint on stock move dates""" 
 
26
    """Make inventories cancelable despite the constraint on stock move dates"""
27
27
    _inherit = "stock.inventory"
28
28
 
29
29
    def action_cancel_inventory(self, cr, uid, ids, context=None):
41
41
 
42
42
    _inherit = 'stock.move'
43
43
 
44
 
    def _past_inventories(self, cr, uid, product_ids, prodlot_ids, location_ids, limit_date, context=None):
 
44
    def _past_inventories(self, cr, uid, product_ids, prodlot_ids,
 
45
                          location_ids, limit_date, context=None):
45
46
        """Search for inventories already finished after a given date"""
46
47
        # Search for inventory lines with the given location / prodlot / product
47
48
        if context is None:
48
49
            context = {}
49
 
        sil_obj = self.pool.get('stock.inventory.line')
 
50
        sil_obj = self.pool['stock.inventory.line']
50
51
        sil_ids = sil_obj.search(cr, uid, [('product_id', 'in', product_ids),
51
52
                                           ('prod_lot_id', 'in', prodlot_ids),
52
53
                                           ('location_id', 'in', location_ids),
59
60
                         for i in sil_obj.read(cr, uid,
60
61
                                               sil_ids, ['inventory_id'],
61
62
                                               context=context)]
62
 
        return self.pool.get('stock.inventory').search(
 
63
        return self.pool['stock.inventory'].search(
63
64
                cr, uid, [('id', 'in', inventory_ids),
64
65
                          ('state', '=', 'done'),
65
66
                          ('date', '>=', limit_date)], context=context)
82
83
                                             vals.get('date'), context=context)
83
84
            if inv_ids:
84
85
                # Make a message string with the names of the Inventories
85
 
                inventories = self.pool.get("stock.inventory").browse(cr, uid, inv_ids, context=context)
 
86
                inventories = self.pool["stock.inventory"].browse(cr, uid, inv_ids, context=context)
86
87
                tab_inventories = {i.id: i.name for i in inventories}
87
88
                msg = "\n".join([_("- %s (ID %d)") % (name, i)
88
89
                                for (i, name) in tab_inventories.iteritems()])
133
134
 
134
135
        if inv_ids:
135
136
            # Make a message string with the names of the Inventories
136
 
            inventories = self.pool.get("stock.inventory").browse(cr, uid, inv_ids, context=context)
 
137
            inventories = self.pool["stock.inventory"].browse(cr, uid, inv_ids, context=context)
137
138
            tab_inventories = {i.id: i.name for i in inventories}
138
139
            msg = "\n".join([_("- %s (ID %d)") % (name, i)
139
140
                            for (i, name) in tab_inventories.iteritems()])