76 lines
3.6 KiB
XML
76 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- Inherit the purchase order form view to add smart button and subcontracting moves section -->
|
|
<record id="view_purchase_order_form_inherit_subcontracting_inventory_move_first" model="ir.ui.view">
|
|
<field name="name">purchase.order.form.inherit.subcontracting.inventory.move.first</field>
|
|
<field name="model">purchase.order</field>
|
|
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
|
<field name="arch" type="xml">
|
|
<xpath expr="//div[@name='button_box']" position="inside">
|
|
<!-- Smart button to view linked subcontracting moves -->
|
|
<button name="action_view_subcontracting_moves"
|
|
type="object"
|
|
class="oe_stat_button"
|
|
icon="fa-truck"
|
|
invisible="subcontracting_move_count == 0">
|
|
<field name="subcontracting_move_count" widget="statinfo" string="Subcontracting Moves"/>
|
|
</button>
|
|
|
|
<!-- Button to link existing subcontracting moves -->
|
|
<button name="action_link_subcontracting_moves"
|
|
type="object"
|
|
class="oe_stat_button"
|
|
icon="fa-link"
|
|
invisible="state not in ['draft', 'sent', 'to approve']">
|
|
<div>Link Subcontracting Moves</div>
|
|
</button>
|
|
</xpath>
|
|
|
|
<!-- Add subcontracting moves section in the form body -->
|
|
<xpath expr="//notebook" position="inside">
|
|
<page string="Subcontracting Moves"
|
|
invisible="subcontracting_move_count == 0">
|
|
<field name="subcontracting_move_ids"
|
|
nolabel="1"
|
|
readonly="1"/>
|
|
</page>
|
|
</xpath>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Add menu item for viewing subcontracting inventory moves -->
|
|
<record id="action_subcontracting_moves_tree" model="ir.actions.act_window">
|
|
<field name="name">Subcontracting Inventory Moves</field>
|
|
<field name="type">ir.actions.act_window</field>
|
|
<field name="res_model">stock.move</field>
|
|
<field name="view_mode">list,form</field>
|
|
<field name="domain">[('location_dest_id.name', '=', 'Subcontracting Location')]</field>
|
|
<field name="context">{'search_default_location_dest_id_name': 'Subcontracting Location'}</field>
|
|
</record>
|
|
|
|
<!-- Add menu item to the Purchase menu -->
|
|
<menuitem id="menu_subcontracting_moves"
|
|
name="Subcontracting Moves"
|
|
action="action_subcontracting_moves_tree"
|
|
parent="purchase.menu_purchase_root"
|
|
sequence="15"/>
|
|
|
|
<!-- 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>
|
|
</odoo> |