Skip to Content
Menu
This question has been flagged
1 Odpoveď
16035 Zobrazenia

How can I group the view of an account by months and that within months are the accounts that I created. For example: In the month of August there is the account called bank and cash and the same with the month of September that has the cash and bank account since these accounts have had movement in those months.

link of the example to what I want to reach and how it is currently: \https://ibb.co/PCzj4ZQ

table view code:

    <record model="ir.ui.view" id="proyecto_rc.tree_account_list">  
    <field name="name">list de account</field>
    <field name="model">proyecto_rc.account</field>
    <field name="arch" type="xml">
        <tree>
          <field name="id"/>
          <field name="title"/>
          <field name="tipo_account"/>
       </tree>
    </field>
    </record>

    <record model="ir.ui.view" id="proyecto_rc.account_form">
            <field name="name">proyecto_rc</field>
            <field name="model">proyecto_rc.account</field>
            <field name="arch" type="xml">
                <form string="Accounts">
                    <sheet>
                        <group col="4">
                        <separator string="Registro de cuentas" colspan="4"/>
                            <field name="id"/>
                            <field name="title"/>
                            <field name="tipo_account"/>
                            <field name="total_account_debit"/>
                            <field name="total_account_credit"/>

                        </group>
                        <group>
                        <separator string="Document" colspan="4"/>
                        <field name="detail_document_ids" nolabel="1">
                        <tree string="Asiento" editable="false">
                            <field name="date"/>
                        </tree>
                        </field>
                        </group>
                    </sheet>
                </form>
            </field>
    </record>

    <!-- actions opening views on models -->
    <record model="ir.actions.act_window" id="proyecto_rc.account_action_window">
    <field name="name">Registro de cuenta</field>    
    <field name="res_model">proyecto_rc.account</field>
    <field name="view_mode">tree,form</field>
    </record>

    <!-- server action to the one above -->

    <record model="ir.actions.server" id="proyecto_rc.account_action_server">
    <field name="name"> cuenta server</field>
    <field name="model_id" ref="model_proyecto_rc_account"/>
    <field name="state">code</field>
    <field name="code">
        action = {
        "type": "ir.actions.act_window",
        "view_mode": "tree,form",
        "res_model": self._name,
        }
    </field>
    </record>

Avatar
Zrušiť
Best Answer

Define search view and define group by in it like

<record id="proyecto_rc.account_view_search" model="ir.ui.view">
<field name="name">proyecto_rc.account<.search</field>
<field name="model">proyecto_rc.account<</field>
<field name="arch" type="xml">
<field name="arch" type="xml">
<search string="String...">
    <field name="field_name"/>
    <group expand="1" string="Group By">
            <filter string="Month" name="month" help="help"  context="{'group_by':'field_name:month'}"/>
    </group>
</search>
</field>
</record>

Avatar
Zrušiť
Autor

<field name="name">proyecto_rc.account<.search</field>

<field name="model">proyecto_rc.account<</field> this have a error the code?

Autor

i have this code <record id="proyecto_rc.cuenta_view_search" model="ir.ui.view">

<field name="name">proyecto_rc.account.search </field>

<field name="model">proyecto_rc.account</field>

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

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

<search string="String...">

<field name="date"/>

<group expand="1" string="Group By">

<filter string="Month" name="month" help="help" context="{'group_by':'date:month'}"/>

</group>

</search>

</field>

</record>

but have a error : File "/mnt/c/odoo/customs2/proyecto_rc/views/account.xml", line 63

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: field line 54 and record, line 63, column 18 - - - (line 63= </record>

there is two/duplicate line <field name="arch" type="xml"> remove one

Autor

I run the code without any problem, but when I group it, only one month appears and two months should appear in the view because I have dates from November and December, do you know what I could have been wrong about? llok mi image: https://ibb.co/RpJYgH0

it's because there is no record for another month (create appropriate record/data)

Autor

the problem is that it only takes me the month with the IDs that first enter movement, for example: If for the first time I have a movement in the Bank account on 11/20/2019 it stays like November. Because I just created another account and I put it as the first movement on 12/20/2019 and it shows it to me in the view like December and the two previous ones that I had before are still in November. Do you know how I could solve that?

Related Posts Replies Zobrazenia Aktivita
3
feb 25
2512
0
máj 24
46
1
apr 24
2647
4
sep 23
4099
2
sep 23
6386