İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
1862 Görünümler

Hi Odooers,

my first question here - sorry if missed the answer here in forum, but did'nt find it.


How can one new odooer find the right syntax?

Want to modify the invoices a little bit, our account has mentioned to write a sentence to the invoices if customer from EU orders from us (we are located in germany) and the customer has an VAT-Number.

What i have found so fare - adding Text to Invoices is easy by inheriting the views for invoices, but i miss the right point to check if the country of the custumer is inside europe.

Can anybody point me to the right direction what is the correct field to show a special Sentence only if the customer is ordering from inside europe?


Thanks for all of your hints.

Kind regards peter

Avatar
Vazgeç
Üretici En İyi Yanıt

thx for the tip.

Hope someone could use it. We have stopped to evaluate of odoo - for us the shop Feature was most important.

al the best

Peter

Avatar
Vazgeç
En İyi Yanıt

Hi,
You can add a condition in the XML by inheriting the invoice template, which means you can get the customer details inside that template, To check that condition you need to add a field inside res.partner model, which indicates that the customer is from Eu country or not, you can refer to the following code for your clarification:

.py;
from odoo import models, fields

class ResPartner(models.Model):
    _inherit = 'res.partner'

    is_eu_country = fields.Boolean("Is EU Country", compute='_compute_is_eu_country')

    def _compute_is_eu_country(self):
        eu_country_codes = ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE']
        for partner in self:
            partner.is_eu_country = partner.country_id.code in eu_country_codes

XML:

<t t-if="o.partner_id.is_eu_country">
    <p>This is an invoice for a customer from the European Union.</p>
</t>


Hope it helps

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 25
346
2
Tem 25
533
1
Tem 25
1585
3
Nis 25
1658
3
Nis 25
2659