我有这个方法:
130
我从这个@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
})
我需要一旦点击这个按钮,它应该保持只读,我知道用布尔值可以完成,但是使用这个<button string="Account Moves" name="account_move_sc5_10" states="awaitingraw" type="object" class="oe_highlight"/>
方法,我对如何实现它感到困惑。
有什么想法吗?
答案 0 :(得分:2)
如果单击按钮后按钮不可见,则可以执行此操作:
在模型中声明按钮方法所在的字段:
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)]}"/>
请注意,我已删除了states
参数,因为 attrs
和states
无法一起使用(如果同时使用它们,它们将无能为力)。因此,如果您还没有state
字段,请添加if (ListGrid.CurrentRow.Cells[4].Value.ToString() == "Male")
{
frm.UMaleRadioBtn.Checked = true;
}
else
{
frm.UFemaleRadioBtn.Checked = true;
}
字段。