Community mailing list archives

community@mail.odoo.com

Re: Edit Partners.is_company field in Point of Sale

by
LMS
- 02/01/2016 09:46:30
Hi Hardik,

Thanks a lot. I tested your suggestion and it worked.

I am having trouble with saving the value when you switch the Is_Company from checked to unchecked. It does not save the value. 

I am working with Odoo v9.

Here is how i add your suggestion in screens.js

        var fields = {};
        this.$('.client-details-contents .detail').each(function(idx,el){
            fields[el.name] = el.value;
            if(el.name=='is_company'){
            fields[el.name] = el.checked;
            }
        });


2016-01-31 13:37 GMT-05:00 Hardik Goswami <hardikgiri.goswami@gmail.com>:
Hi Luis,

Your code looks nice. But it should be something like this:

                    <div class='client-detail'>
                        <span class='label'>Company?</span>
                        <input class='detail is_company' name='is_company' type='checkbox' t-att-checked="partner.is_company ? 'checked' : undefined" />
                    </div><div class='client-detail'>
                        <span class='label'>Company?</span>
                        <input class='detail is_company' name='is_company' type='checkbox' t-att-checked="partner.is_company ? 'checked' : undefined" />
                    </div>

As you see you should use "t-att-checked" with the given value.
Next, It will not fine the value of partner.is_company as it is comes from the different js file. You need to edit models.js file line number 172.
At that line you need to add "is_company" field in the list at line number 172 (for v8). 

Above steps will fetch the value and display it to the screen, It cannot save the record, As it is check box and in javascript when get value of checkbox it will always gives us  "on" as a value. Below script will help you  to save the record too. Insert it in the screens.js file at line number 735.
                if(el.name=='is_company'){
                fields[el.name] = el.checked;
                }
it will be after "fields[el.name] = el.value;" this line.

Regards,
Hardikgiri Goswami
Skype : hardikgiri.goswami
 

On Sun, Jan 31, 2016 at 9:37 PM Luis Miguel Sarabia <luismiguel.sarabia@gmail.com> wrote:
Hi!

I am syncing the field partners.is_company to the point of sale

I have been able to show the value in the Customer List and also in the Customer Detail, but when I add the field to the CustomerEdit screen somehow is seems that is not connected to the field.

I am using the following

                    <div class='client-detail'>
                        <span class='label'>Company?</span>
                        <input class='detail client-is_company' type='checkbox' name='is_company'       t-att-value='partner.is_company' placeholder='Company?'></input>
                    </div>


Thanks for your help.

--
Luis Miguel Sarabia

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Luis Miguel Sarabia