Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I'm trying to put a new button on sales invoice which will print my customized version of invoice. So I've created new addon"my" and now need to connect this button click with function in "my" module. Can you please suggest, how can I refernce function in my model when hitting my new print button. The "print_invoice_my" refers to account.invoice model, while it should refernce to "my" model. Therefore I get an error when trying to run, it says it can not find "print_invoice_my" in account.invoice.Here is my xml:
<record id="invoice_form_my" model="ir.ui.view">
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<button type="object" name="print_invoice_my" string="my Invoice"/>
Much thanks, Arcull
Make sure you have the method or definition with this name print_invoice_my inside your account.invoice model,
When your button type="object" that means odoo framework will look for the method inside model provided on same view, with button name value.
Hope this might help
You've to define print_invoice_my python function in account.invoice model, because of name="print_invoice_my" the function with name print_invoice_my from the corresponding model (account.invoice in your case) is being called and as you have not defined it, you've got above error.
if you're interested in changing view of report itself, or add additional fields to it, then you should inherit or change the report view defined here: https://github.com/odoo/odoo/blob/dc48744bf7438761e1f25d411ec61755f74c60df/addons/account/views/report_invoice.xml#L4
for example, if you add new field in account.invoice, named my_field, then something like this should do the trick:
<template id="report_invoice_document" inherit_id="account.report_invoice_document">this way, "my_field" is added to the printed invoice.
<xpath expr="//div/div/div/address" position="after">
<span t-field="o.my_field" />
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 1/25/16, 1:33 AM|
|Seen: 889 times|
|Last updated: 4/8/16, 3:12 PM|