Skip to content

Commit

Permalink
[REF] repair_picking_after_done: adding repair_stock as dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJForgeFlow committed Aug 29, 2024
1 parent 3a32b8c commit 66e520e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
4 changes: 2 additions & 2 deletions repair_picking_after_done/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

{
"name": "Repair picking after done",
"version": "16.0.1.0.1",
"version": "16.0.1.0.2",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/repair",
"summary": "Transfer repaired move to another location directly from repaire order",
"category": "Repair",
"depends": ["repair_type"],
"depends": ["repair_type", "repair_stock"],
"data": [
"security/ir.model.access.csv",
"views/repair.xml",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


def migrate(env, version):
repairs = env["repair.order"].search([])
for repair in repairs:
repair.picking_ids.move_ids.write({"repair_id": repair.id})
17 changes: 1 addition & 16 deletions repair_picking_after_done/models/repair.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Copyright (C) 2022 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from odoo import _, fields, models
from odoo import fields, models


class Repair(models.Model):
_inherit = "repair.order"

picking_ids = fields.Many2many("stock.picking", string="Transfers", copy=False)
remaining_quantity = fields.Float(
"Remaining quantity to be transferred", compute="_compute_remaining_quantity"
)
Expand Down Expand Up @@ -38,17 +37,3 @@ def action_transfer_done_moves(self):
},
"target": "new",
}

def action_open_transfers(self):
self.ensure_one()
domain = [("id", "in", self.picking_ids.ids)]
action = {
"name": _("Transfers"),
"view_type": "tree",
"view_mode": "list,form",
"res_model": "stock.picking",
"type": "ir.actions.act_window",
"context": self.env.context,
"domain": domain,
}
return action
1 change: 0 additions & 1 deletion repair_picking_after_done/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down
16 changes: 1 addition & 15 deletions repair_picking_after_done/views/repair.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,14 @@
<field name="inherit_id" ref="repair.view_repair_order_form" />
<field name="arch" type="xml">
<header position="inside">
<field name="remaining_quantity" invisible="1" />
<button
name="action_transfer_done_moves"
string="Create Transfer"
type="object"
attrs="{'invisible': ['|', ('state','!=', 'done'), ('remaining_quantity', '=', 0)]}"
/>
</header>
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<field name="remaining_quantity" invisible="1" />
<field name="picking_ids" invisible="1" />
<button
name="action_open_transfers"
type="object"
class="oe_stat_button"
icon="fa-truck"
attrs="{'invisible': [('picking_ids', '=', False)]}"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_text">Transfers</span>
</div>
</button>
</xpath>
</field>
</record>
</odoo>
3 changes: 2 additions & 1 deletion repair_picking_after_done/wizards/repair_move_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _prepare_stock_move_vals(self, picking):
"picking_type_id": self._get_picking_type().id,
"product_uom_qty": self.quantity,
"product_uom": self.repair_order_id.move_id.product_uom.id,
"repair_id": self.repair_order_id.id,
}

def action_create_transfer(self):
Expand All @@ -69,4 +70,4 @@ def action_create_transfer(self):
stock_move.move_line_ids[0].write(
{"lot_id": self.repair_order_id.lot_id.id}
)
self.repair_order_id.write({"picking_ids": [(4, picking.id)]})
self.repair_order_id._compute_picking_ids()

0 comments on commit 66e520e

Please sign in to comment.