Skip to Content
Menu
This question has been flagged
3 Replies
13930 Views

Hello my project was working well a few hours ago, no errors and was printing my pdf correctly, but suddenly I get this error


You can find my module here: https://github.com/dan18fan/dan


thanks!

Avatar
Discard

Daniel, please provide the code here. that more essay for other developers. give more details for your module like odoo version, what change you made, etc.

Best Answer

HI Daniel Medina,
     i just check your code and it seem that there is no function print_work_order.

so you just write a function to print the report.

And one think i noticed that in the " orden_trabajo.py"

class reporte_ot_pdf(osv.AbstractModel):
_name = "report.orden_trabajo.orden_de_trabajo"
_inherit = "report.abstract_report"
_template = "orden_trabajo.orden_de_trabajo"
_wrapped_report_class = reporte_ot

try this code.
Thanks.

Avatar
Discard
Author Best Answer

HI Daniel Medina,
     i just check your code and it seem that there is no function print_work_order.

so you just write a function to print the report.

And one think i noticed that in the " orden_trabajo.py"

class reporte_ot_pdf(osv.AbstractModel):
_name = "report.orden_trabajo.orden_de_trabajo"
_inherit = "report.abstract_report"
_template = "orden_trabajo.orden_de_trabajo"
_wrapped_report_class = reporte_ot

try this code.
Thanks.


Hello, thanks for your help


I modifyied my orden_trabajo.py as you said nothing seemed to change drastically, the reason why there is no print_work_order function in my module it's because I added that function on the sale's module sale.py located in models folder, I just tried deleting that function from sale's .py file and added it to my module in the file button_model.py located in the models folder


Now I'm getting the following error:

AttributeError: type object 'sale.order' has no attribute 'print_work_order'

Not sure if its a inheritance issue :(

# -*- coding: utf-8 -*-
from odoo import models, api

class boton_orden_trabajo(models.Model):
_name = 'boton.ot'
_inherit = 'sale.order'

@api.multi
def print_work_order(self):
return self.env['report'].get_action(self, 'orden_trabajo.orden_de_trabajo')    

Avatar
Discard

you do one think, you just replace the by this.

class boton_orden_trabajo(models.Model):

_inherit = 'sale.order'

it will work fine.

Author

Not working..

AttributeError: type object 'sale.order' has no attribute 'print_work_order'

# -*- coding: utf-8 -*-

from odoo import models, api, _

class boton_orden_trabajo(models.Model):

_inherit = "sale.order"

@api.multi

def print_work_order(self):

return self.env['report'].get_action(self, 'orden_trabajo.orden_de_trabajo')

Author

Nevermind it works now, I had to restart the server :)

Related Posts Replies Views Activity
2
Jul 24
671
1
Nov 22
1306
1
Dec 19
2602
1
Apr 19
3662
2
Sep 18
2280