subcontracting_inventory_mo.../views/stock_move_link_views.xml
2025-10-04 11:52:00 +07:00

45 lines
2.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Server action to link selected subcontracting move to purchase order -->
<record id="action_link_subcontracting_move_to_po" model="ir.actions.server">
<field name="name">Link to Purchase Order</field>
<field name="model_id" ref="stock.model_stock_move"/>
<field name="binding_model_id" ref="stock.model_stock_move"/>
<field name="state">code</field>
<field name="code">
if records:
# Get the active purchase order from context
po_id = env.context.get('default_purchase_order_id') or env.context.get('active_id')
if po_id:
po = env['purchase.order'].browse(po_id)
for record in records:
po.link_selected_subcontracting_move(record.id)
# Close the wizard window
action = {'type': 'ir.actions.act_window_close'}
</field>
</record>
<!-- Custom list view for linking subcontracting moves to purchase orders -->
<record id="view_stock_move_link_subcontracting_tree" model="ir.ui.view">
<field name="name">stock.move.link.subcontracting.tree</field>
<field name="model">stock.move</field>
<field name="arch" type="xml">
<list string="Subcontracting Moves to Link" create="false" edit="false" delete="false">
<header>
<button name="%(action_link_subcontracting_move_to_po)d"
type="action"
string="Link to Purchase Order"
class="btn-primary"
context="{'default_purchase_order_id': context.get('default_purchase_order_id')}"/>
</header>
<field name="name"/>
<field name="product_id"/>
<field name="product_uom_qty"/>
<field name="product_uom" groups="uom.group_uom"/>
<field name="state"/>
<field name="date"/>
<field name="location_dest_id"/>
</list>
</field>
</record>
</odoo>