Skip to Content
Menu
This question has been flagged
3 Replies
3306 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 ?

 

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

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!!!

Avatar
Discard
Author Best Answer

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.

Avatar
Discard