Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] stock_picking_batch_split: add split by product #132

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stock_picking_batch_split/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizards
4 changes: 3 additions & 1 deletion stock_picking_batch_split/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
""",
"author": "Solvos",
"license": "AGPL-3",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"category": "Stock",
"website": "",
"depends": [
"stock_picking_batch_extended",
"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,
}
83 changes: 74 additions & 9 deletions stock_picking_batch_split/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
71 changes: 69 additions & 2 deletions stock_picking_batch_split/i18n/stock_picking_batch_split.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions stock_picking_batch_split/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import stock_move
from . import stock_picking_batch
from . import product_product
19 changes: 19 additions & 0 deletions stock_picking_batch_split/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# 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)
13 changes: 7 additions & 6 deletions stock_picking_batch_split/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
22 changes: 22 additions & 0 deletions stock_picking_batch_split/models/stock_picking_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# 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,
}
2 changes: 2 additions & 0 deletions stock_picking_batch_split/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions stock_picking_batch_split/views/stock_picking_batch_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
groups="stock.group_stock_user"
type="object" />
</xpath>
<xpath expr="//field[@name='id']" position="before">
<button name="action_open_stock_picking_batch_split_wizard" class="btn-primary" type="object" string="Split by product"/>
</xpath>
</field>
</record>

Expand Down
1 change: 1 addition & 0 deletions stock_picking_batch_split/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking_batch_split_wizard
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="stock_picking_batch_split_form" model="ir.ui.view">
<field name="name">stock.picking.batch.split.wizard</field>
<field name="model">stock.picking.batch.split.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="batch_id" invisible="1" />
<field name="batch_product_ids" invisible="1" />
<field name="product_ids" domain="[('id', '=', batch_product_ids)]" context="{'stock_picking_batch_split': batch_id}" widget="many2many_tags"/>
</group>
</sheet>
<footer>
<button name="split" type="object" class="btn-primary" string="Split" />
</footer>
</form>
</field>
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# © 2024 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3.0 (http://www.gnu.org/licenses/agpl-3.0.html)

from odoo import models, fields

class StockPickingBatchSplit(models.TransientModel):
_name="stock.picking.batch.split.wizard"
_description="Split picking"

product_ids = fields.Many2many("product.product")
batch_id = fields.Many2one("stock.picking.batch")
batch_product_ids = fields.Many2many("product.product", compute="_compute_batch_product_ids")

def split(self):
ChristianSantamaria marked this conversation as resolved.
Show resolved Hide resolved
move_ids = self.batch_id.move_lines.filtered(lambda x: x.product_id in self.product_ids)
picking_ids = move_ids.mapped('picking_id')
for picking in picking_ids:
wizard_id = self.env['stock.split.picking'].create({
'mode': 'selection',
'picking_ids': [(4, picking.id)],
'move_ids': [(4, move.id) for move in move_ids.filtered(lambda x: x.picking_id == picking)]
})
wizard_id.action_apply()

def _compute_batch_product_ids(self):
for record in self:
record.batch_product_ids = record.batch_id.move_lines.mapped('product_id')