pos_edit_payment_method/views/pos_order_views.xml
2026-05-21 09:41:38 +07:00

60 lines
2.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_pos_pos_form_inherit_edit_payment" model="ir.ui.view">
<field name="name">pos.order.form.inherit.edit.payment</field>
<field name="model">pos.order</field>
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>
<field name="arch" type="xml">
<!-- Add is_payment_editable field so the view can evaluate its value -->
<xpath expr="//field[@name='partner_id']" position="after">
<field name="is_payment_editable" invisible="1"/>
</xpath>
<!-- Make payment_ids dynamically editable based on our computed field -->
<xpath expr="//field[@name='payment_ids']" position="attributes">
<attribute name="readonly">not is_payment_editable</attribute>
</xpath>
<!-- Inside the list view of payment_ids, make the sub-fields readonly as requested, except payment_method_id -->
<!-- Also set create="0" and delete="0" on list to prevent adding or deleting payments manually -->
<xpath expr="//field[@name='payment_ids']/list" position="attributes">
<attribute name="create">0</attribute>
<attribute name="delete">0</attribute>
<attribute name="editable">bottom</attribute>
</xpath>
<!-- Make date readonly -->
<xpath expr="//field[@name='payment_ids']/list/field[@name='payment_date']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
<!-- Make payment method editable -->
<xpath expr="//field[@name='payment_ids']/list/field[@name='payment_method_id']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
<!-- Make amount/nominal readonly -->
<xpath expr="//field[@name='payment_ids']/list/field[@name='amount']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
<!-- Make optional card and mode fields readonly -->
<xpath expr="//field[@name='payment_ids']/list/field[@name='payment_method_payment_mode']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
<xpath expr="//field[@name='payment_ids']/list/field[@name='card_no']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
<xpath expr="//field[@name='payment_ids']/list/field[@name='card_brand']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
<xpath expr="//field[@name='payment_ids']/list/field[@name='cardholder_name']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
</field>
</record>
</odoo>