improve stock transfer

This commit is contained in:
ronozoro 2024-12-21 18:46:48 -08:00
parent 95bd2d348c
commit 9da93a5602
No known key found for this signature in database
GPG Key ID: 9DC6CC94833D519C
2 changed files with 19 additions and 18 deletions

View File

@ -5,18 +5,20 @@ from odoo import api, fields, models
class PurcahseRefues(models.TransientModel):
_name = "purchase.request_picking.wizard"
_description = "purchase Checking Options wizard"
request_id = fields.Many2one('purchase.request')
request_line_ids = fields.Many2many('purchase.request.line')
is_available=fields.Boolean("Available")
is_available = fields.Boolean("Available")
show_purchase_only = fields.Boolean("Show Purchase Only", compute='_compute_show_purchase_only')
@api.depends('request_line_ids', 'request_id')
def _compute_show_purchase_only(self):
self.show_purchase_only = all(line.available_qty <= 0 for line in self.request_line_ids)
def delivery_close(self):
picking_id= self.env.ref('purchase_custom_stock.stock_picking_type_stock')
picking_id = self.env.ref('purchase_custom_stock.stock_picking_type_stock')
picking_vals = {
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
"origin": self.request_id.name,
@ -30,7 +32,7 @@ class PurcahseRefues(models.TransientModel):
"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,
'product_uom_qty': line.qty,
}))
picking_vals.update({'move_lines': move_vals})
picking_id = self.env['stock.picking'].create(picking_vals)
@ -38,7 +40,7 @@ class PurcahseRefues(models.TransientModel):
self.request_id.write({'state': 'employee'})
def delivery_purchase(self):
picking_id= self.env.ref('purchase_custom_stock.stock_picking_type_stock')
picking_id = self.env.ref('purchase_custom_stock.stock_picking_type_stock')
picking_vals = {
"picking_type_id": self.env.ref('purchase_custom_stock.stock_picking_type_stock').id,
"origin": self.request_id.name,
@ -55,16 +57,16 @@ class PurcahseRefues(models.TransientModel):
"product_uom": line.product_id.uom_id.id,
'product_uom_qty': line.qty,
}))
line.qty_purchased=0
line.qty_purchased = 0
else:
if line.available_qty > 0:
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,
'product_uom_qty': line.qty,
}))
line.qty_purchased = line.qty - line.available_qty
line.qty_purchased = line.qty
picking_vals.update({'move_lines': move_vals})
picking_id = self.env['stock.picking'].create(picking_vals)
self.request_id.picking_id = picking_id.id
@ -72,8 +74,9 @@ class PurcahseRefues(models.TransientModel):
[('name', '=', 'initial_engagement_budget'), ('state', '=', 'installed')], limit=1)
init_budget = True if init_active else False
for line in self.request_line_ids.filtered(lambda line: line.product_id.type != 'product'):
line.qty_purchased=line.qty
line.qty_purchased = line.qty
self.request_id.write({'state': 'wait_for_send' if init_budget else 'waiting'})
def convert_purchase(self):
picking_id = self.env.ref('purchase_custom_stock.stock_picking_type_stock')
picking_vals = {
@ -98,10 +101,5 @@ class PurcahseRefues(models.TransientModel):
[('name', '=', 'initial_engagement_budget'), ('state', '=', 'installed')], limit=1)
init_budget = True if init_active else False
for line in self.request_line_ids:
line.qty_purchased=line.qty
line.qty_purchased = line.qty
self.request_id.write({'state': 'wait_for_send' if init_budget else 'waiting'})

View File

@ -7,10 +7,13 @@
<form string="Cancel Request Reason">
<field name="request_id" invisible="1"/>
<field name="is_available" invisible="1"/>
<field name="show_purchase_only" 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 Purchase' attrs="{'invisible':[('is_available' , '=' , False)]}" name="delivery_purchase" 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),('show_purchase_only' , '=' , True)]}"
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"/>
</footer>