recycle
This commit is contained in:
parent
9effea48ed
commit
4eda96ba80
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -122,53 +122,67 @@ class PurchaseRequest(models.Model):
|
|||
raise ValidationError(_("Can't Confirm Request With No Item!"))
|
||||
if not self.department_id:
|
||||
raise ValidationError(_("Please Select department for employee"))
|
||||
picking_id= self.env.ref('purchase_custom_stock.stock_picking_type_stock')
|
||||
|
||||
available=False
|
||||
if any(self.line_ids.filtered(lambda line: line.available_qty >0 )):
|
||||
available=True
|
||||
if any(self.line_ids.filtered(lambda line: line.product_id.type == 'product' )):
|
||||
storable_product_lines=self.line_ids.filtered(lambda line: line.product_id.type == 'product' )
|
||||
non_storable_product = self.line_ids - storable_product_lines
|
||||
if any(storable_product_lines.filtered(lambda line: line.available_qty > 0)):
|
||||
available = True
|
||||
if any(storable_product_lines.filtered(lambda store_line: store_line.qty > store_line.available_qty)):
|
||||
context = {}
|
||||
view = self.env.ref('purchase_custom_stock.purchase_request_picking_wizard_view_form')
|
||||
wiz = self.env['purchase.request_picking.wizard']
|
||||
context['default_request_id'] = self.id
|
||||
context['default_is_available'] = available
|
||||
storable_product = self.line_ids.filtered(lambda line: line.product_id.type == 'product')
|
||||
context['default_request_line_ids'] = [
|
||||
(6, 0, self.line_ids.ids)]
|
||||
|
||||
return {
|
||||
'name': _('Picking Options'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'purchase.request_picking.wizard',
|
||||
'views': [(view.id, 'form')],
|
||||
'view_id': view.id,
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
else:
|
||||
picking_vals = {
|
||||
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
|
||||
"origin": self.name,
|
||||
"location_id": self.location_id.id,
|
||||
"location_dest_id": picking_id.default_location_dest_id.id
|
||||
}
|
||||
move_vals = []
|
||||
for line in storable_product_lines:
|
||||
move_vals.append((0, 0, {
|
||||
"product_id": line.product_id.id,
|
||||
"name": line.product_id.name,
|
||||
"product_uom": line.product_id.uom_id.id,
|
||||
'product_uom_qty': line.qty,
|
||||
|
||||
if any(self.line_ids.filtered(lambda line: line.qty > line.available_qty and line.product_id.type == 'product' )):
|
||||
context={}
|
||||
view = self.env.ref('purchase_custom_stock.purchase_request_picking_wizard_view_form')
|
||||
wiz = self.env['purchase.request_picking.wizard']
|
||||
context['default_request_id'] = self.id
|
||||
context['default_is_available'] = available
|
||||
context['default_request_line_ids'] = [(6,0,self.line_ids.filtered(lambda line: line.product_id.type == 'product').ids)]
|
||||
|
||||
return {
|
||||
'name': _('Picking Options'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'purchase.request_picking.wizard',
|
||||
'views': [(view.id, 'form')],
|
||||
'view_id': view.id,
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
}))
|
||||
line.qty_purchased = 0
|
||||
picking_vals.update({'move_lines': move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
self.picking_id = picking_id.id
|
||||
if non_storable_product:
|
||||
for rec in non_storable_product:
|
||||
rec.qty_purchased = rec.qty
|
||||
self.write({'state': 'waiting'})
|
||||
else:
|
||||
self.write({'state': 'employee'})
|
||||
else:
|
||||
picking_vals = {
|
||||
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
|
||||
"origin": self.name,
|
||||
"location_id": self.location_id.id,
|
||||
"location_dest_id":self.picking_type_id.default_location_dest_id.id
|
||||
}
|
||||
for line in self.line_ids:
|
||||
line.qty_purchased = line.qty
|
||||
self.write({'state': 'waiting'})
|
||||
|
||||
move_vals=[]
|
||||
for line in self.line_ids.filtered(lambda line: line.qty <= line.available_qty and line.product_id.type != 'service'):
|
||||
move_vals.append((0,0,{
|
||||
"product_id":line.product_id.id,
|
||||
"name":line.product_id.name,
|
||||
"product_uom":line.product_id.uom_id.id,
|
||||
'product_uom_qty': line.available_qty,
|
||||
|
||||
}))
|
||||
picking_vals.update({'move_lines':move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
self.picking_id = picking_id.id
|
||||
self.write({'state': 'employee'})
|
||||
|
||||
# self.picking_id.write({"move_lines":move_vals})
|
||||
|
||||
|
||||
def open_picking(self):
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -47,7 +47,7 @@ class PurcahseRefues(models.TransientModel):
|
|||
}
|
||||
|
||||
move_vals = []
|
||||
for line in self.request_line_ids:
|
||||
for line in self.request_line_ids.filtered(lambda line: line.product_id.type == 'product'):
|
||||
if line.qty < line.available_qty:
|
||||
move_vals.append((0, 0, {
|
||||
"product_id": line.product_id.id,
|
||||
|
|
@ -68,6 +68,8 @@ class PurcahseRefues(models.TransientModel):
|
|||
picking_vals.update({'move_lines': move_vals})
|
||||
picking_id = self.env['stock.picking'].create(picking_vals)
|
||||
self.request_id.picking_id = picking_id.id
|
||||
for line in self.request_line_ids.filtered(lambda line: line.product_id.type != 'product'):
|
||||
line.qty_purchased=line.qty
|
||||
self.request_id.write({'state': 'waiting'})
|
||||
def convert_purchase(self):
|
||||
for line in self.request_line_ids:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<field name="is_available" invisible="1"/>
|
||||
|
||||
<footer>
|
||||
<button string='Delivery and Close' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_close" type="object" class="oe_highlight"/>
|
||||
<!-- <button string='Delivery and Close' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_close" type="object" class="oe_highlight"/>-->
|
||||
<button string='Delivery and Purchase' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_purchase" type="object" class="oe_highlight"/>
|
||||
<button string='Convert Purchase' name="convert_purchase" type="object" class="oe_highlight"/>
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue