如何设置和获取stock.config.settings(TransientModel)中的many2one字段数据

时间:2017-08-23 08:01:28

标签: configuration settings stock

类StockConfigSettings(models.TransientModel):

_inherit = 'stock.config.settings'

incoming_picking_id = fields.Many2one('stock.picking.type', string="Incoming Inter Warehouse Picking")
outgoing_picking_id = fields.Many2one('stock.picking.type', string="Outgoing Inter Warehouse Picking")

@api.model
def get_default_incoming_picking(self, fields):
    conf = self.env['ir.config_parameter']
    return {
        'incoming_picking_id': int(conf.get_param('allowed_incoming_picking.incoming_picking_id')),
    }

@api.one
def set_incoming_picking(self):
    conf = self.env['ir.config_parameter']
    conf.set_param('allowed_incoming_picking.incoming_picking_id', str(self.incoming_picking_id.id))

@api.one
def set_outgoing_picking(self):
    conf = self.env['ir.config_parameter']
    conf.set_param('allowed_outgoing_picking.outgoing_picking_id', str(self.outgoing_picking_id))

@api.model
def get_default_outgoing_picking(self, fields):
    conf = self.env['ir.config_parameter']
    return {
        'outgoing_picking_id': int(conf.get_param('allowed_outgoing_picking.outgoing_picking_id')),
    }

我试过这段代码,但它不能为Many2one工作,请帮助我......

0 个答案:

没有答案