Skip to content

Commit

Permalink
Merge pull request #34 from milleniumkid/16.0-mig-split_stock_move_pi…
Browse files Browse the repository at this point in the history
…cking

[MIG] split_stock_move_picking
  • Loading branch information
yibudak authored Jan 17, 2025
2 parents 84743cb + 03a794f commit d3a3a5a
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
4 changes: 4 additions & 0 deletions split_stock_move_picking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Ismail Cagan Yilmaz (https://github.com/milleniumkid)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import wizard
20 changes: 20 additions & 0 deletions split_stock_move_picking/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Ismail Cagan Yilmaz (https://github.com/milleniumkid)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Split Stock Move Picking",
"summary": """
Splits stock.move record in pickings.
""",
"author": "yibudak, Altinkaya Enclosures",
"website": "https://github.com/altinkaya-opensource/odoo-addons",
"category": "Product",
"license": "LGPL-3",
"version": "16.0.1.0.0",
"depends": ["base", "stock"],
"data": [
"wizard/wizard_split_picking_line.xml",
"views/stock_picking_view.xml",
"security/ir.model.access.csv",
],
}
2 changes: 2 additions & 0 deletions split_stock_move_picking/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_split_stock_move_picking,access_split_stock_move_picking,model_split_stock_move_picking,base.group_user,1,1,1,1
20 changes: 20 additions & 0 deletions split_stock_move_picking/views/stock_picking_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" ?>
<odoo>

<record id="view_stock_split_picking_line" model="ir.ui.view">
<field name="name">Stock Split Picking Line</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<field name="product_uom" position="after">
<button
name="split_stock_move_picking.action_stock_split_picking_line"
states="draft,confirmed,assigned"
string="Böl"
type="action"
/>
</field>
</field>
</record>

</odoo>
4 changes: 4 additions & 0 deletions split_stock_move_picking/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Ismail Cagan Yilmaz (https://github.com/milleniumkid)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import split_stock_move_picking
43 changes: 43 additions & 0 deletions split_stock_move_picking/wizard/split_stock_move_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2025 Ismail Cagan Yilmaz (https://github.com/milleniumkid)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import _, api, fields, models
from odoo.exceptions import UserError


class SplitStockMovePicking(models.TransientModel):
_name = "split.stock.move.picking"
_description = "Splits stock.move in pickings"

move_id = fields.Many2one("stock.move", "Move", readonly=True)
product_id = fields.Many2one(
"product.product", string="Product", related="move_id.product_id", readonly=True
)
requested_qty = fields.Float(
"Talep Edilen", related="move_id.product_uom_qty", read_only=True
)
uom = fields.Many2one(
"uom.uom", string="UoM", related="move_id.product_uom", readonly=True
)
qty = fields.Float("Bölmek istediğiniz miktar")
after_split_qty = fields.Float("Bölünmeden sonra miktar", readonly=True)

def action_split(self):
for record in self:
if record.requested_qty - record.qty < 0.0:
raise UserError(
_("Bölmek istediğiniz miktar talep edilenden daha fazla.")
)

self.move_id._do_unreserve()
new_move = self.move_id.copy({"product_uom_qty": self.qty})
new_move._action_confirm(merge=False)
self.move_id.write({"product_uom_qty": self.move_id.product_uom_qty - self.qty})
self.move_id._action_confirm(merge=False)
self.move_id._action_assign()
new_move._action_assign()

@api.onchange("qty")
def calc_qty_after_split(self):
for move in self:
move.after_split_qty = move.requested_qty - move.qty
41 changes: 41 additions & 0 deletions split_stock_move_picking/wizard/wizard_split_picking_line.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_stock_split_picking_line_window" model="ir.ui.view">
<field name="model">split.stock.move.picking</field>
<field name="arch" type="xml">
<form>
<group>
<field name="move_id" invisible="1" />
<field name="product_id" />
<field name="requested_qty" />
<field name="uom" />
<field name="qty" class="oe_inline" />
<field name="after_split_qty" />

</group>
<footer>
<button
name="action_split"
class="btn btn-primary"
string="Böl"
type="object"
/>
or
<button special="cancel" class="btn btn-secondary" string="İptal" />
</footer>
</form>
</field>
</record>

<record id="action_stock_split_picking_line" model="ir.actions.act_window">
<field name="name">Satırı Böl</field>
<field name="res_model">split.stock.move.picking</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_stock_split_picking_line_window" />
<field name="target">new</field>
<field name="context">{'default_move_id': active_id}</field>
<field name="domain">[('move_id','=', active_id)]</field>
</record>

</odoo>

0 comments on commit d3a3a5a

Please sign in to comment.