Odoo在高级搜索,中隐藏字段
def fields_get(self, cr, uid, fields=None, context=None): fields_to_hide = ['period_id','audit','status','stock_move_lines'] res =super(HrpStockMove,self).fields_get(cr, uid, fields, context) for field in fields_to_hide: res[field]['selectable'] =False return res
Odoo新老写法转换,例1:
老写法
def move_quants_write(self, cr, uid, quants, move, location_dest_id, dest_package_id, context=None): context=context or {} vals = {'location_id': location_dest_id.id,'history_ids': [(4, move.id)],'reservation_id': False} if not context.get('entire_pack'): vals.update({'package_id': dest_package_id}) self.write(cr, SUPERUSER_ID, [q.id for q in quants], vals, context=context)
新写法
def move_quants_write(self,quants, move, location_dest_id, dest_package_id): context=self.env.context or {} vals = {'location_id': location_dest_id.id, 'history_ids': [(4, move.id)], 'reservation_id': False} if not context.get('entire_pack'): vals.update({'package_id': dest_package_id}) for quant in quants: quant.sudo().write(vals) if not(move.product_id.type == 'consu' and context.get('flag')): if move.product_id.valuation == 'real_time': self._account_entry_move(quants, move)