This question has been flagged
2 Replies
8368 Views

Hello I'm getting the following error while trying to inherit sale.order form in my own module, I want to add a button in the sale.order form next to the print button which says "Orden de Trabajo" or "Work Order" this one generates a PDF with the following variables.. number of order, customer, product, quantity, the code is made, just don't know how to inherit correctly to add this button to the sale.order form


ParseError: "Error mientras se validavan las restricciones

El elemento '<xpath expr="//header[@name='print_quotation']">' no puede ser localizado en la vista padre

Error de contexto:
Vista `sale.order.form.inherit`
[view_id: 3446, xml_id: n/a, model: sale.order, parent_id: 547]
None" while parsing file:///c:/odoo 10.0e/server/odoo/custom_addons/orden_trabajo/views/boton_ot.xml:4, near
<record id="view_order_form_inherit" model="ir.ui.view">
        <field name="name">sale.order.form.inherit</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
	    <field name="arch" type="xml">
	<!--The action -->
        <xpath expr="//header[@name='print_quotation']" position="after">
                <button string="Orden de Trabajo" type="object" name="print_work_order"/>
        </xpath>
     </field>
    </record>
Avatar
Discard
Author Best Answer

You're right, now I see my button but when I click it I see this... :(


Odoo Server Error
Traceback (most recent call last):
File "C:\Odoo 10.0e\server\odoo\http.py", line 640, in _handle_exception
File "C:\Odoo 10.0e\server\odoo\http.py", line 677, in dispatch
File "C:\Odoo 10.0e\server\odoo\http.py", line 333, in _call_function
File "C:\Odoo 10.0e\server\odoo\service\model.py", line 101, in wrapper
File "C:\Odoo 10.0e\server\odoo\http.py", line 326, in checked_call
File "C:\Odoo 10.0e\server\odoo\http.py", line 935, in __call__
File "C:\Odoo 10.0e\server\odoo\http.py", line 506, in response_wrap
File "C:\Odoo 10.0e\server\odoo\addons\web\controllers\main.py", line 889, in call_button
File "C:\Odoo 10.0e\server\odoo\addons\web\controllers\main.py", line 877, in _call_kw
File "C:\Odoo 10.0e\server\odoo\api.py", line 677, in call_kw

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


Here is my module, I probably have a lot of mistakes, sorry but I'm new around here and I really want to be able to develop in odoo


https://github.com/dan18fan/dan




edit: Solved it, now I can print my work order, everything is working as intended, thanks for the help :)

Avatar
Discard
Best Answer

Hii,
You need to change xpath 

Try like this ,

<xpath expr="//header/button[@name='print_quotation']" position="after">
     <button string="Orden de Trabajo" type="object" name="print_work_order"/>
</xpath>

Correct me,If I am wrong
Thank you

Avatar
Discard