我有一个计算域人力资源工资单'模型。在
cumulative_income_tax_base_previous = fields.Float(string="Kümülatif
Gelir Vergisi Matrahı"
compute='_get_previous_payslip_fields',store=True)
我想根据同一模型中的另一个字段(类型是boolean)编辑此字段。在
^{pr2}$如果这个字段设置为true,我想编辑手工计算的字段。 在窗体视图中,我设置只读:真属性到我的计算领域。在
<xpath expr="//group[@name='accounting']" position="after">
<group name="other_calculation" string="Dİğer Hesaplamalar">
<field name="first_access"/>
<field name="cumulative_income_tax_base_previous"
attrs="{'readonly':[('first_access', '!=', True)],
'required': [('first_access', '=', True)]}"/>
</group>
</xpath>
我没有,但我在课堂上没有。当我手动编辑它时,它被指定为零。我怎样才能解决这个问题
@api.one
@api.depends('employee_id', 'date_from', 'date_to', 'first_access')
def _get_previous_payslip_fields(self):
for record in self:
if record.employee_id and record.date_from and record.date_to
and not record.line_ids:
.... (some codes)
payslip_object = self.env['hr.payslip'].search(domain,
order='id desc', limit=1)
if payslip_object and not record.first_access:
record.gv_rate_init_previous=payslip_object['gv_rate_init']
record.cumulative_income_tax_base_previous =
payslip_object['cumulative_income_tax_base']
else:
... ? ( When the first access field is set True)
您必须在Python字段声明中添加一个
inverse
参数,如:请参阅文档:https://www.odoo.com/documentation/11.0/reference/orm.html#computed-fields
只需在Python中添加xml force_save=“1”和store=True: 例如:
XML:
Python:
相关问题 更多 >
编程相关推荐