Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1860 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jul 25
334
2
jul 25
524
1
jul 25
1572
3
abr 25
1649
3
abr 25
2656