~unifield-team/unifield-server/trunk

« back to all changes in this revision

Viewing changes to bin/addons/mission_stock/wizard/mission_stock_wizard.py

  • Committer: jftempo
  • Date: 2017-11-29 12:01:16 UTC
  • mfrom: (4630.1.2 jfb-int)
  • Revision ID: jfb@tempo-consulting.fr-20171129120116-jlspxzk4j19cl5mq
US-2988 [IMP] Mission Stock: only products in stock

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
            [('true', 'Yes'), ('false', 'No')],
71
71
            string='Split the Warehouse stock qty. to Stock and Unallocated Stock.',
72
72
            required=True),
 
73
        'display_only_in_stock': fields.selection(
 
74
            [('true', 'Yes'), ('false', 'No')],
 
75
            string='Display only products in stock',
 
76
            required=True,
 
77
        ),
73
78
        'last_update': fields.datetime(
74
79
            string='Last update',
75
80
            readonly=True,
100
105
    _defaults = {
101
106
        'with_valuation': lambda *a: 'true',
102
107
        'split_stock': lambda *a: 'true',
 
108
        'display_only_in_stock': lambda *a: 'false',
103
109
        'fname': lambda *a: 'Mission stock report',
104
110
        'processed_state': lambda *a: 'not_started',
105
111
        'export_error_msg': lambda *a: False,
167
173
        c = context.copy()
168
174
        c.update({
169
175
            'mission_report_id': wiz_id.report_id.id,
170
 
            'with_valuation': wiz_id.with_valuation == 'true' and True or False,
171
 
            'split_stock': wiz_id.split_stock == 'true' and True or False,
 
176
            'with_valuation': wiz_id.with_valuation == 'true',
 
177
            'split_stock': wiz_id.split_stock == 'true',
172
178
            'hide_amc_fmc': wiz_id.report_id.full_view and (self.pool.get('res.users').browse(cr, uid, uid, c).company_id.instance_id.level in ['section', 'coordo']),
173
179
        })
 
180
        display_only_in_stock =  wiz_id.display_only_in_stock == 'true'
 
181
        if display_only_in_stock:
 
182
            # the qty column are not depending on with_valuation but only on
 
183
            # split_stock
 
184
            if wiz_id.split_stock == 'true':
 
185
                domain =[ '&',
 
186
                          ('mission_report_id', '=', wiz_id.report_id.id),
 
187
                          '|', '|', '|', '|', '|', '|', '|',
 
188
                          ('internal_qty', '!=', 0),
 
189
                          ('wh_qty', '!=', 0),
 
190
                          ('cross_qty', '!=', 0),
 
191
                          ('secondary_qty', '!=', 0),
 
192
                          ('cu_qty', '!=', 0),
 
193
                          ('in_pipe_qty', '!=', 0),
 
194
                          ('stock_qty', '!=', 0),
 
195
                          ('central_qty', '!=', 0)]
 
196
            else:
 
197
                # in case of split_stock is false, some fields are not
 
198
                # displayed, so do not take into account this quantity
 
199
                domain =[ '&',
 
200
                          ('mission_report_id', '=', wiz_id.report_id.id),
 
201
                          '|', '|', '|', '|',
 
202
                          ('internal_qty', '!=', 0),
 
203
                          ('cross_qty', '!=', 0),
 
204
                          ('secondary_qty', '!=', 0),
 
205
                          ('cu_qty', '!=', 0),
 
206
                          ('in_pipe_qty', '!=', 0)]
 
207
        else:
 
208
            domain = [('mission_report_id', '=', wiz_id.report_id.id)]
174
209
 
175
210
        return {'type': 'ir.actions.act_window',
176
211
                'name': '%s: %s' % (_('Stock mission report'), wiz_id.report_id.name),
177
212
                'res_model': 'stock.mission.report.line',
178
213
                'view_type': 'form',
179
214
                'view_mode': 'tree,form',
180
 
                'domain': [('mission_report_id', '=', wiz_id.report_id.id)],
 
215
                'domain': domain,
181
216
                'context': c,
182
217
                'target': 'current'}
183
218
 
250
285
        # add the requested field name and report_id to the datas
251
286
        # to be used later on in the stock_mission_report_xls_parser
252
287
        res = self.read(cr, uid, ids, ['with_valuation', 'split_stock',
253
 
                                       'report_id'], context=context)
 
288
                                       'report_id', 'display_only_in_stock'], context=context)
254
289
 
255
290
        field_name = None
256
291
        if res['split_stock'] == 'false' and res['with_valuation'] == 'false':
265
300
        datas['field_name'] = field_name
266
301
        datas['report_id'] = res['report_id']
267
302
        datas['file_format'] = file_format
 
303
        datas['display_only_in_stock'] = (res['display_only_in_stock'] == 'true')
268
304
 
269
305
        return {
270
306
            'type': 'ir.actions.report.xml',