Skip to Content
Menu
This question has been flagged
2 Replies
8413 Views

I would like to modify Journal Entry Form, so the (un-added) fields at the item level can be put first at the header level. Once satisfied, I can put additional button (Insert) to insert that into the item level.

Basically I do not want to use the link "Add Item".

For example, added fields are: Partner, Account, Name, Debit/Credit indicator, Amount. Plus "Insert" button.

I've done inheritance to modify the Form view, add those fields.

Question: How to invoke the "Add Item" link, and pass those information to the item level?

Thanks in advance.

Avatar
Discard
Author Best Answer

Dear Mahmoud,

thanks for your response.

I'm very new to Odoo programming, so would like to confirm my understanding:

1. Requirement: Accounting | Journal Entries | Create

- I don't want to use the "Add in Item" link.

- but I will move the values of item entries from current fields at the header level, plus the new fields I'm adding below.

- The Save button still available, to save the whole journal entry.


2. Added 4 fields = DONE

class myJournalEntry(models.Model):
 _inherit = 'account.move'
 # ADD 4 new fields
x_myDescription = fields.Char('Description', required=True, default='Description here ...')
x_myDebitCredit = fields.Char('Debit/Kredit', required=True, default='D')
x_myPartner = fields.Many2one('res.partner', 'Customer')
x_myAccount = fields.Many2one('account.account', 'Account')

3. My view: 4 new fields + 1 button to move the values from header level to item level (while standard Save button is still available)

<?xml version="1.0"?>
    <openerp>
        <data>
            <record id="view_form_account_move_inherited" model="ir.ui.view">
                <field name="name">Account Move form – User extension</field>
                <field name="model">account.move</field>
                <field name="inherit_id" ref="account.view_move_form"/>
                <field name="arch" type="xml">
                    <group> <group name="group_l1">
                        <field name="x_myDescription" />
                        <field name="x_myDebitCredit" />
                        <field name="x_myPartner" />
                        <field name="x_myAccount" />
                    </group>
                    <group name="group_l2">
                        <!-- INSERT button = a method to insert the entry as items -->
                        <button name="do_insert_item" type="object" string="Insert Item" class="oe_highlight" />
                    </group>
                </group>
            </field>
        </record>
    </data>
</openerp>


4. How to make the "Insert" button move the values from header + new fields to the journal item section?

Note: it's NOT saving action using the Save button.

The "Insert" button is only moving the values.

After all is filled up, I still want to use the "Save" button to create the Journal Entry.


Appreciate your very help. :)

Avatar
Discard
Best Answer

First you can inherit line tree and use attribute no-create = True, After that make your insert button create record in 'account.move.line' model with move_id = id of account.move record, and the new record will appear automatically in view

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 24
424
2
Nov 24
761
3
Oct 23
13197
2
Feb 23
1229
1
Dec 22
1371