Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
8881 Zobrazení

I want to make the "Pricelist" and "Payment Term" readonly if pricelist and payment term is set for the customer in sale order form.

It should be done on onchange of the customer field how can I do this in odoo9?

Is it possible to call a function on readonly attribute like following?


field_name = fields.Many2one('related_model', 'label', readonly="function_name")


def function_name(self):

     if condition:

         return True

     else:

         return False


Avatar
Zrušit
Nejlepší odpověď

Hello Sebin Siby,

set attrs on pricelist like

attrs="{'readonly': [('partner_id.pricelist_id', '!=', False)]}

set attrs on payment term same as like pricelist field just change payment term field name.

Avatar
Zrušit
Autor

I tried it but it's not working. The states and readonly attribute are set for that field while defining it in .py file. The changes made for readonly attribute from xml is not getting reflected on that field.

Autor

Now I need to remove the states and readonly attribute from .py file and defining it in xml.

I tried redefining that field without these attributes but the attributes doesn't chages.

Did you update your module and refresh your web page after you made your changes? Because changes made in the xml are not automatically reflected on the database.

Related Posts Odpovědi Zobrazení Aktivita
3
pro 23
90681
3
zář 21
4917
1
zář 15
8823
4
dub 25
4739
3
čvc 23
5571