Skip to Content
Menu
This question has been flagged
2 Replies
1852 Views

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
Discard
Author Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
Jul 25
281
2
Jul 25
482
1
Jul 25
1532
3
Apr 25
1616
3
Apr 25
2588