From 8a9a3658c330cd4ebccf4219c34f6e0c11645b7c Mon Sep 17 00:00:00 2001 From: Iria Alonso Date: Fri, 21 Jun 2024 10:58:10 +0200 Subject: [PATCH] [IMP] stock_picking_batch_split: add split by product --- stock_picking_batch_split/__init__.py | 1 + stock_picking_batch_split/__manifest__.py | 4 +- stock_picking_batch_split/i18n/es.po | 83 +++++++++++++++++-- .../i18n/stock_picking_batch_split.pot | 71 +++++++++++++++- stock_picking_batch_split/models/__init__.py | 2 + .../models/product_product.py | 19 +++++ .../models/stock_move.py | 13 +-- .../models/stock_picking_batch.py | 22 +++++ .../security/ir.model.access.csv | 2 + .../views/stock_picking_batch_views.xml | 3 + stock_picking_batch_split/wizards/__init__.py | 1 + .../stock_picking_batch_split_views.xml | 23 +++++ .../stock_picking_batch_split_wizard.py | 27 ++++++ 13 files changed, 253 insertions(+), 18 deletions(-) create mode 100644 stock_picking_batch_split/models/product_product.py create mode 100644 stock_picking_batch_split/models/stock_picking_batch.py create mode 100644 stock_picking_batch_split/security/ir.model.access.csv create mode 100644 stock_picking_batch_split/wizards/__init__.py create mode 100644 stock_picking_batch_split/wizards/stock_picking_batch_split_views.xml create mode 100644 stock_picking_batch_split/wizards/stock_picking_batch_split_wizard.py diff --git a/stock_picking_batch_split/__init__.py b/stock_picking_batch_split/__init__.py index 0650744f..aee8895e 100644 --- a/stock_picking_batch_split/__init__.py +++ b/stock_picking_batch_split/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizards diff --git a/stock_picking_batch_split/__manifest__.py b/stock_picking_batch_split/__manifest__.py index 6cb9837e..ee2888a4 100644 --- a/stock_picking_batch_split/__manifest__.py +++ b/stock_picking_batch_split/__manifest__.py @@ -7,7 +7,7 @@ """, "author": "Solvos", "license": "AGPL-3", - "version": "14.0.1.0.0", + "version": "14.0.1.1.0", "category": "Stock", "website": "", "depends": [ @@ -15,8 +15,10 @@ "stock_split_picking", ], "data": [ + "security/ir.model.access.csv", "views/stock_picking_views.xml", "views/stock_picking_batch_views.xml", + "wizards/stock_picking_batch_split_views.xml", ], "installable": True, } diff --git a/stock_picking_batch_split/i18n/es.po b/stock_picking_batch_split/i18n/es.po index b991aa2f..79e2a7a1 100644 --- a/stock_picking_batch_split/i18n/es.po +++ b/stock_picking_batch_split/i18n/es.po @@ -6,39 +6,104 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-02 07:30+0000\n" -"PO-Revision-Date: 2024-05-02 09:32+0200\n" +"POT-Creation-Date: 2024-06-21 08:38+0000\n" +"PO-Revision-Date: 2024-06-21 08:38+0000\n" "Last-Translator: \n" "Language-Team: \n" -"Language: es_ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.0.1\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__batch_id +msgid "Batch" +msgstr "Agrupación" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__batch_product_ids +msgid "Batch Product" +msgstr "Produtos de la agrupación" + +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_stock_picking_batch +msgid "Batch Transfer" +msgstr "Grupo de albaranes" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__create_date +msgid "Created on" +msgstr "Creado en" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product__display_name #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move__display_name +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch__display_name +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__display_name msgid "Display Name" -msgstr "Nombre a mostrar" +msgstr "Nombre Mostrado" #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product__id #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move__id +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch__id +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__id msgid "ID" -msgstr "" +msgstr "Id." #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product____last_update #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move____last_update +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch____last_update +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard____last_update msgid "Last Modified on" +msgstr "Última Modificación en" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__write_uid +msgid "Last Updated by" +msgstr "Última modificación por" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__write_date +msgid "Last Updated on" msgstr "Última modificación en" +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_product_product +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__product_id +msgid "Product" +msgstr "Producto" + #. module: stock_picking_batch_split #: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_batch_picking_form +#: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_picking_batch_split_form #: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.vpicktree msgid "Split" msgstr "Dividir" +#. module: stock_picking_batch_split +#: code:addons/stock_picking_batch_split/models/stock_picking_batch.py:0 +#, python-format +msgid "Split Picking By Product" +msgstr "Dividir albarán por producto" + +#. module: stock_picking_batch_split +#: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_batch_picking_form +msgid "Split by product" +msgstr "Dividir por producto" + +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_stock_picking_batch_split_wizard +msgid "Split picking" +msgstr "Dividir albarán" + #. module: stock_picking_batch_split #: model:ir.model,name:stock_picking_batch_split.model_stock_move msgid "Stock Move" -msgstr "Movimiento de Inventario" +msgstr "Movimiento de Almacén" diff --git a/stock_picking_batch_split/i18n/stock_picking_batch_split.pot b/stock_picking_batch_split/i18n/stock_picking_batch_split.pot index 86e7ea50..be088cd6 100644 --- a/stock_picking_batch_split/i18n/stock_picking_batch_split.pot +++ b/stock_picking_batch_split/i18n/stock_picking_batch_split.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-02 07:30+0000\n" -"PO-Revision-Date: 2024-05-02 07:30+0000\n" +"POT-Creation-Date: 2024-06-21 08:38+0000\n" +"PO-Revision-Date: 2024-06-21 08:38+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,26 +16,93 @@ msgstr "" "Plural-Forms: \n" #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__batch_id +msgid "Batch" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__batch_product_ids +msgid "Batch Product" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_stock_picking_batch +msgid "Batch Transfer" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__create_date +msgid "Created on" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product__display_name #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move__display_name +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch__display_name +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__display_name msgid "Display Name" msgstr "" #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product__id #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move__id +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch__id +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__id msgid "ID" msgstr "" #. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_product_product____last_update #: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_move____last_update +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch____last_update +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard____last_update msgid "Last Modified on" msgstr "" +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_product_product +#: model:ir.model.fields,field_description:stock_picking_batch_split.field_stock_picking_batch_split_wizard__product_id +msgid "Product" +msgstr "" + #. module: stock_picking_batch_split #: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_batch_picking_form +#: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_picking_batch_split_form #: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.vpicktree msgid "Split" msgstr "" +#. module: stock_picking_batch_split +#: code:addons/stock_picking_batch_split/models/stock_picking_batch.py:0 +#, python-format +msgid "Split Picking By Product" +msgstr "" + +#. module: stock_picking_batch_split +#: model_terms:ir.ui.view,arch_db:stock_picking_batch_split.stock_batch_picking_form +msgid "Split by product" +msgstr "" + +#. module: stock_picking_batch_split +#: model:ir.model,name:stock_picking_batch_split.model_stock_picking_batch_split_wizard +msgid "Split picking" +msgstr "" + #. module: stock_picking_batch_split #: model:ir.model,name:stock_picking_batch_split.model_stock_move msgid "Stock Move" diff --git a/stock_picking_batch_split/models/__init__.py b/stock_picking_batch_split/models/__init__.py index 6bda2d24..37cebc73 100644 --- a/stock_picking_batch_split/models/__init__.py +++ b/stock_picking_batch_split/models/__init__.py @@ -1 +1,3 @@ from . import stock_move +from . import stock_picking_batch +from . import product_product diff --git a/stock_picking_batch_split/models/product_product.py b/stock_picking_batch_split/models/product_product.py new file mode 100644 index 00000000..3c08af96 --- /dev/null +++ b/stock_picking_batch_split/models/product_product.py @@ -0,0 +1,19 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3.0 (http://www.gnu.org/licenses/agpl-3.0.html) + +from odoo import models, api, _ + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + @api.model + def name_search(self, name="", args=None, operator="ilike", limit=100): + context = self.env.context + if context.get('stock_picking_batch_split', False): + product_batch_ids = self.env['stock.picking.batch'].browse(context.get('stock_picking_batch_split')).move_lines.mapped('product_id') + domain = args or [] + domain += ['&', ("name", operator, name), ('id', 'in', product_batch_ids.ids)] + return self.search(domain).name_get() + + return super().name_search(name=name, args=args, operator=operator, limit=limit) diff --git a/stock_picking_batch_split/models/stock_move.py b/stock_picking_batch_split/models/stock_move.py index 9579ce38..905fb7b9 100644 --- a/stock_picking_batch_split/models/stock_move.py +++ b/stock_picking_batch_split/models/stock_move.py @@ -8,9 +8,10 @@ class StockMove(models.Model): _inherit = "stock.move" def stock_move_split_picking(self): - wizard_id = self.env['stock.split.picking'].create({ - 'mode': 'selection', - 'picking_ids': [(4, self.picking_id.id)], - 'move_ids': [(4, self.id)] - }) - wizard_id.action_apply() + for record in self: + wizard_id = self.env['stock.split.picking'].create({ + 'mode': 'selection', + 'picking_ids': [(4, record.picking_id.id)], + 'move_ids': [(4, record.id)] + }) + wizard_id.action_apply() diff --git a/stock_picking_batch_split/models/stock_picking_batch.py b/stock_picking_batch_split/models/stock_picking_batch.py new file mode 100644 index 00000000..6a857239 --- /dev/null +++ b/stock_picking_batch_split/models/stock_picking_batch.py @@ -0,0 +1,22 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3.0 (http://www.gnu.org/licenses/agpl-3.0.html) + +from odoo import models, _ + + +class StockPickingBatch(models.Model): + _inherit="stock.picking.batch" + + def action_open_stock_picking_batch_split_wizard(self): + Wizard = self.env["stock.picking.batch.split.wizard"] + new = Wizard.create({ + 'batch_id': self.id + }) + return{ + "name": _("Split Picking By Product"), + 'view_mode': 'form', + "res_model": "stock.picking.batch.split.wizard", + "type":"ir.actions.act_window", + "target":"new", + "res_id":new.id, + } diff --git a/stock_picking_batch_split/security/ir.model.access.csv b/stock_picking_batch_split/security/ir.model.access.csv new file mode 100644 index 00000000..1735861e --- /dev/null +++ b/stock_picking_batch_split/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_stock_picking_batch_split_user","access.stock_picking_batch_split_user","stock_picking_batch_split.model_stock_picking_batch_split_wizard","stock.group_stock_user",1,1,1,1 diff --git a/stock_picking_batch_split/views/stock_picking_batch_views.xml b/stock_picking_batch_split/views/stock_picking_batch_views.xml index 54eba93f..50c78348 100644 --- a/stock_picking_batch_split/views/stock_picking_batch_views.xml +++ b/stock_picking_batch_split/views/stock_picking_batch_views.xml @@ -17,6 +17,9 @@ groups="stock.group_stock_user" type="object" /> + +