~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to specific_rules/specific_rules.py

  • Committer: Quentin THEURET
  • Date: 2016-02-08 08:59:27 UTC
  • mto: This revision was merged to the branch mainline in revision 2762.
  • Revision ID: qt@tempo-consulting.fr-20160208085927-ev5m5e1j1njk17qo
US-913 [FIX] Perishable and batch management product checkboxes on PI and ISI are now functional field

Show diffs side-by-side

added added

removed removed

Lines of Context:
1838
1838
                    return False
1839
1839
        return True
1840
1840
 
 
1841
    def _get_bm_perishable(self, cr, uid, ids, field_name, args, context=None):
 
1842
        res = {}
 
1843
 
 
1844
        for line in self.browse(cr, uid, ids, context=context):
 
1845
            res[line.id] = {
 
1846
                'hidden_batch_management_mandatory': line.product_id.batch_management,
 
1847
                'hidden_perishable_mandatory': line.product_id.perishable,
 
1848
            }
 
1849
 
 
1850
        return res
 
1851
 
 
1852
    def _get_products(self, cr, uid, ids, context=None):
 
1853
        inv_ids = self.pool.get('stock.inventory').search(cr, uid, [
 
1854
            ('state', 'not in', ['done', 'cancel']),
 
1855
        ], context=context)
 
1856
        return self.pool.get('stock.inventory.line').search(cr, uid, [
 
1857
            ('inventory_id', 'in', inv_ids),
 
1858
            ('product_id', 'in', ids),
 
1859
        ], context=context)
 
1860
 
1841
1861
    _columns = {
1842
 
        'hidden_perishable_mandatory': fields.boolean(string='Hidden Flag for Perishable product',),
1843
 
        'hidden_batch_management_mandatory': fields.boolean(string='Hidden Flag for Batch Management product',),
 
1862
        'hidden_perishable_mandatory': fields.function(
 
1863
            _get_bm_perishable,
 
1864
            type='boolean',
 
1865
            method=True,
 
1866
            string='Hidden Flag for Perishable product',
 
1867
            multi='bm_perishable',
 
1868
            store={
 
1869
                'stock.inventory.line': (lambda self, cr, uid, ids, c=None: ids, ['product_id'], 10),
 
1870
                'product.product': (_get_products, ['perishable'], 20),
 
1871
            },
 
1872
        ),
 
1873
        'hidden_batch_management_mandatory': fields.function(
 
1874
            _get_bm_perishable,
 
1875
            type='boolean',
 
1876
            method=True,
 
1877
            string='Hidden Flag for Perishable product',
 
1878
            multi='bm_perishable',
 
1879
            store={
 
1880
                'stock.inventory.line': (lambda self, cr, uid, ids, c=None: ids, ['product_id'], 10),
 
1881
                'product.product': (_get_products, ['batch_management'], 20),
 
1882
            },
 
1883
        ),
1844
1884
        # Remove the 'required' attribute on location_id to allow the possiblity to fill lines with list or nomenclature
1845
1885
        # The required attribute is True on the XML view
1846
1886
        'location_id': fields.many2one('stock.location', 'Location'),