0

This is my Custom Module : enter image description here

When I Click on Create invoice button it shows wizard as shown below : enter image description here

But when I try to Create regular invoice it shows error :

enter image description here

I Changed the invoicing policy of product from "delivered quantities" to "ordered quantities" but still it throws same error.

xml code adding buttons :

          <header>
                <button name="action_draft" string="Draft" type="object" data-hotkey="r"/>
                <button name="action_in_progress" string="In Progress" type="object" data-hotkey="p"/>
                <button name="action_done" string="Done" type="object" states="in_progress"/>
                <button name="action_cancel" string="Cancel" type="object" data-hotkey="x"/>
                <field name="state" widget="statusbar" nolabel="1"/>
                <button name="331" string="Create Invoice" type="action" data-hotkey="x" states="done"/>
            </header>
  • Pl add your code. What does your Create Invoice button do ? – NinjaBat May 23 '22 at 08:41
  • @NinjaBat I have added the xml code in question and yes I simply added name of button as 331 because I have seen the same in sale order module. So to create invoice from my job card I did the same. – Dhiren Ahuja May 23 '22 at 10:01
  • 1
    You can't do that way. It will try to take value from sale.order because that's how the button function is. 1. Create your own button. 2. Pass necessary values(partner_id,product_id,..) and call create() function for 'account.move' – NinjaBat May 23 '22 at 10:20

1 Answers1

0

You need to create a python function that does it and then to call that function by naming a button as your function.

Odoo tutorial explaining how to proceed

Code example about how to create an account.move

Don't forget to add taxes if you need to.

Levizar
  • 75
  • 1
  • 8