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

« back to all changes in this revision

Viewing changes to msf_doc_import/wizard/wiz_common_import.py

  • Committer: Quentin THEURET
  • Date: 2016-03-04 11:27:47 UTC
  • Revision ID: qt@tempo-consulting.fr-20160304112747-jicftfrdqy4gyql1
US-826 [IMP] Add warning message on add multiple lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
        'search_default_not_restricted': 0,
175
175
    }
176
176
 
 
177
    def add_products(self, cr, uid, ids, product_ids, context=None):
 
178
        if not product_ids:
 
179
            return {}
 
180
 
 
181
        res = {}
 
182
        for wl in self.browse(cr, uid, ids, context=context):
 
183
            if wl.parent_model in ('tender', 'sale.order', 'purchase.order'):
 
184
                categ = self.pool.get(wl.parent_model).read(cr, uid, wl.parent_id.id, ['categ'], context=context)['categ']
 
185
                if categ:
 
186
                    not_ok_product_ids = self.pool.get('product.product').search(cr, uid, [
 
187
                        ('id', 'in', product_ids),
 
188
                        ('purchase_type', '=', categ),
 
189
                    ], context=context)
 
190
                    if not_ok_product_ids:
 
191
                        res.update({
 
192
                            'warning': {
 
193
                                'title': _('Warning'),
 
194
                                'message': _('Warning you are about to add a product which does not conform to this PO’s order category, do you wish to proceed ?'),
 
195
                            },
 
196
                        })
 
197
 
 
198
        return res
 
199
 
 
200
 
177
201
    def fill_lines(self, cr, uid, ids, context=None):
178
202
        '''
179
203
        Fill the line of attached document