This question has been flagged

I am brand new to odoo!  On odoo 13 EE I am trying to create and confirm a vendor bill after importing a purchase order and the item receipts.  I can create an invoice directly, but haven't been able to link that to the PO/receipt?


Sadly under purchase.order the method action_create_invoice seems hidden from the API

PurchaseOrder = odoo.env["purchase.order"]
order_id = PurchaseOrder.create(po)
purchaseorder = PurchaseOrder.browse([order_id])
print("Before validating:", purchaseorder.name, purchaseorder.state) # draft
odoo.env.context[
'check_move_validity'] = True
purchaseorder.button_confirm()
purchaseorder = PurchaseOrder.browse([order_id])
picking_count = purchaseorder.picking_count
print("After Post:", purchaseorder.name, purchaseorder.state, "picking_count = ", purchaseorder.picking_count)
if picking_count == 0:
print("Nothing to receive. Straight to to Billing.") # ok so far
tryme = purchaseorder.action_view_invoice()

odoorpc.error.RPCError: type object 'purchase.order' has no attribute 'action_create_invoice'
SO I tried overriding/extending 
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
@api.model
def create_invoice(self, context=None):
# try 1 => odoorpc.error.RPCError: 'super' object has no attribute      # 'action_create_invoice'
rtn = super().action_create_invoice(self)

# try2 => odoorpc.error.RPCError: name 'action_create_invoice' is         # not defined
# rtn = action_create_invoice(self)

# try3 => Error %s 'super' object has no attribute '
       #         action_create_invoice'
# rtn = super(models.Model, self).action_create_invoice(self)
return rtn
I hope somebody can suggest a solution! Thank you.
Avatar
Discard