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

INHERITANCE BY PROTOTYPE : FIELD NOT RECONGNIZED [SOLVED]

By
Yassine TEIMI
on 12/2/14, 10:16 AM 791 views

I'm working on stock.picking.out wich inherits by prototype from stock.picking, So , i want to add a field on stock.picking.out, the inheritance by prototype says that every field added on stock.picking.out is not recognized by views, and that's what hapenning with me I guess.

Because I added a field num_bl on stock.picking.out (By custom module), and I overwrite a method of stock.picking (force_assign), so I have now the following elements added to stock.picking.out, like this :

 class stock_picking_out(osv.osv):
    _name = "stock.picking.out"
    _inherit = "stock.picking"
    _table = "stock_picking"
    _description = "Delivery Orders"

  # Columns and other methods here #

    def force_assign(self, cr, uid, ids, *args):

        picking = self.browse(cr, uid, ids[0])
        num_bl = picking.num_bl
        if not num_bl:
            raise osv.except_osv(_('Attention !'), _('Numero BL est un champ obligatoire ! '))
        return super(stock_picking_out, self).force_assign(self, cr, uid, ids, *args)

 

When running the force_assign overriden method, it shows following error  Attribute error : Num_bl, it dosn't recognize the field num_bl, because of inheritance by prototype.

When I add the field num_bl manually ( direclty on source code without custom module) on stock_picking, it works, but it affects other databases, so I tried to add it on stock_picking with a custom module, but it shows only on the view_picking_form view, of stock_picking.

I am kind of confused, I'm looking for a solution that provides me adding the field on the stock_picking model (By custom module), exactly if I did it manually (direclty on the source code).

Any suggestions please ?

 

3

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 12/2/14, 10:36 AM

To add column in stock.picking.in and stock.picking.out, you need to add it in stock.picking as well.  Also, when you inherit stock.picking.out, you can just specify _inherit = "stock.picking.out" so that all stock.picking.out specific methods will still be accessible.

0
Takwa
On 6/2/15, 7:19 AM

hello,

I want inherit "prototype inheritance " a customer fracture view from accounting model to another custom module that i called test!but it doesn't work!!can anybody help me please!this is my code:

class test_test(models.Model):

_name = 'test.test'

_inherit = 'account.invoice'

de = fields.Text(string='Des', required=True)

and the xml :

<record id="invoice_tree" model="ir.ui.view"> 

<field name="name">module.name.account.invoice.tree</field> 

<field name="model">test.test</field> 

<field name="inherit_id" ref="account.invoice_tree" />

<field name="arch" type="xml"> 

<field name="state" position="after">

<field name="de" /> </field> </field> </record>

help please!!!

0
Yassine TEIMI
On 12/2/14, 10:52 AM

Thanks John, I just needed to add my field on stock_picking as well, while I was adding it for stock.picking.out, on my custom module. Thank you for your help I'll  mark it as solved so as to other people benefit from it.

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: 12/2/14, 10:16 AM
Seen: 791 times
Last updated: 6/2/15, 7:19 AM