~julie-w/unifield-wm/UTP-560

« back to all changes in this revision

Viewing changes to specific_rules/specific_rules.py

  • Committer: jf
  • Date: 2016-02-08 17:28:51 UTC
  • mfrom: (2753.9.5 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20160208172851-6boltyee0n3d2q3k
US-913 [FIX] Product attribute change is not directly reflected on Initial Stock Inventory (ISI)
US-901 [FIX] Report regarding unconsistencies between ED/BM
lp:~unifield-team/unifield-wm/us-901

Show diffs side-by-side

added added

removed removed

Lines of Context:
1875
1875
                    return False
1876
1876
        return True
1877
1877
 
 
1878
    def _get_bm_perishable(self, cr, uid, ids, field_name, args, context=None):
 
1879
        res = {}
 
1880
 
 
1881
        for line in self.browse(cr, uid, ids, context=context):
 
1882
            res[line.id] = {
 
1883
                'hidden_batch_management_mandatory': line.product_id.batch_management,
 
1884
                'hidden_perishable_mandatory': line.product_id.perishable,
 
1885
            }
 
1886
 
 
1887
        return res
 
1888
 
 
1889
    def _get_products(self, cr, uid, ids, context=None):
 
1890
        inv_ids = self.pool.get('stock.inventory').search(cr, uid, [
 
1891
            ('state', 'not in', ['done', 'cancel']),
 
1892
        ], context=context)
 
1893
        return self.pool.get('stock.inventory.line').search(cr, uid, [
 
1894
            ('inventory_id', 'in', inv_ids),
 
1895
            ('product_id', 'in', ids),
 
1896
        ], context=context)
 
1897
 
1878
1898
    _columns = {
1879
 
        'hidden_perishable_mandatory': fields.boolean(string='Hidden Flag for Perishable product',),
1880
 
        'hidden_batch_management_mandatory': fields.boolean(string='Hidden Flag for Batch Management product',),
 
1899
        'hidden_perishable_mandatory': fields.function(
 
1900
            _get_bm_perishable,
 
1901
            type='boolean',
 
1902
            method=True,
 
1903
            string='Hidden Flag for Perishable product',
 
1904
            multi='bm_perishable',
 
1905
            store={
 
1906
                'stock.inventory.line': (lambda self, cr, uid, ids, c=None: ids, ['product_id'], 10),
 
1907
                'product.product': (_get_products, ['perishable'], 20),
 
1908
            },
 
1909
        ),
 
1910
        'hidden_batch_management_mandatory': fields.function(
 
1911
            _get_bm_perishable,
 
1912
            type='boolean',
 
1913
            method=True,
 
1914
            string='Hidden Flag for Perishable product',
 
1915
            multi='bm_perishable',
 
1916
            store={
 
1917
                'stock.inventory.line': (lambda self, cr, uid, ids, c=None: ids, ['product_id'], 10),
 
1918
                'product.product': (_get_products, ['batch_management'], 20),
 
1919
            },
 
1920
        ),
1881
1921
        # Remove the 'required' attribute on location_id to allow the possiblity to fill lines with list or nomenclature
1882
1922
        # The required attribute is True on the XML view
1883
1923
        'location_id': fields.many2one('stock.location', 'Location'),