19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:21 +01:00
parent 7dc55599c6
commit 7f43bbbfcc
650 changed files with 45260 additions and 33436 deletions

View file

@ -1,7 +1,7 @@
# G.C.C. - Arabic/English Invoice
# Gulf Cooperation Council - Invoice
Arabic/English for GCC
Adds Arabic as a secondary language on your invoice, credit note, debit note, vendor bill, and refund bill
## Installation
@ -12,35 +12,14 @@ pip install odoo-bringout-oca-ocb-l10n_gcc_invoice
## Dependencies
This addon depends on:
- account
## Manifest Information
- **Name**: G.C.C. - Arabic/English Invoice
- **Version**: 1.0.0
- **Category**: Accounting/Localizations
- **License**: LGPL-3
- **Installable**: False
## Source
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `l10n_gcc_invoice`.
- Repository: https://github.com/OCA/OCB
- Branch: 19.0
- Path: addons/l10n_gcc_invoice
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md
This package preserves the original LGPL-3 license.

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import tests
def _l10n_gcc_invoice_post_init(env):
env['res.lang']._activate_and_install_lang('ar_001')

View file

@ -1,16 +1,21 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'G.C.C. - Arabic/English Invoice',
'version': '1.0.0',
'author': 'Odoo',
'name': 'Gulf Cooperation Council - Invoice',
'version': '1.0.1',
'category': 'Accounting/Localizations',
'description': """
Arabic/English for GCC
Adds Arabic as a secondary language on your invoice, credit note, debit note, vendor bill, and refund bill
""",
'author': 'Odoo S.A.',
'license': 'LGPL-3',
'depends': ['account'],
'post_init_hook': '_l10n_gcc_invoice_post_init',
'data': [
'views/report_invoice.xml',
'views/res_config_settings_views.xml',
],
"assets": {
"web.report_assets_common": [
"l10n_gcc_invoice/static/src/scss/styles.scss",
],
},
}

View file

@ -2,3 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_move
from . import product
from . import res_company
from . import res_config_settings

View file

@ -1,7 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, api
import logging
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
try:
from num2words import num2words
except ImportError:
_logger.warning("The num2words python library is not installed, amount-to-text features won't be fully available.")
num2words = None
class AccountMove(models.Model):
@ -11,18 +21,29 @@ class AccountMove(models.Model):
def _get_name_invoice_report(self):
self.ensure_one()
if self.company_id.country_id in self.env.ref('base.gulf_cooperation_council').country_ids:
return 'l10n_gcc_invoice.arabic_english_invoice'
if self.company_id.country_id and 'GCC' in self.company_id.country_id.country_group_codes:
return 'l10n_gcc_invoice.l10n_gcc_report_invoice_document'
return super()._get_name_invoice_report()
def _l10n_gcc_get_invoice_title(self):
"""To be overriden by inheriting modules implementing a custom invoice title"""
self.ensure_one()
return False
def _num2words(self, number, lang):
if num2words is None:
_logger.warning("The library 'num2words' is missing, cannot render textual amounts.")
return ""
return num2words(number, lang=lang).title()
def _load_narration_translation(self):
# Workaround to have the english/arabic version of the payment terms
# in the report
if not self:
return
gcc_countries = self.env.ref('base.gulf_cooperation_council').country_ids
moves_to_fix = self.env['account.move']
for move in self.filtered(lambda m: m.company_id.country_id in gcc_countries and m.is_sale_document(include_receipts=True) and m.narration):
for move in self.filtered(lambda m: m.narration and m.is_sale_document(include_receipts=True) and m.company_id.country_id and 'GCC' in m.company_id.country_id.country_group_codes):
lang = move.partner_id.lang or self.env.user.lang
if move.company_id.terms_type == 'html' or move.narration != move.company_id.with_context(lang=lang).invoice_terms:
continue
@ -49,12 +70,42 @@ class AccountMove(models.Model):
# Only update translations of real records
self.filtered('id')._load_narration_translation()
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
l10n_gcc_invoice_tax_amount = fields.Float(string='Tax Amount', compute='_compute_tax_amount', digits='Product Price')
l10n_gcc_invoice_tax_amount = fields.Float(string='Tax Amount', compute='_compute_tax_amount', min_display_digits='Product Price')
l10n_gcc_line_name = fields.Char(compute='_compute_l10n_gcc_line_name')
@api.depends('price_subtotal', 'price_total')
def _compute_tax_amount(self):
for record in self:
record.l10n_gcc_invoice_tax_amount = record.price_total - record.price_subtotal
@api.depends('name')
def _compute_l10n_gcc_line_name(self):
def lang_product_name(line, lang):
return line.with_context(lang=lang).product_id.display_name
for line in self:
if line.product_id and line.name in [lang_product_name(line, lang) for lang in ('ar_001', 'en_US')]:
line.l10n_gcc_line_name = lang_product_name(line, line.move_id.partner_id.lang)
else:
line.l10n_gcc_line_name = line.name
def _get_child_lines(self):
# EXTENDS account
self.ensure_one()
res = super()._get_child_lines()
for line in res:
line['l10n_gcc_invoice_tax_amount'] = line['price_total'] - line['price_subtotal']
return res
def _l10n_gcc_get_section_total(self):
section_lines = self._get_section_lines()
return sum(section_lines.mapped('price_total'))
def _l10n_gcc_get_section_tax_amount(self):
section_lines = self._get_section_lines()
return sum(section_lines.mapped('l10n_gcc_invoice_tax_amount'))

