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

I unable to change the properties of some fields from within fields_view_get method

By
Tarek Mohamed Ibrahim
on 8/5/15, 11:22 AM 966 views

I needed to change some attributes of the 'stock.move' popup screen that opened when one need to add a product in a delivery order screen, I added the following code


    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        if context is None:
            context = {}
        res = super(stock_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
        if context.get('picking_type') and context['picking_type']=='out':
            doc = etree.XML(res['arch'])
            domain ="[('use_type','=','finished')]"
            nodes = doc.xpath("//field[@name='product_id']")
            for node in nodes:
                node.set('domain', domain)
                node.set('string', 'Finished Product')
            nodes2 = doc.xpath("//field[@name='prodlot_id']")
            for node in nodes2:
                node.set('readonly',"1")
                node.set('invisible',"1")
                node.set('string',"1==================") res['arch'] = etree.tostring(doc)

The first nodes loop worked ok, the second one, nodes2, didn't work, i.e, the field still available and editable. I added the last line for test and for surprise it worked. Any idea is appreciated


try node.set('readonly', '1')

Solanki Shamji
on 8/5/15, 11:33 AM

No difference. Any more suggestions??

Tarek Mohamed Ibrahim
on 8/6/15, 4:25 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 8/6/15, 5:35 AM

Hi,

You can make apply any modifier as like below.


from openerp.osv.orm import setup_modifiers
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None:
context = {}
res = super(stock_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
if context.get('picking_type') and context['picking_type']=='out':
doc = etree.XML(res['arch'])
domain ="[('use_type','=','finished')]"
nodes = doc.xpath("//field[@name='product_id']")
for node in nodes:
node.set('domain', domain)
node.set('string', 'Finished Product')
setup_modifiers(node, res['fields']['product_id'])
nodes2 = doc.xpath("//field[@name='prodlot_id']")
for node in nodes2:
node.set('readonly',"1")
node.set('invisible',"1")
node.set('string',"1==================")
setup_modifiers(node, res['fields']['prodlot_id'])
res['arch'] = etree.tostring(doc)


I hope it will help you a lot.

Thanks.

Thank you 'Emipro' and thank to the site and the community that gave me this chance to get information by asking and receiving replies. You helped me before.

Tarek Mohamed Ibrahim
on 8/6/15, 7:51 AM

I tried your suggestion and it worked well. I now need to disable the 'split' button on the popup screen, I added this code nodes = doc.xpath("//button[@string='Split']") for node in nodes: node.set('readonly','1') I checked the 'res' dictionary to find how to apply this function and didn't get a clue, pls help me again. If this requires adding this in a new question pls post a comment to me to do so. Thx again

Tarek Mohamed Ibrahim
on 8/6/15, 7:51 AM

It is good that we can manage this as new question. Thanks.

Emipro Technologies Pvt. Ltd.
on 8/7/15, 5:53 AM

I posted the question https://www.odoo.com/nl_NL/forum/help-1/question/i-unable-to-change-the-readonly-proprety-of-a-button-from-within-fields-view-get-method-89309 pls check

Tarek Mohamed Ibrahim
on 8/8/15, 7:54 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: 8/5/15, 11:22 AM
Seen: 966 times
Last updated: 8/6/15, 7:37 AM