Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Form with tree inside. Problem with function fields.

By
Pau Ubach
on 10/1/14, 11:38 PM 1,090 views

I have a form A with a tree inside. When I click on "Add an item" I got a form B, where I can enter some information. Some of the fields in B are function and are calculated. 

When I create new item, everything is OK, functional fields are correctly updated.

But when I edit and change some values, when I save, the form B closes and the functional fields aren't updated on the tree in A form. 

If I click on the tree item to edit it, the fields in form B, also have the old values like the tree.

 

<record id="quotation_form" model="ir.ui.view">
            <field name="name">bdt.quotation.form</field>
            <field name="model">bdt.quotation</field>
            <field name="arch" type="xml">
                <form string="Quotation" version="7.0">
                    <header>
                        <div>
                            <button name="action_button_quot_to_customer" states="0" string="Send to Customer" class="oe_highlight" type="object"/>
                            <button name="action_button_quot_to_draft" states="1" string="Review" type="object"/> 
                            <button name="action_button_quot_won" states="1" string="Accepted" class="oe_highlight" type="object"/>
                            <button name="action_button_quot_lost" states="1" string="Rejected" class="oe_highlight" type="object"/> 
                            <field name="state" widget="statusbar"/>
                        </div>  
                    </header>
                    <sheet>
                        <!-- h1>
                            <label string="Customer "/>
                            <field name="cus_id"/>
                        </h1>
                        <h2>
                            <label string="Project "/>
                            <field name="pr_id" class="oe_inline"/>
                        </h2-->
                        <h2>
                            <label string="Quotation Name "/>
                            <field name="name" class="oe_inline"/>
                        </h2>
                        <group>
                            <group>
                                <field name="status_cust_reason"/>
                            </group>
                            <group>
                                <!-- field name="create_date"/-->
                            </group>
                        </group>
                        <notebook>
                            <page string="Forms">
                                <field name="q_form">
                                    <form string="Quotation Forms" version="7.0">
                                        <header>
                                            <div>
                                                <button name="action_button_form_to_review" states="0" string="Send for Revision" class="oe_highlight" type="object"/>
                                                <button name="action_button_form_approve" states="1" string="Approve" class="oe_highlight" type="object"/> 
                                                <button name="action_button_form_reject" states="1" string="Reject" class="oe_highlight" type="object"/>
                                                <button name="action_button_form_to_review" states="3" string="Send for Revision again" class="oe_highlight" type="object"/> 
                                                <button name="action_button_form_cancel" states="3" string="Cancel" class="oe_highlight" type="object"/> 
                                                <field name="state" widget="statusbar" statusbar_colors='{"4":"red","3":"orange","2":"green"}'/>
                                            </div> 
                                        </header>
                                        <h2>
                                            <label string="Quotation Form Name "/>
                                            <field name="name" class="oe_inline"/>
                                        </h2>
                                        <group>
                                            <group>
                                                <field name="amount" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="speed" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="hard" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="setup_price" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="price_min" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="profit_rate" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />
                                                <field name="sales_com" on_change="on_change_quot_field_data(amount,speed,hard,setup_price,price_min,profit_rate,sales_com)" />                                        
                                            </group>
                                            <group>
                                                <field name="calc_speed"/>
                                                <field name="calc_cost"/>
                                                <field name="calc_profit"/>
                                                <field name="calc_salescom"/>
                                                <field name="calc_price"/>
                                                <field name="calc_revenue"/>
                                            </group>
                                        </group>
                                    </form>
                                    <tree string="Sales Order Lines">
                                        <field name="amount" style="align:left"/>
                                        <field name="calc_speed" style="align:left"/>
                                        <field name="calc_cost"/>
                                        <field name="calc_profit"/>
                                        <field name="calc_salescom"/>
                                        <field name="calc_price"/>
                                        <field name="calc_revenue"/>
                                        <field name="state"/>
                                    </tree>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 10/2/14, 5:39 AM

Might be very obvious, but did you also save form A? 

And if so: how did you make the tree view in form A? Perhaps you can post some code?

I have copied the view. Sorry, but I don't know how to copy code here in a better way to make it easier to read.

Pau Ubach
on 10/2/14, 5:48 AM

That was my first thought too: You have to save the most outer object (in your case Form A)!

René Schuster
on 10/2/14, 5:49 AM

Thanks. Yes, I saved. Still same error.

Pau Ubach
on 10/2/14, 5:54 AM

I can't see anything particularly wrong with that at first glance. Perhaps you can take a working example from an existing object that actually works (invoices come into mind) and base your view on that? Have you checked to see if the data on the database DOES change? What happens when you trigger an on_change on form B?

Ludo - Neobis
on 10/2/14, 8:11 AM

For me, invoices has the same error. When I update quantity or price, amount and total aren't recalculated until I save.

Pau Ubach
on 10/2/14, 9:23 PM

When I use an on_change function on form B, the information is updated in the form, but when I save, the functional fields aren't updated in the tree of form A. I need to save A, and then I can see the changes, but not before.

Pau Ubach
on 10/2/14, 9:25 PM

What you describe is the normal behaviour, Pau Ubach.

René Schuster
on 10/6/14, 2:43 AM

Yes, I know, as it is how it happens in invoices, but being the normal behavior doesn't mean it is right behavior. In order of usability and machine-people interaction, the normal behavior should be as I describe.

Pau Ubach
on 10/6/14, 2:53 AM

Yes, I know, as it is how it happens in invoices, but being the normal behavior doesn't mean it is right behavior. In order of usability and machine-people interaction, the normal behavior should be as I describe.

Pau Ubach
on 10/6/14, 2:53 AM

I'm afraid there is nothing more we can do. If you want to change this you will need to dig pretty deep into the OpenERP core. Good luck with that.

Ludo - Neobis
on 10/6/14, 4:48 AM

Yes. It will be hard and I don't have time now for it, so we will have to live with it. Thanks very much for your support.

Pau Ubach
on 10/6/14, 4:52 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/1/14, 11:38 PM
Seen: 1090 times
Last updated: 3/16/15, 8:10 AM