Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odgovori
10487 Prikazi

I have tried to inherit purchase module and replace default picking_type_id to False. 

This is original module :

_defaults = {
        'date_order': fields.datetime.now,
        'state': 'draft',
        'name': lambda obj, cr, uid, context: '/',
        'shipped': 0,
        'invoice_method': 'order',
        'invoiced': 0,
        'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id,
        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c),
        'journal_id': _get_journal,
        'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id,
        'picking_type_id': _get_picking_in,
    }

And I change to : 

_defaults = {
                 'name': '/',
                 'picking_type_id': False,
                 'salesman_id': lambda obj, cr, uid, context:uid,
                 'partner_ref': 'try'
                 }

But the default of picking_type_id (just picking_type_id) still get default from original module. How to change it?

Avatar
Opusti

What is the definition of the field in your module? Module starts?

Best Answer

Hi,

you can override default_get function in your class sale_order like this :


def default_get(self, cr, uid, fields, context=None):

     context = context or {}

     res = super(sale_order, self).default_get(cr, uid, fields, context=context)

     if 'name' in fields:

         res.update({'name': '/'})

     if 'salesman_id' in fields:

         res.update({'salesman_id': uid})

     if 'picking_type_id' in fields:

         res.update({'picking_type_id': False})

     if 'partner_ref' in fields:

         res.update({'partner_ref': 'try'})

    return res

bye


Avatar
Opusti
Best Answer

Hi , i want to override this value to be not required ,,but even if i put required= False it's still the same

Avatar
Opusti
Best Answer

thank you for the reply


Avatar
Opusti
Best Answer

you must rewrite the code like this in your new module

_columns = {

    'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming       shipment", required=True,

states={'confirmed': [('readonly', True)], 'approved': [('readonly', True)], 'done': [('readonly', True)]}),

}

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
jun. 22
1603
0
maj 22
3293
0
jun. 16
3115
0
sep. 15
3045
2
apr. 24
4194