跳至内容
菜单
此问题已终结
2 回复
1858 查看

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

形象
丢弃
编写者 最佳答案

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

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
1
7月 25
322
2
7月 25
512
1
7月 25
1557
3
4月 25
1642
3
4月 25
2626