Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
10496 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

thank you for the reply


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

}

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 22
1604
0
thg 5 22
3295
0
thg 6 16
3117
0
thg 9 15
3045
2
thg 4 24
4198