This question has been flagged
3 Replies
20587 Views

Hello,

I try to add a new editable column on tree view of payments in POS Orders to add the date of receipt of check method payments.

I already add the column, but I can't edit it.

This is my xml :

<record id="date_receipt_check" model="ir.ui.view">

<field name="name">pos.order.form.view.inherit</field>

<field name="model">pos.order</field>

<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"></field>

<field name="arch" type="xml">

<xpath expr="//tree" position="attributes">

<attribute name="editable">tpo</attribute>

</xpath>

<xpath expr="//field[@name='amount']" position="after">

<field name="date_receipt" readonly="False" />

</xpath>

</field>

</record>


Currently, when I click on the "date_receipt" field in tree, it opens a popup "Open: Payments" and therefore, I can not edit my date.

What I need to do to make it editable ?

Avatar
Discard

Seems like Typo/Spell mistake while making editable treeview .

<attribute name="editable">tpo</attribute>

It should be like <attribute name="editable">top</attribute>

Author

This is an error made when I created this post. My xml does not have this error.

Author Best Answer

I have resolved my problème.

First I have overrided field "statement_ids" to make readonly at false

class PosOrder(models.Model):

_inherit = 'pos.order'

# Override the statement_ids field to make readonly at false

    statement_ids = fields.One2many('account.bank.statement.line', 'pos_statement_id', string='Payments', readonly=False)

And in my view :

  1. I have disable creation and deletion to the treeview,

  2. Enable readonly for all fields of the treeview,

  3. And add my new field with readonly at "False".

<record id="receipt_checks_date" model="ir.ui.view">
      <field name="name">pos.order.form.view.inherit</field>
      <field name="model">pos.order</field>
      <field name="inherit_id" ref="point_of_sale.view_pos_pos_form"></field>
      <field name="arch" type="xml">        
        <!--Disable creation and deletion to the treeview of the statement ordres-->
        <xpath expr="//field[@name='statement_ids']/tree" position="attributes">
          <attribute name="create">false</attribute>
          <attribute name="delete">false</attribute>
        </xpath>        
        <!--Make all fields readonly except receipt_date-->
        <xpath expr="//field[@name='journal_id']" position="attributes">
          <attribute name="readonly">1</attribute>
        </xpath>
        <xpath expr="//field[@name='statement_id']" position="attributes">
          <attribute name="readonly">1</attribute>
        </xpath>
        <xpath expr="//field[@name='amount']" position="attributes">
          <attribute name="readonly">1</attribute>
        </xpath>        
        <!--Add column "Receipt date" in the treeview of payment lines-->
        <xpath expr="//field[@name='amount']" position="after">
          <field name="receipt_date" readonly="0" />
        </xpath>        
      </field>
 </record>

I don't no if it's the best solution, but it work.

Avatar
Discard