From 40998277a08ae559221d29d1e0f66f26c56b5823 Mon Sep 17 00:00:00 2001 From: Bruno Zanotti Date: Tue, 17 Oct 2023 11:46:42 +0000 Subject: [PATCH] [MIG] stock_batch_picking_ux: Migration to 16.0 closes ingadhoc/stock#405 Signed-off-by: Nicolas Mac Rouillon --- stock_batch_picking_ux/__manifest__.py | 7 +- .../data/stock_batch_picking_data.xml | 7 -- stock_batch_picking_ux/i18n/es.po | 2 +- stock_batch_picking_ux/i18n/es_CL.po | 2 +- .../models/stock_batch_picking.py | 68 ++----------------- .../models/stock_picking.py | 2 +- .../views/stock_batch_picking_views.xml | 46 ++++--------- .../views/stock_move_line_views.xml | 2 +- 8 files changed, 27 insertions(+), 109 deletions(-) delete mode 100644 stock_batch_picking_ux/data/stock_batch_picking_data.xml diff --git a/stock_batch_picking_ux/__manifest__.py b/stock_batch_picking_ux/__manifest__.py index 88079717..7c9d1a12 100644 --- a/stock_batch_picking_ux/__manifest__.py +++ b/stock_batch_picking_ux/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'Stock Usability with Batch Picking and stock vouchers', - 'version': "15.0.1.0.0", + 'version': "16.0.1.0.0", 'category': 'Warehouse Management', 'sequence': 14, 'summary': '', @@ -31,10 +31,9 @@ 'depends': [ 'stock_ux', 'stock_voucher', - 'stock_picking_batch_extended', + 'stock_picking_batch', ], 'data': [ - 'data/stock_batch_picking_data.xml', 'views/stock_batch_picking_views.xml', 'views/stock_move_line_views.xml', 'views/stock_picking_views.xml', @@ -42,7 +41,7 @@ ], 'demo': [ ], - 'installable': False, + 'installable': True, 'auto_install': True, 'application': False, } diff --git a/stock_batch_picking_ux/data/stock_batch_picking_data.xml b/stock_batch_picking_ux/data/stock_batch_picking_data.xml deleted file mode 100644 index 1f3dc58c..00000000 --- a/stock_batch_picking_ux/data/stock_batch_picking_data.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/stock_batch_picking_ux/i18n/es.po b/stock_batch_picking_ux/i18n/es.po index 7ca67260..19ce6103 100644 --- a/stock_batch_picking_ux/i18n/es.po +++ b/stock_batch_picking_ux/i18n/es.po @@ -93,7 +93,7 @@ msgstr "El número de comprobante de albarán debe ser único por partner" #. module: stock_batch_picking_ux #: model_terms:ir.ui.view,arch_db:stock_batch_picking_ux.stock_batch_picking_form msgid "Process Operations" -msgstr "Operaciones del proceso" +msgstr "Procesar cantidades" #. module: stock_batch_picking_ux #: model:ir.model,name:stock_batch_picking_ux.model_stock_move_line diff --git a/stock_batch_picking_ux/i18n/es_CL.po b/stock_batch_picking_ux/i18n/es_CL.po index 68b3e8a3..19feeb75 100644 --- a/stock_batch_picking_ux/i18n/es_CL.po +++ b/stock_batch_picking_ux/i18n/es_CL.po @@ -88,7 +88,7 @@ msgstr "" #. module: stock_batch_picking_ux #: model_terms:ir.ui.view,arch_db:stock_batch_picking_ux.stock_batch_picking_form msgid "Process Operations" -msgstr "" +msgstr "Procesar cantidades" #. module: stock_batch_picking_ux #: model:ir.model,name:stock_batch_picking_ux.model_stock_move_line diff --git a/stock_batch_picking_ux/models/stock_batch_picking.py b/stock_batch_picking_ux/models/stock_batch_picking.py index 011b24c8..1da1a7c7 100644 --- a/stock_batch_picking_ux/models/stock_batch_picking.py +++ b/stock_batch_picking_ux/models/stock_batch_picking.py @@ -10,35 +10,7 @@ class StockPickingBatch(models.Model): _inherit = 'stock.picking.batch' - # operation_type = fields.Selection([ - # ('incoming', 'Suppliers'), - # ('outgoing', 'Customers'), - # ('internal', 'Internal')], - # 'Type of Operation', - # required=True, - # ) - # preferimos limitar por picking type para no confundir a los usuarios - # porque si no podrian imaginar que al seleccionar recepciones de distintos - # lugares van a estar recibiendo todo en una misma - picking_code = fields.Selection([ - ('incoming', 'Suppliers'), - ('outgoing', 'Customers'), - ('internal', 'Internal'), - ], - 'Type of Operation', - # related='picking_type_id.code', - # readonly=True, - required=True, - # el default sobre todo para que no necesitemos script de migracion - default='incoming', - states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, - ) - # picking_type_id = fields.Many2one( - # 'stock.picking.type', - # 'Picking Type', - # states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, - # required=True, - # ) + picking_type_code = fields.Selection(store=True) partner_id = fields.Many2one( 'res.partner', # por ahora lo hacemos requerido porque si no tenemos que hacer algun @@ -71,13 +43,6 @@ class StockPickingBatch(models.Model): related='picking_ids.vouchers', ) - # overwrite this because we need only takes the moves with are not cancel - @api.depends('picking_ids') - def _compute_move_lines(self): - for batch in self: - batch.move_lines = batch.picking_ids.mapped( - "move_lines").filtered(lambda x: x.state != 'cancel') - @api.depends('picking_ids') def _compute_picking_type_data(self): for rec in self: @@ -88,24 +53,12 @@ def _compute_picking_type_data(self): # este viene exigido desde la cia pero seguramente lo movamos a # exigir desde picking type # solo es requerido para outgoings - if rec.picking_code == 'outgoing': + if rec.picking_type_code == 'outgoing': rec.restrict_number_package = any( x.picking_type_id.restrict_number_package for x in rec.picking_ids) - # TODO deberiamos ver como hacer para aceptar multiples numeros de remitos - # si llega a ser necesario - # voucher_ids = fields.One2many( - # 'stock.picking.voucher', - # 'batch_picking_id', - # 'Vouchers', - # copy=False - # ) - # vouchers = fields.Char( - # compute='_compute_vouchers' - # ) - # @api.onchange('picking_type_id', 'partner_id') - @api.onchange('picking_code', 'partner_id') + @api.onchange('picking_type_code', 'partner_id') def changes_set_pickings(self): # if we change type or partner reset pickings self.picking_ids = False @@ -157,7 +110,7 @@ def action_transfer(self): rec.picking_ids.write({ 'number_of_packages': rec.number_of_packages}) - if rec.picking_code == 'incoming' and rec.voucher_number: + if rec.picking_type_code == 'incoming' and rec.voucher_number: for picking in rec.active_picking_ids: # agregamos esto para que no se asigne a los pickings # que no se van a recibir ya que todavia no se limpiaron @@ -170,7 +123,7 @@ def action_transfer(self): 'picking_id': picking.id, 'name': rec.voucher_number, }) - elif rec.picking_code != 'incoming': + elif rec.picking_type_code != 'incoming': # llamamos al chequeo de stock voucher ya que este metodo # termina usando do_transfer pero el chequeo se llama solo # con do_new_transfer @@ -192,14 +145,3 @@ def do_unreserve_picking(self): pickings_todo = self.mapped('picking_ids') self.write({'state': 'draft'}) pickings_todo.do_unreserve() - - def action_done(self): - # limpiamos todos los pickings que no tienen cantidades hechas en lo moves - for rec in self: - picking_without_qty_done = self.env['stock.picking'] - for picking in rec.picking_ids.filtered(lambda picking: picking.state not in ('cancel', 'done')): - if all([x.qty_done == 0.0 for x in picking.move_line_ids]): - # Check if we need to set some qty done. - picking_without_qty_done |= picking - rec.picking_ids -= picking_without_qty_done - return super(StockPickingBatch, self.with_context(picking_batches=self)).action_done() diff --git a/stock_batch_picking_ux/models/stock_picking.py b/stock_batch_picking_ux/models/stock_picking.py index a8270478..aeb49ca7 100644 --- a/stock_batch_picking_ux/models/stock_picking.py +++ b/stock_batch_picking_ux/models/stock_picking.py @@ -32,7 +32,7 @@ def force_transfer(self, force_qty=True): if force_qty: for pack in pick.move_line_ids: - pack.qty_done = pack.product_uom_qty + pack.qty_done = pack.reserved_uom_qty else: if all( float_is_zero( diff --git a/stock_batch_picking_ux/views/stock_batch_picking_views.xml b/stock_batch_picking_ux/views/stock_batch_picking_views.xml index 149d299f..6c4ada51 100644 --- a/stock_batch_picking_ux/views/stock_batch_picking_views.xml +++ b/stock_batch_picking_ux/views/stock_batch_picking_views.xml @@ -4,17 +4,15 @@ stock.picking.batch.form stock.picking.batch - + - + - - + - - + @@ -23,13 +21,11 @@ stock.picking.batch.form stock.picking.batch - + - - - + @@ -38,13 +34,13 @@ stock.picking.batch.form stock.picking.batch - + -