Initial commit: L10N_Me Africa packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:53 +02:00
commit c265268138
611 changed files with 75334 additions and 0 deletions

View file

@ -0,0 +1,49 @@
# Saudi Arabia - Point of Sale
Saudi Arabia POS Localization
## Installation
```bash
pip install odoo-bringout-oca-ocb-l10n_sa_pos
```
## Dependencies
This addon depends on:
- l10n_gcc_pos
- l10n_sa
## Manifest Information
- **Name**: Saudi Arabia - Point of Sale
- **Version**: N/A
- **Category**: Accounting/Localizations/Point of Sale
- **License**: LGPL-3
- **Installable**: False
## Source
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `l10n_sa_pos`.
## 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
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.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

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph L10n_sa_pos Module - l10n_sa_pos
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for l10n_sa_pos. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,6 @@
# Dependencies
This addon depends on:
- [l10n_gcc_pos](../../odoo-bringout-oca-ocb-l10n_gcc_pos)
- [l10n_sa](../../odoo-bringout-oca-ocb-l10n_sa)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon l10n_sa_pos or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-ocb-l10n_sa_pos"
# or
uv pip install odoo-bringout-oca-ocb-l10n_sa_pos"
```

View file

@ -0,0 +1,13 @@
# Models
Detected core models and extensions in l10n_sa_pos.
```mermaid
classDiagram
class pos_config
class pos_order
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: l10n_sa_pos. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon l10n_sa_pos
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon l10n_sa_pos
```

View file

@ -0,0 +1,3 @@
# Wizards
This module does not include UI wizards.

View file

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Saudi Arabia - Point of Sale',
'author': 'Odoo S.A.',
'category': 'Accounting/Localizations/Point of Sale',
'icon': '/l10n_sa/static/description/icon.png',
'description': """
Saudi Arabia POS Localization
""",
'license': 'LGPL-3',
'depends': [
'l10n_gcc_pos',
'l10n_sa',
],
'assets': {
'point_of_sale.assets': [
'web/static/lib/zxing-library/zxing-library.js',
'l10n_sa_pos/static/src/js/models.js',
'l10n_sa_pos/static/src/xml/OrderReceipt.xml',
'l10n_sa_pos/static/src/css/pos_receipt.css',
]
},
'auto_install': True,
}

View file

@ -0,0 +1,5 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import pos_config

View file

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.exceptions import UserError
from odoo.tools.translate import _
class pos_config(models.Model):
_inherit = 'pos.config'
def open_ui(self):
for config in self:
if not config.company_id.country_id:
raise UserError(_("You have to set a country in your company setting."))
return super(pos_config, self).open_ui()

View file

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class POSOrder(models.Model):
_inherit = 'pos.order'
def _prepare_invoice_vals(self):
vals = super()._prepare_invoice_vals()
if self.company_id.country_id.code == 'SA':
vals.update({'l10n_sa_confirmation_datetime': self.date_order})
return vals

View file

@ -0,0 +1,4 @@
.pos-receipt .pos-receipt-qrcode {
display: block;
margin: 0 auto;
}

View file

@ -0,0 +1,64 @@
odoo.define('l10n_sa_pos.pos', function (require) {
"use strict";
var { Order } = require('point_of_sale.models');
var Registries = require('point_of_sale.Registries');
const PosL10nSAOrder = (Order) => class PosL10nSAOrder extends Order {
export_for_printing() {
var result = super.export_for_printing(...arguments);
if (this.pos.company.country && this.pos.company.country.code === 'SA') {
result.is_settlement = this.is_settlement();
if (!result.is_settlement) {
const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter()
let qr_values = this.compute_sa_qr_code(result.company.name, result.company.vat, result.date.isostring, result.total_with_tax, result.total_tax);
let qr_code_svg = new XMLSerializer().serializeToString(codeWriter.write(qr_values, 150, 150));
result.qr_code = "data:image/svg+xml;base64," + window.btoa(qr_code_svg);
}
}
return result;
}
/**
* If the order is empty (there are no products)
* and all "pay_later" payments are negative,
* we are settling a customer's account.
* If the module pos_settle_due is not installed,
* the function always returns false (since "pay_later" doesn't exist)
* @returns {boolean} true if the current order is a settlement, else false
*/
is_settlement() {
return this.is_empty() &&
!!this.paymentlines.filter(paymentline => paymentline.payment_method.type === "pay_later" && paymentline.amount < 0).length;
}
compute_sa_qr_code(name, vat, date_isostring, amount_total, amount_tax) {
/* Generate the qr code for Saudi e-invoicing. Specs are available at the following link at page 23
https://zatca.gov.sa/ar/E-Invoicing/SystemsDevelopers/Documents/20210528_ZATCA_Electronic_Invoice_Security_Features_Implementation_Standards_vShared.pdf
*/
const seller_name_enc = this._compute_qr_code_field(1, name);
const company_vat_enc = this._compute_qr_code_field(2, vat);
const timestamp_enc = this._compute_qr_code_field(3, date_isostring);
const invoice_total_enc = this._compute_qr_code_field(4, amount_total.toString());
const total_vat_enc = this._compute_qr_code_field(5, amount_tax.toString());
const str_to_encode = seller_name_enc.concat(company_vat_enc, timestamp_enc, invoice_total_enc, total_vat_enc);
let binary = '';
for (let i = 0; i < str_to_encode.length; i++) {
binary += String.fromCharCode(str_to_encode[i]);
}
return btoa(binary);
}
_compute_qr_code_field(tag, field) {
const textEncoder = new TextEncoder();
const name_byte_array = Array.from(textEncoder.encode(field));
const name_tag_encoding = [tag];
const name_length_encoding = [name_byte_array.length];
return name_tag_encoding.concat(name_length_encoding, name_byte_array);
}
}
Registries.Model.extend(Order, PosL10nSAOrder);
});

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1">
<xpath expr="//img[hasclass('pos-receipt-logo')]" position="after">
<t t-if="receipt.is_gcc_country and !receipt.is_settlement">
<img t-if="receipt.qr_code" id="qrcode" t-att-src="receipt.qr_code" class="pos-receipt-qrcode"/>
<br/>
</t>
</xpath>
<xpath expr="//span[@id='title_english']" position="replace">
<t t-if="!receipt.is_settlement">
<span id="title_english">Simplified Tax Invoice</span>
</t>
</xpath>
<xpath expr="//span[@id='title_arabic']" position="replace">
<t t-if="!receipt.is_settlement">
<span id="title_arabic">فاتورة ضريبية مبسطة</span>
</t>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,43 @@
[project]
name = "odoo-bringout-oca-ocb-l10n_sa_pos"
version = "16.0.0"
description = "Saudi Arabia - Point of Sale - Odoo addon"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-ocb-l10n_gcc_pos>=16.0.0",
"odoo-bringout-oca-ocb-l10n_sa>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"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.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["l10n_sa_pos"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]