View file

@ -0,0 +1,24 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
from odoo import models
class ProductProduct(models.Model):
_inherit = 'product.product'
def _compute_display_name(self):
""" In a string consisting of space-delimited substrings, force a double-space between
substrings where (when looking right to left) the first substring ends with a numeral and
the second begins with an Arabic character.
"""
def repl(match_occurrence):
# group(1): (\d) == numeral
# group(3): ([\u0600-\u06FF]) == Arabic character
return f'{match_occurrence.group(1)} {match_occurrence.group(3)}'
super()._compute_display_name()
for product in self:
if product.display_name:
product.display_name = re.sub(r'(\d)(\s)([\u0600-\u06FF])', repl, product.display_name)

View file

@ -0,0 +1,13 @@
from odoo import api, fields, models
class ResCompany(models.Model):
_inherit = 'res.company'
l10n_gcc_dual_language_invoice = fields.Boolean(string="GCC Formatted Invoices")
l10n_gcc_country_is_gcc = fields.Boolean(compute='_compute_l10n_gcc_country_is_gcc')
@api.depends('partner_id.country_id.country_group_ids.code')
def _compute_l10n_gcc_country_is_gcc(self):
for record in self:
record.l10n_gcc_country_is_gcc = record.country_id and 'GCC' in record.country_id.country_group_codes

View file

@ -0,0 +1,8 @@
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
l10n_gcc_dual_language_invoice = fields.Boolean(related='company_id.l10n_gcc_dual_language_invoice', readonly=False)
l10n_gcc_country_is_gcc = fields.Boolean(related='company_id.l10n_gcc_country_is_gcc')

View file

@ -0,0 +1,3 @@
table[name="invoice_line_table"] th {
vertical-align: bottom;
}

View file

