40
40
update the name attribute if a product is selected
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 !'))
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:
59
69
update the name attribute if a product is selected
73
if isinstance(ids, (int, long)):
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'),)
67
return super(purchase_order_line, self).write(cr, uid, ids, vals, context=context)
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 !'))
69
91
def _get_manufacturers(self, cr, uid, ids, field_name, arg, context=None):
71
93
get manufacturers info