İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

odoo 14 call action invoice sent from another model

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
invoiceactionsodoomodels.Model
3 Cevaplar
9133 Görünümler
Avatar
Joao Almeida

Right now I'm trying to call  programmatically, from  another  model,  the action 'action_invoice_sent'  that exists in the invoice details  page  as  a  button  called  'Send  &  Print'  (I'm not able to post images).

I call the action as a method: 'invoice_object.action_invoice_sent()' but nothing happens. Does anyone knows how to send invoices programmatically?

Thanks


1
Avatar
Vazgeç
Avatar
Mohamed Lamine Lalmi
En İyi Yanıt

Hello Joao,

The function action_invoice_sent  return  an  action  in  dictionary  format.  You have to return the result of this function to perform the action.

def  my_action(self):    
    action = invoice_object.action_invoice_sent()
    return  action

Otherwise, if you want to perform sending the Invoice directly (without opening the wizard), so you will have to create account.invoice.send object with the following context values:



def action_send_invoice_directly(self):
    # Search for your invoice_object
    invoice_object = ...

template = self.env.ref('account.email_template_edi_invoice', raise_if_not_found=False)
lang = False

if template:
lang = template._render_lang(invoice_object.ids)[invoice_object.id]

if not lang:
lang = get_lang(self.env).code

ctx = dict(
mark_invoice_as_sent=True,
active_ids=invoice_object.ids, # Use ids and not id (it has to be a list)
custom_layout="mail.mail_notification_paynow",
model_description=invoice_object.with_context(lang=lang).type_name,
force_email=True,
default_res_model='account.move',
default_use_template=bool(template),
)
values = {
'model': 'account.move',
'res_id': invoice_object.id,
'template_id': template and template.id or False,
'composition_mode': 'comment',
}

wizard = self.env['account.invoice.send'].with_context(ctx).create(values)
    wizard._compute_composition_mode()
wizard.onchange_template_id()
wizard.onchange_is_email()

    # If you want to send without printing the invoice use this function

    wizard._send_email()

# If you want to send and print use this function
    # wizard.send_and_print_action()

Hope my answer helps you.

4
Avatar
Vazgeç
Joao Almeida
Üretici

hi Mahamed,
in this case I want it to run without returning it, since it's an automated processing of invoices. Is this possible?

Mohamed Lamine Lalmi

Hey again,
Yes, It is possible but in a different way. In this cas you can't use the function action_invoice_sent because this function will not send the invoice, it will open the Wizard "account.invoice.send" then this wizard has it own function the send the invoice (_send_email). I'll update my response according to your needs.

Joao Almeida
Üretici

it makes sense. In that case, how can I send the invoice?

Mohamed Lamine Lalmi

Dear Joao,
I've updated my answer.
Good luck.

Joao Almeida
Üretici

wow, that is so great! looked all over the internet to find something like that. Than you so much.

One doubt: what is the "self.ids" in this line?
lang = template._render_lang(self.ids)[self.id]

Joao Almeida
Üretici

it's almost working. The invoice is marked as sent, but the email is not actually sent (it's not even on emails list that failed on odoo settings, so it's not an SMTP configuration problem)
I tried to look into the system's 'account.move.send' model and didn't find what could be the possible cause.

Joao Almeida
Üretici

found the solution, 3 methods must be called before send:

wizard = self.env['account.invoice.send'].with_context(ctx).create(values)

wizard._compute_composition_mode()
wizard.onchange_template_id()
wizard.onchange_is_email()

# If you want to send without printing the invoice use this function
wizard._send_email()

Joao Almeida
Üretici

now, the only thing that is not working is the invoice 'move_to_sent' is not set as true.

Mohamed Lamine Lalmi

Dear Joao,
for this line: lang = template._render_lang(self.ids)[self.id],
I did a mistake and i've updated the code.
_render_lang: Given some record ids, return the lang for each record based on lang field of template or through specific context-based key.
This line is added to ensure that the email will be sent in the correct language.

Mohamed Lamine Lalmi

Good catch Joao!

found the solution, 3 methods must be called before send:

wizard = self.env['account.invoice.send'].with_context(ctx).create(values)

wizard._compute_composition_mode()
wizard.onchange_template_id()
wizard.onchange_is_email()

Mohamed Lamine Lalmi

Dear Joao, could you please add a positif vote on my solution. :)

Joao Almeida
Üretici

added a positive vote :)

also could you change your post to reflect the corrections we discussed here? Just to help someone in the future that stumbles upon this post.

Also, in this line 'model_description=self.with_context(lang=lang).type_name,' self is actually invoice_object? At least I had to use it

Also, I had to create a composer instance:
composer = http.request.env['mail.compose.message'].create({
'composition_mode': 'comment'
})

then use it in the values:
values = {
'model': 'account.move',
'is_email': True,
'res_id': invoice_object.id,
'template_id': template and template.id or False,
'composition_mode': 'comment',
'composer_id': composer.id,
'invoice_ids': invoice_object.ids,
}

Mohamed Lamine Lalmi

Thank you for the positive vote :)
Yes, you were right, it should be invoice_object.
Updates are made on my response.
Thank you for your feedback, it was like a teamwork.

Joao Almeida
Üretici

Hi Mohamed

thank you so much for your help :) yes it felt like team work. With this, now anyone can implement the same

Gouranga Kala

Hi Mohammad,
The above code fits to my requirements, but the only problem is it is generating 2 emails.
1. from user to customer
2.from user to user itself (which is not required)
Can you please help me ?
I am using odoo 16 enterprise. Thanks in advance

Avatar
Răzvan Anastasescu
En İyi Yanıt

I think that using the wizard (which will generate some data in temp tables) and composer (which is not used anyway) it's a little bit too complex (and actually slower)

I'd use something like this:

def action_send_invoice(self):
# one 'account.move' object
invoice = self.env['account.move'].search([], limit=1)

template = self.env.ref('account.email_template_edi_invoice')

if not(invoice and template):
return False

res = template.send_mail(invoice.id, force_send=True, notif_layout='mail.mail_notification_paynow')

# or:
res = invoice.with_context(force_send=True).message_post_with_template(template.id, email_layout_xmlid='mail.mail_notification_paynow')

if res:
invoice.is_move_sent = True

return res

Attachments and partner language will be automatically taken care of, but you have to manually set the invoice as sent if success

1
Avatar
Vazgeç
Avatar
J. Blanco Caura
En İyi Yanıt

Excellent. I congratulate you, of someone out of shape trying to catch the thread of programming again

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Odoo - Return record lists on form view
actions odoo
Avatar
Avatar
Avatar
Avatar
3
Tem 24
6696
What are the value need to pass in field 'type' of account.invoice table in Odoo to get Customer_Invoice & Supplier_Invoice ?
invoice odoo
Avatar
Avatar
1
Eki 18
4791
Error Converting Sale Orders to Invoice
invoice odoo
Avatar
0
Eki 15
4204
How to remove product description from invoice lines?
invoice odoo v18
Avatar
Avatar
Avatar
2
Ağu 25
3083
Remove link from offer and invoice email Çözüldü
invoice emailtemplate odoo
Avatar
Avatar
Avatar
2
Kas 24
3883
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now