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

« back to all changes in this revision

Viewing changes to purchase_msf/purchase_msf.py

  • Committer: Quentin THEURET
  • Date: 2014-03-05 16:51:14 UTC
  • mto: (2004.1.33 unifield-wm)
  • mto: This revision was merged to the branch mainline in revision 2016.
  • Revision ID: qt@tempo-consulting.fr-20140305165114-m3n5p978sisi4n3f
REF-27 [FIX] Fix import of tools.translate

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        '''
40
40
        update the name attribute if a product is selected
41
41
        '''
 
42
        if not context:
 
43
            context = {}
42
44
        sol_obj = self.pool.get('sale.order.line')
43
45
        prod_obj = self.pool.get('product.product')
44
46
        if vals.get('product_id'):
45
47
            vals.update(name=prod_obj.browse(cr, uid, vals.get('product_id'), context=context).name,)
46
48
        elif vals.get('comment'):
47
49
            vals.update(name=vals.get('comment'),)
 
50
        if not context.get('import_in_progress', False):
 
51
            product_id = vals.get('product_id', False)
 
52
            product_uom = vals.get('product_uom', False)
 
53
            if product_id and product_uom:
 
54
                if not self.pool.get('uom.tools').check_uom(cr, uid, product_id, product_uom, context):
 
55
                    raise osv.except_osv(_('Error'),
 
56
                                         _('You have to select a product UOM in the same category than the purchase UOM of the product !'))
 
57
 
48
58
        # utp-518:we write the comment from the sale.order.line on the PO line through the procurement (only for the create!!)
49
59
        po_procurement_id = vals.get('procurement_id', False)
50
60
        if po_procurement_id:
58
68
        '''
59
69
        update the name attribute if a product is selected
60
70
        '''
 
71
        if not context:
 
72
            context = {}
 
73
        if isinstance(ids, (int, long)):
 
74
            ids = [ids]
61
75
        prod_obj = self.pool.get('product.product')
62
76
        if vals.get('product_id'):
63
77
            vals.update(name=prod_obj.browse(cr, uid, vals.get('product_id'), context=context).name,)
64
78
        elif vals.get('comment'):
65
79
            vals.update(name=vals.get('comment'),)
66
 
            
67
 
        return super(purchase_order_line, self).write(cr, uid, ids, vals, context=context)
68
 
    
 
80
        res = super(purchase_order_line, self).write(cr, uid, ids, vals, context=context)
 
81
        if not context.get('import_in_progress', False):
 
82
            for pol_read in self.read(cr, uid, ids, ['product_id', 'product_uom']):
 
83
                if pol_read.get('product_id'):
 
84
                    product_id = pol_read['product_id'][0]
 
85
                    uom_id = pol_read['product_uom'][0]
 
86
                    if not self.pool.get('uom.tools').check_uom(cr, uid, product_id, uom_id, context):
 
87
                        raise osv.except_osv(_('Error'), _('You have to select a product UOM in the same category than the purchase UOM of the product !'))
 
88
 
 
89
        return res
 
90
 
69
91
    def _get_manufacturers(self, cr, uid, ids, field_name, arg, context=None):
70
92
        '''
71
93
        get manufacturers info