Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
4 Besvarelser
10497 Visninger

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
Kassér

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

Bedste svar

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
Kassér
Bedste svar

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

Avatar
Kassér
Bedste svar

thank you for the reply


Avatar
Kassér
Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
0
jun. 22
1604
0
maj 22
3295
0
jun. 16
3117
0
sep. 15
3045
2
apr. 24
4198