@ -1,556 +1,335 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_invoice" inherit_id="account.report_invoice">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_gcc_invoice.arabic_english_invoice'"
t-call="l10n_gcc_invoice.arabic_english_invoice" t-lang="lang"/>
</xpath>
</template>
<template id="report_invoice_with_payments" inherit_id="account.report_invoice_with_payments">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_gcc_invoice.arabic_english_invoice'"
t-call="l10n_gcc_invoice.arabic_english_invoice" t-lang="lang"/>
</xpath>
</template>
<template id="arabic_english_invoice">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context(lang=lang)" />
<t t-set="forced_vat" t-value="o.fiscal_position_id.foreign_vat"/> <!-- So that it appears in the footer of the report instead of the company VAT if it's set -->
<t t-set="address">
<address t-field="o.partner_id" t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' style="text-align: right"/>
<div t-if="o.partner_id.vat" class="mt16" style="text-align: right">
<t t-if="o.company_id.account_fiscal_country_id.vat_label" t-esc="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
<t t-else="">Tax ID</t>: <span t-field="o.partner_id.vat"/></div>
<data>
<template id="l10n_gcc_report_invoice_document" inherit_id="account.report_invoice_document" primary="True">
<t t-set="o" position="after">
<t name="l10n_gcc_settings">
<t t-if="lang != 'ar_001'" t-set="lang_sec" t-value="o.env['res.lang']._get_code('ar_001')"/>
<t t-else="" t-set="lang_sec" t-value="o.env['res.lang']._get_code('en_US')"/>
<t t-set="o_sec" t-value="o.with_context(lang=lang_sec)"/>
<t t-set="display_in_lang_sec" t-value="o.company_id.l10n_gcc_country_is_gcc and o.company_id.l10n_gcc_dual_language_invoice"/>
<t t-set="display_in_ar" t-value="display_in_lang_sec and lang_sec == 'ar_001'"/>
<t t-set="display_in_en" t-value="display_in_lang_sec and lang_sec == 'en_US'"/>
<t t-set="invoice_gcc_title" t-value="o._l10n_gcc_get_invoice_title()"/>
<t t-set="invoice_gcc_title_sec" t-value="o_sec._l10n_gcc_get_invoice_title()"/>
</t>
</t>
<!-- Arabic & English titles -->
<t name="invoice_title" position="attributes">
<attribute name="t-if">not invoice_gcc_title</attribute>
</t>
<t name="invoice_title" position="after">
<t t-else="" name="invoice_gcc_title" t-out="invoice_gcc_title"></t>
</t>
<span t-field='o.name' position="after">
<t t-if="display_in_ar and not proforma" t-translation="off">
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">
<t t-if="not invoice_gcc_title_sec" name="invoice_title_ar">فاتورة</t>
<t t-else="" name="invoice_gcc_title_ar" t-out="invoice_gcc_title_sec"></t>
</span>
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">
<t name="draft_invoice_title_ar">مسودة فاتورة</t>
</span>
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">
<t name="cancelled_invoice_title_ar">فاتورة ملغاة</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'posted'">
<t name="credit_note_title_ar">إشعار دائن</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'draft'">
<t name="draft_credit_note_title_ar">مسودة إشعار دائن</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'cancel'">
<t name="cancelled_credit_note_title_ar">إشعار دائن ملغاة</t>
</span>
<span t-elif="o.move_type == 'in_refund'">
<t name="vendor_credit_note_title_ar">إشعار المورد الدائن</t>
</span>
<span t-elif="o.move_type == 'in_invoice'">
<t name="vendor_bill_title_ar">فاتورة المورد</t>
</span>
</t>
<t t-elif="display_in_en and not proforma" t-translation="off">
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'" dir="rtl">
<t t-if="not invoice_gcc_title_sec" name="invoice_title_en">Invoice</t>
<t t-else="" name="invoice_gcc_title_en" t-out="invoice_gcc_title_sec"></t>
</span>
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'" dir="rtl">
<t name="draft_invoice_title_en">Draft Invoice</t>
</span>
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'" dir="rtl">
<t name="cancelled_invoice_title_en">Cancelled Invoice</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'posted'" dir="rtl">
<t name="credit_note_title_en">Credit Note</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'draft'" dir="rtl">
<t name="draft_credit_note_title_en">Draft Credit Note</t>
</span>
<span t-elif="o.move_type == 'out_refund' and o.state == 'cancel'" dir="rtl">
<t name="cancelled_credit_note_title_en">Cancelled Credit Note</t>
</span>
<span t-elif="o.move_type == 'in_refund'" dir="rtl">
<t name="vendor_credit_note_title_en">Vendor Credit Note</t>
</span>
<span t-elif="o.move_type == 'in_invoice'" dir="rtl">
<t name="vendor_bill_title_en">Vendor Bill</t>
</span>
</t>
</span>
<!-- End Arabic & English titles -->
<!-- Arabic & English information div -->
<xpath expr="//div[@name='invoice_date']/t" position="before">
<t t-if="display_in_en" t-translation="off">
<t name="out_invoice_date_en" t-if="o.move_type == 'out_invoice'"><strong>Invoice Date</strong></t>
<t name="out_refund_date_en" t-elif="o.move_type == 'out_refund'"><strong>Credit Note Date</strong></t>
<t name="out_receipt_date_en" t-elif="o.move_type == 'out_receipt'"><strong>Receipt Date</strong></t>
<t name="move_date_en" t-else=""><strong>Date</strong></t>
<br/>
</t>
<t t-elif="display_in_ar" t-translation="off">
<t name="out_invoice_date_ar" t-if="o.move_type == 'out_invoice'"><strong>تاريخ فاتورة العميل</strong></t>
<t name="out_refund_date_ar" t-elif="o.move_type == 'out_refund'"><strong>تاريخ إشعار الدائن</strong></t>
<t name="out_receipt_date_ar" t-elif="o.move_type == 'out_receipt'"><strong>تاريخ الإيصال</strong></t>
<t name="move_date_ar" t-else=""><strong>تاريخ</strong></t>
<br/>
</t>
</xpath>
<xpath expr="//div[@name='due_date']/strong" position="before">
<strong name="due_date_ar" t-if="display_in_ar" t-translation="off">تاريخ الاستحقاق<br/></strong>
<strong name="due_date_en" t-if="display_in_en" t-translation="off">Due Date<br/></strong>
</xpath>
<xpath expr="//div[@name='delivery_date']/strong" position="before">
<strong name="delivery_date_ar" t-if="display_in_ar" t-translation="off">تاريخ التوصيل<br/></strong>
<strong name="delivery_date_en" t-if="display_in_en" t-translation="off">Delivery Date<br/></strong>
</xpath>
<xpath expr="//div[@name='origin']/strong" position="before">
<strong name="origin_ar" t-if="display_in_ar" t-translation="off">المصدر<br/></strong>
<strong name="origin_en" t-if="display_in_en" t-translation="off">Source<br/></strong>
</xpath>
<xpath expr="//div[@name='customer_code']/strong" position="before">
<strong name="customer_code_ar" t-if="display_in_ar" t-translation="off">كود العميل<br/></strong>
<strong name="customer_code_en" t-if="display_in_en" t-translation="off">Customer Code<br/></strong>
</xpath>
<xpath expr="//div[@name='reference']/strong" position="before">
<strong name="reference_ar" t-if="display_in_ar" t-translation="off">رقم الإشارة<br/></strong>
<strong name="reference_en" t-if="display_in_en" t-translation="off">Reference<br/></strong>
</xpath>
<xpath expr="//div[@name='incoterm_id']/strong" position="before">
<strong name="incoterm_id_ar" t-if="display_in_ar" t-translation="off">شرط التجارة الدولي<br/></strong>
<strong name="incoterm_id_en" t-if="display_in_en" t-translation="off">Incoterm<br/></strong>
</xpath>
<!-- End Arabic & English information div -->
<!-- Arabic & English table headers -->
<xpath expr="//th[@name='th_description']/span" position="before">
<span name="th_description_ar" t-if="display_in_ar" t-translation="off">الوصف<br/></span>
<span name="th_description_en" t-if="display_in_en" t-translation="off">Description<br/></span>
</xpath>
<xpath expr="//th[@name='th_quantity']/span" position="before">
<span name="th_quantity_ar" t-if="display_in_ar" t-translation="off">الكمية<br/></span>
<span name="th_quantity_en" t-if="display_in_en" t-translation="off">Quantity<br/></span>
</xpath>
<xpath expr="//th[@name='th_priceunit']/span" position="before">
<span name="th_priceunit_ar" t-if="display_in_ar" t-translation="off">سعر الوحدة<br/></span>
<span name="th_priceunit_en" t-if="display_in_en" t-translation="off">Unit Price<br/></span>
</xpath>
<xpath expr="//th[@name='th_discount']/span" position="before">
<span name="th_discount_ar" t-if="display_in_ar" t-translation="off">٪ خصم<br/></span>
<span name="th_discount_en" t-if="display_in_en" t-translation="off">Disc.%<br/></span>
</xpath>
<xpath expr="//th[@name='th_taxes']/span" position="before">
<span name="th_taxes_ar" t-if="display_in_ar" t-translation="off">الضرائب<br/></span>
<span name="th_taxes_en" t-if="display_in_en" t-translation="off">Taxes<br/></span>
</xpath>
<xpath expr="//th[@name='th_subtotal']/span" position="before">
<span name="th_subtotal_ar" t-if="display_in_ar" t-translation="off">المبلغ<br/></span>
<span name="th_subtotal_en" t-if="display_in_en" t-translation="off">Amount<br/></span>
</xpath>
<!-- End Arabic & English table headers -->
<!-- Arabic & English table body -->
<xpath expr="//td[@name='account_invoice_line_name']/span" position="replace">
<t t-if="line.product_id and display_in_lang_sec">
<t t-set="english_name" t-value="line.with_context(lang='en_US').product_id.display_name"/>
<t t-set="arabic_name" t-value="line.with_context(lang=o.env['res.lang']._get_code('ar_001')).product_id.display_name"/>
<t t-set="o_sec" t-value="o.with_context(lang='ar_001')"/>
<t t-set="o" t-value="o.with_context(lang='en_US')"/>
<div class="page">
<h3>
<div class="row">
<div class="col-4" style="text-align:left">
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">
Tax Invoice
</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">
Draft Invoice
</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">
Cancelled Invoice
</span>
<span t-if="o.move_type == 'out_refund'">
Credit Note
</span>
<span t-if="o.move_type == 'in_refund'">
Vendor Credit Note
</span>
<span t-if="o.move_type == 'in_invoice'">
Vendor Bill
</span>
</div>
<div class="col-4 text-center">
<span t-if="o.name != '/'" t-field="o.name"/>
</div>
<div class="col-4" style="text-align:right">
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">
فاتورة ضريبية
</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">
مسودة فاتورة
</span>
<span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">
فاتورة ملغاة
</span>
<span t-if="o.move_type == 'out_refund'">
إشعار دائن
</span>
<span t-if="o.move_type == 'in_refund'">
إشعار مدين
</span>
<span t-if="o.move_type == 'in_invoice'">
فاتورة المورد
</span>
</div>
</div>
</h3>
<div id="informations" class="pb-3">
<div class="row" t-if="o.invoice_date" name="invoice_date">
<div class="col-2 offset-6">
<strong style="white-space:nowrap">Invoice Date:
</strong>
</div>
<div class="col-2">
<span t-field="o.invoice_date"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
تاريخ الفاتورة
</strong>
</div>
</div>
<div class="row"
t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'"
name="due_date">
<div class="col-2 offset-6">
<strong style="white-space:nowrap">Due Date:
</strong>
</div>
<div class="col-2">
<span t-field="o.invoice_date_due"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
تاريخ الاستحقاق
</strong>
</div>
</div>
<div class="row" t-if="o.invoice_origin" name="origin">
<div class="col-2 offset-6">
<strong style="white-space:nowrap">Source:
</strong>
</div>
<div class="col-2">
<span t-field="o.invoice_origin"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
المصدر
</strong>
</div>
</div>
<div class="row" t-if="o.partner_id.ref" name="customer_code">
<div class="col-2 offset-6">
<strong style="white-space:nowrap">:
Customer Code
</strong>
</div>
<div class="col-2">
<span t-field="o.partner_id.ref"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
كود العميل
</strong>
</div>
</div>
<div class="row" t-if="o.ref" name="reference">
<div class="col-2">
<strong style="white-space:nowrap">Reference:
</strong>
</div>
<div class="col-8">
<span t-field="o.ref"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
رقم الإشارة
</strong>
</div>
</div>
<span t-out="arabic_name + '\n'" t-if="arabic_name not in line.name" t-options="{'widget': 'text'}" dir="rtl"/>
<span t-out="english_name + '\n'" t-if="(english_name != arabic_name) and (english_name not in line.name)" t-options="{'widget': 'text'}"/>
</t>
<span t-if="line.name" t-field="line.name" t-options="{'widget': 'text'}" t-att-dir="o.env['res.lang']._get_data(code=lang).direction"/>
</xpath>
<!-- End Arabic & English table body -->
<!-- Arabic & English payment terms -->
<span id="payment_terms_note_id" position="before">
<span id="payment_terms_note_id_lang_sec"
t-if="o.invoice_payment_term_id.note and o.invoice_payment_term_id.note != o_sec.invoice_payment_term_id.note
and display_in_lang_sec"
t-out="o_sec.invoice_payment_term_id.note"
name="payment_term_lang_sec"/>
</span>
<t t-set="payment_term_details" position="after">
<t t-set="payment_term_details_sec" t-value="o_sec.payment_term_details"/>
</t>
<xpath expr="//div[@id='total_payment_term_details_table']//td" position="before">
<td name="td_payment_term_ar" t-if="display_in_ar" t-translation="off">
<span t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}'
t-out="o_sec.invoice_payment_term_id._get_amount_due_after_discount(o_sec.amount_total, o_sec.amount_tax)" dir="rtl">30.00</span> المبلغ المستحق إذا تم الدفع قبل
<span t-out="o_sec.invoice_payment_term_id._get_last_discount_date_formatted(o_sec.invoice_date)" dir="rtl">2024-01-01</span>
</td>
<td name="td_payment_term_en" t-if="display_in_en" t-translation="off">
<span t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}'
t-out="o_sec.invoice_payment_term_id._get_amount_due_after_discount(o_sec.amount_total, o_sec.amount_tax)" dir="ltr">30.00</span> due if paid before
<span t-out="o_sec.invoice_payment_term_id._get_last_discount_date_formatted(o_sec.invoice_date)" dir="ltr">2024-01-01</span>
</td>
</xpath>
<xpath expr="//div[@id='total_payment_term_details_table']//div[@id='early_payment_discount']" position="before">
<div name="td_payment_term_ar" t-if="display_in_ar" t-translation="off">
<span t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}'
t-out="o_sec.invoice_payment_term_id._get_amount_due_after_discount(o_sec.amount_total, o_sec.amount_tax)" dir="rtl">30.00</span> المبلغ المستحق إذا تم الدفع قبل
<span t-out="o_sec.invoice_payment_term_id._get_last_discount_date_formatted(o_sec.invoice_date)" dir="rtl">2024-01-01</span>
</div>
<t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
<table class="table table-sm o_main_table" name="invoice_line_table">
<thead>
<tr>
<t t-set="colspan" t-value="6"/>
<th name="th_total" class="text-end">
<span>
السعر الاجمالي
</span>
<br/>
<span>
Total Price
</span>
</th>
<th name="th_tax_amount"
class="text-end">
<span>
قيمة الضريبة
</span>
<br/>
<span>
VAT Amount
</span>
</th>
<th name="th_subtotal" class="text-end">
<span>
مبلغ
</span>
<br/>
<span>
Amount
</span>
</th>
<th name="th_taxes"
class="text-end">
<span>
الضرائب
</span>
<br/>
<span>
Taxes
</span>
</th>
<th name="th_price_unit" t-if="display_discount"
class="text-end">
<span>
خصم %
</span>
<br/>
<span>
Disc.%
</span>
<t t-set="colspan" t-value="colspan+1"/>
</th>
<th name="th_priceunit"
class="text-end">
<span>
سعر الوحدة
</span>
<br/>
<span>
Unit price
</span>
</th>
<th name="th_quantity" class="text-end">
<span>
الكمية
</span>
<br/>
<span>
Quantity
</span>
</th>
<th name="th_source" class="d-none text-start" t-if="0">
<span>
المستند المصدر
</span>
<br/>
<span>
Source Document
</span>
</th>
<th name="th_description" class="text-end">
<span>
الوصف
</span>
<br/>
<span>
Description
</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="lines"
t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"
groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total"
groups="account.group_show_line_subtotals_tax_included"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type not in ('line_note', 'line_section')" name="account_invoice_line_accountable">
<td class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_total"/>
</td>
<td class="text-end">
<span class="text-nowrap" t-field="line.l10n_gcc_invoice_tax_amount"/>
</td>
<td class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal"/>
</td>
<td class="text-end">
<span t-out="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"
id="line_tax_ids"/>
</td>
<td t-if="display_discount"
class="text-end">
<span class="text-nowrap" t-field="line.discount"/>
</td>
<td class="text-end">
<span class="text-nowrap" t-field="line.price_unit"/>
</td>
<td class="text-end">
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td name="account_invoice_line_name" class="text-end">
<t t-if="line.product_id">
<t t-set="english_name" t-value="line.with_context(lang='en_US').product_id.display_name"/>
<t t-set="arabic_name" t-value="line.with_context(lang='ar_001').product_id.display_name"/>
<span t-out="arabic_name + '\n'" t-if="arabic_name not in line.name" t-options="{'widget': 'text'}"/>
<span t-out="english_name + '\n'" t-if="(english_name != arabic_name) and (english_name not in line.name)" t-options="{'widget': 'text'}"/>
</t>
<span t-out="line.name" t-options="{'widget': 'text'}"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}"/>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16" style="display: inline-block">Subtotal/الإجمالي الفرعي</strong>
<span
t-out="current_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/>
</td>
</tr>
</t>
</t>
</tbody>
</table>
<div class="clearfix pt-4 pb-3">
<div id="total" class="row">
<div class="col-6">
<table class="table table-sm" style="page-break-inside: avoid;">
<tr class="border-black o_subtotal">
<td class="text-end">
<span t-field="o.amount_untaxed"/>
</td>
<td class="text-end">
<strong>
Subtotal
/
الإجمالي الفرعي
</strong>
</td>
</tr>
<t t-set="tax_totals" t-value="o.tax_totals"/>
<t t-foreach="tax_totals['subtotals']" t-as="subtotal">
<t t-set="subtotal_to_show" t-value="subtotal['name']"/>
<!-- copy-pasted template "account.tax_groups_totals" with reversed columns order -->
<t t-foreach="tax_totals['groups_by_subtotal'][subtotal_to_show]" t-as="amount_by_group">
<tr>
<td class="text-end o_price_total">
<span class="text-nowrap" t-esc="amount_by_group['formatted_tax_group_amount']"/>
</td>
<td class="text-end">
<strong>
<span t-esc="amount_by_group['tax_group_name']"/>
<t t-if="tax_totals['display_tax_base']">
<span class="text-nowrap"> on
<t t-esc="amount_by_group['formatted_tax_group_base_amount']"/>
</span>
</t>
<!-- Arabic translation of tax group -->
<t t-set="arabic_tax_group_name" t-value="o_sec.tax_totals['groups_by_subtotal'][o_sec.tax_totals['subtotals'][subtotal_index]['name']][amount_by_group_index]['tax_group_name']"/>
<span t-if="arabic_tax_group_name != amount_by_group['tax_group_name']" class="text-nowrap">/
<t t-esc="arabic_tax_group_name"/>
</span>
</strong>
</td>
</tr>
</t>
</t>
<tr class="border-black o_total">
<td class="text-end">
<span class="text-nowrap" t-field="o.amount_total"/>
</td>
<td class="text-end">
<strong>
Total
/
المجموع
</strong>
</td>
</tr>
<t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals" t-value="o.sudo().invoice_payments_widget and o.sudo().invoice_payments_widget['content'] or []"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr class="border-black o_total">
<td>
<i class="row">
<div class="col-7 oe_form_field oe_payment_label">
Paid on/دفعت في:
</div>
<div class="col-5 ps-0 oe_form_field oe_payment_label">
<t t-out="payment_vals['date']"/>
</div>
</i>
</td>
<td class="text-end">
<span t-out="payment_vals['amount']"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black">
<td>
<strong>
Amount Due
/
المبلغ المستحق
</strong>
</td>
<td class="text-end">
<span t-field="o.amount_residual"/>
</td>
</tr>
</t>
</t>
</t>
</table>
</div>
</div>
<div name="td_payment_term_en" t-if="display_in_en" t-translation="off">
<span t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}'
t-out="o_sec.invoice_payment_term_id._get_amount_due_after_discount(o_sec.amount_total, o_sec.amount_tax)" dir="ltr">30.00</span> due if paid before
<span t-out="o_sec.invoice_payment_term_id._get_last_discount_date_formatted(o_sec.invoice_date)" dir="ltr">2024-01-01</span>
</div>
</xpath>
<xpath expr="//div[@id='total_payment_term_details_table']//t[2]" position="before">
<t name="div_payment_term_ar" t-if="len(payment_term_details_sec) > 1 and display_in_ar" t-foreach="payment_term_details_sec" t-as="term" t-translation="off">
<div dir="rtl">
<span t-out="term_index + 1">1</span> - دفعة من
<t t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}' t-out="term.get('amount')" class="text-end">31.05</t>
<span> مستحق في </span>
<t t-out="term.get('date')" class="text-start">2024-01-01</t>
</div>
</t>
<t name="div_payment_term_en" t-if="len(payment_term_details_sec) > 1 and display_in_en" t-foreach="payment_term_details_sec" t-as="term" t-translation="off">
<div dir="ltr">
<span t-out="term_index + 1">1</span> - Installment of
<t t-options='{"widget": "monetary", "display_currency": o_sec.currency_id}' t-out="term.get('amount')" class="text-end">31.05</t>
<span> due on </span>
<t t-out="term.get('date')" class="text-start">2024-01-01</t>
</div>
</t>
</xpath>
<!-- End Arabic & English payment terms -->
<!-- Arabic & English amount in words -->
<p t-if="o.company_id.display_invoice_amount_total_words" position="before">
<p name="amount_total_words_lang_sec" t-if="o.company_id.display_invoice_amount_total_words and display_in_lang_sec"
t-att-dir="env['res.lang']._get_data(code=lang_sec).direction or 'ltr'" t-translation="off">
<span t-if="display_in_ar">المبلغ الإجمالي كتابةً: <br/></span>
<span t-if="display_in_en">Total amount in words: <br/></span>
<small class="text-muted lh-sm"><span t-out="o_sec.currency_id.amount_to_text(o_sec.amount_total).replace(' and ', ' و')"></span></small>
</p>
</p>
<!-- End Arabic & English amount in words -->
<!-- Arabic & English amount in words -->
<p name="payment_communication" position="before">
<p name="payment_communication_ar" t-if="display_in_ar" t-translation="off">
<span class="fw-bold" t-out="o_sec.payment_reference">INV/2023/00001</span> :التواصل بشأن الدفع
<t t-if="o_sec.partner_bank_id">
<br/><span t-out="o_sec.partner_bank_id.acc_number" class="fw-bold"/> :في هذا الحساب
</t>
</p>
<p name="payment_communication_en" t-if="display_in_en" t-translation="off">
Payment Communication: <span class="fw-bold" t-out="o_sec.payment_reference">INV/2023/00001</span>
<t t-if="o_sec.partner_bank_id">
<br/> on this account: <span t-out="o_sec.partner_bank_id.acc_number" class="fw-bold"/>
</t>
</p>
</p>
<!-- End Arabic & English amount in words -->
<!-- Call custom tax totals templates -->
<t t-set="tax_totals" position="after">
<t t-set="tax_totals_sec" t-value="o_sec.tax_totals"/>
</t>
<t t-call="account.document_tax_totals" position="attributes">
<attribute name="t-call">l10n_gcc_invoice.l10n_gcc_document_tax_totals</attribute>
</t>
<xpath expr="(//t[@t-set='tax_totals'])[2]" position="after">
<t t-set="tax_totals_sec" t-value="o_sec.tax_totals"/>
<t t-set="show_exchange_rate" t-value="0"/>
</xpath>
<t t-call="account.document_tax_totals_company_currency_template" position="attributes">
<attribute name="t-call">l10n_gcc_invoice.l10n_gcc_document_tax_totals_company_currency_template</attribute>
</t>
<!-- End Call custom tax totals templates -->
</template>
<p t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference" name="payment_communication" class="pt-1">
<div class="row">
<div class="col-2 text-nowrap">
Payment Reference:
</div>
<div class="col-2 text-center">
<b>
<span t-field="o.payment_reference"/>
</b>
</div>
<div class="col-2 text-end">
:رقم إشارة الدفعة
</div>
</div>
</p>
<template id="l10n_gcc_document_tax_totals" inherit_id="account.document_tax_totals" primary="True">
<xpath expr="//t[@t-set='same_tax_base']" position="after">
<t t-set="subtotal_index" t-value="0"/>
</xpath>
<xpath expr="//tr[hasclass('o_subtotal')]" position="before">
<t t-set="subtotal_sec" t-value="tax_totals_sec['subtotals'][subtotal_index]"/>
<t t-set="subtotal_index" t-value="subtotal_index + 1"/>
<t t-set="tax_group_index" t-value="0"/>
</xpath>
<xpath expr="//tr[hasclass('o_taxes')]" position="before">
<t t-set="tax_group_sec" t-value="subtotal_sec['tax_groups'][tax_group_index]"/>
<t t-set="tax_group_index" t-value="tax_group_index + 1"/>
</xpath>
<span t-out="subtotal['name']" position="after">
<span name="untaxed_amount_ar" t-if="display_in_ar" t-translation="off"> / بدون ضريبة</span>
<span name="untaxed_amount_en" t-if="display_in_en" t-translation="off"> / Untaxed Amount</span>
</span>
<xpath expr="//tr[hasclass('o_total')]/td" position="inside">
<strong name="total_ar" t-if="display_in_ar" t-translation="off"> / الإجمالي</strong>
<strong name="total_en" t-if="display_in_en" t-translation="off"> / Total</strong>
</xpath>
</template>
<template id="l10n_gcc_document_tax_totals_company_currency_template" inherit_id="account.document_tax_totals_company_currency_template" primary="True">
<xpath expr="//t[@t-set='same_tax_base']" position="after">
<t t-set="subtotal_index" t-value="0"/>
</xpath>
<xpath expr="//t[@t-as='subtotal']" position="before">
<tr t-if="show_exchange_rate">
<t t-set="exchange_rate" t-if="o.amount_total" t-value="abs(o.amount_total_signed) / o.amount_total"/>
<t t-set="exchange_rate" t-else="" t-value="o.env['res.currency']._get_conversion_rate(o.currency_id, o.company_id.currency_id, o.company_id, o.invoice_date or datetime.date.today())"/>
<td>
<span>Exchange Rate</span>
<span t-if="display_in_ar" t-translation="off"> / سعر الصرف</span>
<span t-if="display_in_en" t-translation="off"> / Exchange Rate</span>
</td>
<td class="text-end" t-out="exchange_rate" t-options='{"widget": "float", "precision": 5}'/>
</tr>
</xpath>
<xpath expr="//tr[hasclass('o_subtotal')]" position="before">
<t t-set="subtotal_sec" t-value="tax_totals_sec['subtotals'][subtotal_index]"/>
<t t-set="subtotal_index" t-value="subtotal_index + 1"/>
<t t-set="tax_group_index" t-value="0"/>
</xpath>
<xpath expr="//tr[hasclass('o_taxes')]" position="before">
<t t-set="tax_group_sec" t-value="subtotal_sec['tax_groups'][tax_group_index]"/>
<t t-set="tax_group_index" t-value="tax_group_index + 1"/>
</xpath>
<span t-field="o.company_currency_id" position="after">
<t name="taxes_ar" t-if="display_in_ar" t-translation="off" dir="rtl">
الضرائب
</t>
</span>
<span t-field="o.company_currency_id" position="after">
<t name="taxes_en" t-if="display_in_en" t-translation="off">
Taxes
</t>
</span>
<span t-out="subtotal['name']" position="after">
<span name="untaxed_amount_ar" t-if="display_in_ar" t-translation="off"> / المبلغ دون ضريبة</span>
<span name="untaxed_amount_en" t-if="display_in_en" t-translation="off"> / Untaxed Amount</span>
</span>
<xpath expr="//tr[hasclass('o_total')]/td" position="inside">
<strong name="total_ar" t-if="display_in_ar" t-translation="off"> / الإجمالي</strong>
<strong name="total_en" t-if="display_in_en" t-translation="off"> / Total</strong>
</xpath>
</template>
<p t-if="o.invoice_payment_term_id" name="payment_term">
<div class="row">
<div class="col-3 text-start">
<span t-out="o.invoice_payment_term_id.note"/>
</div>
<div class="col-3 text-end">
<span t-if="o.invoice_payment_term_id.note != o_sec.invoice_payment_term_id.note" dir="rtl" t-out="o_sec.invoice_payment_term_id.note"/>
</div>
</div>
<t t-if="o.invoice_payment_term_id.display_on_invoice and o.payment_term_details">
<div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
<t t-set="pt_size" t-value="'col-9 offset-3' if o.show_discount_details else 'col-6 offset-6'"/>
<t t-set="pt_size_html" t-value="'col-sm-9 col-md-8 offset-sm-3 offset-md-4' if o.show_discount_details else 'col-sm-6 col-md-6 offset-sm-6 offset-md-6'"/>
<div t-attf-class="#{pt_size if report_type != 'html' else pt_size_html} mt-2 mb-2">
<table class="table table-sm" style="page-break-inside: avoid;">
<th class="border-black text-start">
<span>
تاريخ الاستحقاق
</span>
<br/>
<span>
Due Date
</span>
</th>
<th class="border-black text-end">
<span>
المبلغ المستحق
</span>
<br/>
<span>
Amount Due
</span>
</th>
<th t-if="o.show_discount_details" class="border-black text-end">
<span>
الخصم
</span>
<br/>
<span>
Discount
</span>
</th>
<t t-foreach="o.payment_term_details" t-as="term">
<tr>
<td t-esc="term.get('date')" class="text-start"/>
<td t-options="{'widget': 'monetary', 'display_currency': o.currency_id}" t-esc="term.get('amount')" class="text-end"/>
<td t-if="term.get('discount_date')" class="text-end">
<span dir="rtl" style="white-space: normal;">
<span t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
t-esc="term.get('discount_amount_currency')"/> إذا تم الدفع قبل
<span t-esc="term.get('discount_date')"/>
</span>
<br/>
<span t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
t-esc="term.get('discount_amount_currency')"/> if paid before
<span t-esc="term.get('discount_date')"/>
</td>
</tr>
</t>
</table>
</div>
</div>
</t>
</p>
<p t-if="o.narration" name="comment">
<div class="row">
<div class="col-6 text-start">
<span t-out="o.narration"/>
</div>
<div class="col-6 text-end">
<span t-if="o.narration != o_sec.narration" dir="rtl" t-out="o_sec.narration"/>
</div>
</div>
</p>
<p t-if="o.fiscal_position_id.note" name="note">
<div class="row">
<div class="col-6 text-start">
<span t-out="o.fiscal_position_id.note"/>
</div>
<div class="col-6 text-end">
<span t-if="o.fiscal_position_id.note != o_sec.fiscal_position_id.note" dir="rtl" t-out="o_sec.fiscal_position_id.note"/>
</div>
</div>
</p>
<p t-if="o.invoice_incoterm_id" name="incoterm">
<div class="row">
<div class="col-6 text-start">
<strong>Incoterm:
</strong>
<span
t-out="o.invoice_incoterm_id.code"/>
-
<span
t-out="o.invoice_incoterm_id.name"/>
</div>
<div class="col-6 text-end">
<strong>شرط تجاري:
</strong>
<span
t-out="o_sec.invoice_incoterm_id.code"/>
-
<span
t-out="o_sec.invoice_incoterm_id.name"/>
</div>
</div>
</p>
</div>
</t>
</template>
<!-- Workaround for Studio reports, see odoo/odoo#60660 -->
<template id="report_invoice" inherit_id="account.report_invoice">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-elif="o._get_name_invoice_report() == 'l10n_gcc_invoice.l10n_gcc_report_invoice_document'"
t-call="l10n_gcc_invoice.l10n_gcc_report_invoice_document"
t-lang="lang"/>
</xpath>
</template>
</data>
</odoo>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="res_config_settings_view_form_inherit_l10n_gcc_invoice" model="ir.ui.view">
<field name="name">res.config.settins.view.form.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<block id="invoicing_settings" position="inside">
<setting string="Gulf Cooperation Council Format" company_dependent="1"
invisible="not l10n_gcc_country_is_gcc"
help="Add Arabic as a secondary language to your invoices, credit notes, debit notes, vendor bills, and refund bills">
<field name="l10n_gcc_dual_language_invoice"/>
</setting>
</block>
</field>
</record>
</data>
</odoo>

View file

@ -1,12 +1,14 @@
[project]
name = "odoo-bringout-oca-ocb-l10n_gcc_invoice"
version = "16.0.0"
description = "G.C.C. - Arabic/English Invoice - Odoo addon"
description = "Gulf Cooperation Council - Invoice -
Odoo addon
"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-account>=16.0.0",
"odoo-bringout-oca-ocb-account>=19.0.0",
"requests>=2.25.1"
]
readme = "README.md"
@ -16,7 +18,7 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]