Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
10508 Представления

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?

Аватар
Отменить

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

Лучший ответ

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


Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Лучший ответ

thank you for the reply


Аватар
Отменить
Лучший ответ

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)]}),

}

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
июн. 22
1607
0
мая 22
3296
0
июн. 16
3121
0
сент. 15
3047
2
апр. 24
4203