Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6677 มุมมอง

Hi there,

Is it possible to create an automation in Odoo 14 for create invoices after the quotation is confirmed in sales module?

Thank you

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

You can override the function of 'Confirm' button in sale order and create invoice from it.
See the below code.

class SaleOrder(models.Model):
    _inherit = 'sale.order'

    def action_confirm(self):
        res = super(SaleOrder, self).action_confirm()
        invoice_lines = []
        for line in self.order_line:
            vals = {
                'name': line.name,
                'price_unit': line.price_unit,
                'quantity': line.product_uom_qty,
                'product_id': line.product_id.id,
                'product_uom_id': line.product_uom.id,
                'tax_ids': [(6, 0, line.tax_id.ids)],
                'sale_line_ids': [(6, 0, [line.id])],
            }
            invoice_lines.append((0, 0, vals))
        self.env['account.move'].create({
            'ref': self.client_order_ref,
            'move_type': 'out_invoice',
            'invoice_origin': self.name,
            'invoice_user_id': self.user_id.id,
            'partner_id': self.partner_invoice_id.id,
            'currency_id': self.pricelist_id.currency_id.id,
            'invoice_line_ids': invoice_lines
        })
        return res

Regards

อวตาร
ละทิ้ง

thank you cybrosys!

คำตอบที่ดีที่สุด

Hi,

Use this free module as it is or you can refer the coding done inside the free module, which automatically create the picking and invoice on confirming the sales order.

Module: Sale Order Automation


Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 25
952
0
ต.ค. 24
1264
3
มี.ค. 16
4631
1
มี.ค. 25
1043
1
พ.ค. 24
1513