From 9da93a56020ad19dd98a370bb6bc4b17e0cd5bc4 Mon Sep 17 00:00:00 2001 From: ronozoro Date: Sat, 21 Dec 2024 18:46:48 -0800 Subject: [PATCH] improve stock transfer --- .../wizards/picking_purchase_request.py | 30 +++++++++---------- .../wizards/picking_purchase_request.xml | 7 +++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.py b/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.py index af889abe1..e2b283581 100644 --- a/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.py +++ b/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.py @@ -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'}) - - - - - diff --git a/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.xml b/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.xml index 0b950121e..1b8885bfa 100644 --- a/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.xml +++ b/odex25_purchase/purchase_custom_stock/wizards/picking_purchase_request.xml @@ -7,10 +7,13 @@
+