In Odoo, you can create an invoice automatically after a delivery transfer is done by creating a new module and overriding the _action_done method of the stock.picking model.
Here is an example of how you can create an invoice automatically after a delivery transfer is done:
Create a new module, for example stock_invoice_auto.
In the models folder of your module, create a new file called stock.py and add the following code:
Copy code
from odoo import api, fields, models
class StockPicking(models.Model):
_inherit = 'stock.picking'
def _action_done(self):
res = super(StockPicking, self)._action_done()
for picking in self:
if picking.picking_type_id.code == 'outgoing':
invoice_id = self.env['account.move'].create({
'type': 'out_invoice',
'partner_id': picking.partner_id.id,
'invoice_line_ids': [
(0, 0, {
'product_id': move.product_id.id,
'name': move.product_id.name,
'quantity': move.product_uom_qty,
'price_unit': move.product_id.lst_price,
'account_id': move.product_id.categ_id.property_account_income_categ_id.id,
})
for move in picking.move_lines
],
})
invoice_id.post()
return res
Add the dependencies in the manifest.py file of your module
Copy code
'depends': ['base','sale','stock'],
Update the module list and install the stock_invoice_auto module.
Once the installation is done, you can test it by creating a delivery order, and confirm it, you should see the invoice created automatically.
Please note that the above code is an example, you might need to adapt it to your specific requirements