#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Modifies all of the HR payslip format.""" import os import sys import odooly def use_local_resources(): """Facilita usar recursos en el mismo directorio del script.""" global __location__ __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) def main(): odooly.Client._config_file = os.path.expanduser('~/.config/odooly.ini') odoo = odooly.Client.from_config('Odoo14_Production') views = odoo.env['ir.ui.view'] reports = odoo.env['ir.actions.report'] papers = odoo.env['report.paperformat'] baseid = 'hr_avancys.print_report_payslip' qweb = open(os.path.join(__location__, 'agofer_payslip.xml')).read() viewextid = 'agofer_view.override_payslip' viewname = 'override_payslip' viewarch = """ {2} """.format(viewname, baseid, qweb) repextid = 'hr_avancys.action_print_report_payslip' papextid = 'agofer_paper.factura_carta' base_view = views.get(baseid) assert base_view.name == 'print_report_payslip' viewvalues = { 'arch': viewarch, 'active': True, 'mode': 'extension', 'inherit_id': base_view.id, 'name': viewname, 'priority': 16, 'type': 'qweb', 'model': False, } repvalues = { 'name': 'Comprobante de nĂ³mina', 'report_type': 'qweb-pdf', 'multi': False, 'attachment_use': False, 'attachment': False, 'paperformat_id': papers.get(papextid).id, } try: reports.get(repextid).write(repvalues) newview = views.get(viewextid) if newview: newview.write(viewvalues) else: newview = views.create(viewvalues) newview._set_external_id(viewextid) except: xt, xc, tb = sys.exc_info() xm = ''.join(odooly.format_exception(xt, xc, tb, chain=False)) print('### Error\n' + xm.strip()) if __name__ == "__main__": use_local_resources() main()