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

fields_view_get not being triggered

By
Vincent Gagnon-Coll
on 11/14/16, 11:40 AM 145 views

Can someone explain why fields_view_get is not being triggered ? Even in debug. I'm using v9

class AdjustmentLines(models.Model):
    
    _name = 'load.valuation.adjustment.lines'
    _description = 'Stock Valuation Adjustment Lines'
    name = fields.Char('Description', compute='_compute_name', store=True)
    cost_id = fields.Many2one('load.load', 'Landed Cost', ondelete='cascade', required=True)
    cost_line_id = fields.Many2one('load.landed.cost.lines', 'Cost Line', readonly=True)
    move_id = fields.Many2one('stock.move', 'Stock Move', readonly=True)
    product_id = fields.Many2one('product.product', 'Product', required=True)
    quantity = fields.Float('Quantity', default=1.0, digits=dp.get_precision('Product Unit of Measure'), required=True)
    weight = fields.Float('Weight', default=1.0, digits=dp.get_precision('Product Unit of Measure'))
    test = fields.Char(string='Test', default='aaa')
    volume = fields.Float('Volume', default=1.0, digits=dp.get_precision('Product Unit of Measure'))
    former_cost = fields.Float('Former Cost', digits=dp.get_precision('Product Price'))
    former_cost_per_unit = fields.Float('Former Cost(Per Unit)', compute='_compute_former_cost_per_unit', digits=0, store=True)
    additional_landed_cost = fields.Float('Additional Landed Cost', digits=dp.get_precision('Product Price'))
    final_cost = fields.Float('Final Cost', compute='_compute_final_cost', digits=0, store=True)
 
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        #override of fields_view_get in order to replace the name field to product template
        if context is None:
            context={}
            res = super(AdjustmentLines, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
       (...)

0
Vincent Gagnon-Coll
On 11/15/16, 1:11 PM

Finally the reason why it wasn't being displayed was that the field that I wanted to change was a Many2one and when I placed the code in the parent entity it worked.


<pre data-original-code="def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): #override of fields_view_get in order to replace the name field to product template if context is None: context={} res = super(AdjustmentLines, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) for node in doc.xpath(&quot;//label[@string='Test']&quot;): node.set('string','Salut') res['arch'] = etree.tostring(doc) return res " data-snippet-id="ext.d4721cecd57564839eec96a58e5383de" data-snippet-saved="false" data-codota-status="done">def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    #override of fields_view_get in order to replace the name field to product template
    if context is None:
        context={}
        res = super(AdjustmentLines, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
     
        doc = etree.XML(res['arch'])
        for node in doc.xpath("//label[@string='Test']"):
            node.set('string','Salut')
    
        res['arch'] = etree.tostring(doc)
        return res

1

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

Keyur
On 11/15/16, 12:30 AM

Hi Vincent,


fields_view_get method will be called when view of object load.valuation.adjustment.lines will be rendered on the screen

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: 11/14/16, 11:40 AM
Seen: 145 times
Last updated: 11/15/16, 3:43 PM