Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 单击后禁用按钮-奥多v8_Python_Xml_Python 2.7_Odoo 8_Odoo - Fatal编程技术网

Python 单击后禁用按钮-奥多v8

Python 单击后禁用按钮-奥多v8,python,xml,python-2.7,odoo-8,odoo,Python,Xml,Python 2.7,Odoo 8,Odoo,我有这个方法: @api.multi def account_move_sc5_10(self): #if record.state in ('awaitingraw'): for record in self: #if record.state in ('draft'): tempy = record.contract_worksheet.total_alles - record.contract_worksheet.total_totals

我有这个方法:

@api.multi
def account_move_sc5_10(self):
    #if record.state in ('awaitingraw'):
    for record in self:
        #if record.state in ('draft'):
        tempy = record.contract_worksheet.total_alles - record.contract_worksheet.total_totals
        acc_move = self.env['account.move'] 
        move_lines = [
            (0, 0, {
                'name': 'name', # a label so accountant can understand where this line come from
                'debit': tempy or 0.0, # amount of debit
                'credit': 0, # amount of credit
                'account_id': record.transporter.transp_transit.id, #account_id, # account 
                'date': fields.Date.today(), #date,
                'partner_id': record.transporter.id, # partner if there is one
                #'currency_id': currency_id or (account.currency_id.id or False),
            }),
            (0, 0, {
                'name': 'name',
                'debit': 0, 
                'credit': record.contract_worksheet.total_alles or 0.0,
                'account_id': record.transporter.transp_transit.id,
                #'analytic_account_id': context.get('analytic_id', False),
                'date': fields.Date.today(), #date,
                'partner_id': record.transporter.id,
                #'currency_id': currency_id or (account.currency_id.id or False),
            })
        ]

        journal_id = False
        if record.transporter.transp_transit:
            journals = self.env['account.journal'].search([
                ('default_debit_account_id', '=', record.transporter.transp_transit.id)
            ])
            if journals:
                journal_id = journals[0].id
                acc_move.create({
                #'period_id': period_id, #Fiscal period
                    'journal_id': journal_id, #self.aajournal.id, # journal ex: sale journal, cash journal, bank journal....
                    'date': fields.Date.today(),
                    'state': 'draft',
                    'line_id': move_lines, # this is one2many field to account.move.line
                })
我从视图中这样调用

我需要的是,一旦单击此按钮,它应该保持只读,我知道使用布尔值可以完成此操作,但使用此
account.move
方法,我对如何实现它有点困惑


有什么想法吗?

如果单击按钮后使按钮不可见对您来说是可以的,您可以这样做:

在模型中声明一个字段,其中按钮方法为:

button_clicked = fields.Boolean(
    string='Button clicked',
    default=False,
)
修改按钮调用的方法,只需添加此行:

@api.multi
def account_move_sc5_10(self):
    for record in self:
        record.write({
            'button_clicked': True,
        })
        ...
修改按钮所属模型的视图,以添加新字段和条件:

<field name="button_clicked" invisible="1"/>

<button string="Account Moves" name="account_move_sc5_10" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('state', 'not in', 'awaitingraw'), ('button_clicked', '=', True)]}"/>


请注意,我已经删除了
状态
参数,这是因为
属性
状态
不能一起使用(如果两者都使用,它们将不会起任何作用)。因此,如果没有,请将
state
字段添加到视图中。

无法使用
attrs
readonly
()禁用该按钮。如果你不介意的话,你可以在点击后不可见地做。如果你想让它可见但被禁用,这会有点棘手,因为你需要在你的模块中添加一个CSS类。。。要搜索一些示例,您知道一些吗?谢谢简单就是艺术。谢谢亲爱的