65
65
for line in sale_brw.order_line:
66
66
virtual = line.product_id.qty_available
67
67
real = line.product_id.virtual_available
68
if virtual == real and line.product_uom_qty > virtual or line.product_uom_qty > virtual:
68
if virtual == real and\
69
line.product_uom_qty > virtual or\
70
line.product_uom_qty > virtual:
69
71
raise osv.except_osv(_('Error'), _(
70
'The quantity in the line of the product %s is minor that quantity available ' % line.product_id.name))
72
'The quantity in the line of the product %s is minor that\
73
quantity available ' % line.product_id.name))
72
elif virtual > real and line.product_uom_qty > real and line.product_uom_qty < virtual and not line.check_confirm:
75
elif virtual > real and line.product_uom_qty > real and\
76
line.product_uom_qty < virtual and not line.check_confirm:
73
77
raise osv.except_osv(_('Error'), _(
74
'The amount you want to sell is not available in the real stock of product %s, but if a shipment next, if you want to make this sale select Stock future sales line' % line.product_id.name))
78
'The amount you want to sell is not available in the real\
79
stock of product %s, but if a shipment next, if you want\
80
to make this sale select Stock future sales line'
81
% line.product_id.name))
81
86
class sale_order_line(osv.Model):
83
88
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
84
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
85
lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
89
uom=False, qty_uos=0, uos=False, name='',
91
lang=False, update_tax=True, date_order=False,
92
packaging=False, fiscal_position=False, flag=False,
86
94
if context is None:
88
96
product_obj = self.pool.get('product.product')
90
sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
91
uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
92
lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag)
98
sale_order_line, self).product_id_change(cr, uid, ids, pricelist,
100
uom=uom, qty_uos=qty_uos,
102
partner_id=partner_id,
104
update_tax=update_tax,
105
date_order=date_order,
107
fiscal_position=fiscal_position, flag=flag)
94
109
future_stock = product and self.pool.get(
95
110
'stock.move').search(cr, uid, [('product_id', '=', product),
97
'assigned', 'confirmed', 'waiting')),
98
('picking_id.type', '=', 'in')], context=context)
112
'assigned', 'confirmed', 'waiting')),
113
('picking_id.type', '=', 'in')], context=context)
99
114
future_stock and res.get('value', False) and res.get(
100
115
'value', False).update({'stock_move_ids': future_stock})
104
119
_inherit = 'sale.order.line'
106
'stock_move_ids': fields.one2many('stock.move', 'id_sale', 'Future Stock', readonly=True, help="Stock move future to reference of salesman for knowing that product is available"),
107
'check_confirm': fields.boolean("Future Stock'", help="This field indicates if the salesman is in accordance with sale a product that is not available but if in a future stock"),
121
'stock_move_ids': fields.one2many('stock.move', 'id_sale',
122
'Future Stock', readonly=True,
123
help="Stock move future to reference of salesman for knowing that\
124
product is available"),
125
'check_confirm': fields.boolean("Future Stock'",
126
help="This field indicates if the salesman is in accordance with\
127
sale a product that is not available but if in a\