I try to migrate the module hr_payslip_ytd_amount to the new API, but I get a traceback with the error:
ParseError: "Invalid view definition
Error details:
Field `total_ytd` does not exist
Error context:
View `hr.payslip.form`
[view_id: 2915, xml_id: n/a, model: hr.payslip, parent_id: 1629]
None" while parsing /opt/odoo9/custom/addons/hr_payslip_ytd_amount/views/hr_payslip_view.xml:5, near
<record id="view_hr_payslip_form" model="ir.ui.view">
<field name="name">hr.payslip.form</field>
<field name="model">hr.payslip</field>
<field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']//field[@name='total']" position="after">
<field name="total_ytd"/>
</xpath>
</field>
</record>
I assume it is related to a invalid definition of the field "total_ytd". The corresponding code is the following (I did only replace "_columns" with "_fields"):
from openerp import fields, models, api
import openerp.addons.decimal_precision as dp
class hr_payslip_line(models.Model):
_inherit = 'hr.payslip.line'
_fields = {
'total_ytd': fields.float(
'Total Year-to-date',
digits_compute=dp.get_precision('Payroll'))
}
I can't find any help which is understandable for a python-newbie.
try this:
from openerp import fields, models, api
import openerp.addons.decimal_precision as dp
class hr_payslip_line(models.Model):
_inherit = 'hr.payslip.line'
total_ytd = fields.Float(string='Total Year-to-date', digits=dp.get_precision('Payroll'))
Unfortunately, this does not work. The field is not added to the model and therefore I get the same view error.