mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-26 23:42:07 +02:00
Initial commit: L10N_Europe packages
This commit is contained in:
commit
9803722600
2377 changed files with 380711 additions and 0 deletions
47
odoo-bringout-oca-ocb-l10n_latam_account_sequence/README.md
Normal file
47
odoo-bringout-oca-ocb-l10n_latam_account_sequence/README.md
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Accounting Sequence - Latam Documents
|
||||
|
||||
Change the way `sequence.mixin` works to reduce concurrency errors
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-ocb-l10n_latam_account_sequence
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
This addon depends on:
|
||||
- l10n_latam_invoice_document
|
||||
- account_sequence
|
||||
|
||||
## Manifest Information
|
||||
|
||||
- **Name**: Accounting Sequence - Latam Documents
|
||||
- **Version**: 1.0
|
||||
- **Category**: Hidden
|
||||
- **License**: LGPL-3
|
||||
- **Installable**: True
|
||||
|
||||
## Source
|
||||
|
||||
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `l10n_latam_account_sequence`.
|
||||
|
||||
## 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
|
||||
|
|
@ -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_latam_account_sequence Module - l10n_latam_account_sequence
|
||||
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.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Configuration
|
||||
|
||||
Refer to Odoo settings for l10n_latam_account_sequence. Configure related models, access rights, and options as needed.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Controllers
|
||||
|
||||
This module does not define custom HTTP controllers.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Dependencies
|
||||
|
||||
This addon depends on:
|
||||
|
||||
- [l10n_latam_invoice_document](../../odoo-bringout-oca-ocb-l10n_latam_invoice_document)
|
||||
- [account_sequence](../../odoo-bringout-oca-ocb-account_sequence)
|
||||
|
|
@ -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_latam_account_sequence or install in UI.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Install
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-ocb-l10n_latam_account_sequence"
|
||||
# or
|
||||
uv pip install odoo-bringout-oca-ocb-l10n_latam_account_sequence"
|
||||
```
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Models
|
||||
|
||||
Detected core models and extensions in l10n_latam_account_sequence.
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class account_move
|
||||
```
|
||||
|
||||
Notes
|
||||
- Classes show model technical names; fields omitted for brevity.
|
||||
- Items listed under _inherit are extensions of existing models.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Overview
|
||||
|
||||
Packaged Odoo addon: l10n_latam_account_sequence. Provides features documented in upstream Odoo 16 under this addon.
|
||||
|
||||
- Source: OCA/OCB 16.0, addon l10n_latam_account_sequence
|
||||
- License: LGPL-3
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Reports
|
||||
|
||||
This module does not define custom reports.
|
||||
|
|
@ -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
|
||||
|
|
@ -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.
|
||||
|
|
@ -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_latam_account_sequence
|
||||
```
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Wizards
|
||||
|
||||
This module does not include UI wizards.
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
# Copyright (c) 2011 CCI Connect asbl (http://www.cciconnect.be) All Rights Reserved.
|
||||
# Philmer <philmer@cciconnect.be>
|
||||
|
||||
{
|
||||
'name': 'Accounting Sequence - Latam Documents',
|
||||
'version': '1.0',
|
||||
'category': 'Hidden',
|
||||
'description': "Change the way `sequence.mixin` works to reduce concurrency errors",
|
||||
'depends': ['l10n_latam_invoice_document', 'account_sequence'],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import account_move
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
from odoo import models
|
||||
from odoo.tools.sql import index_exists, drop_index
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
_sql_constraints = [(
|
||||
'unique_name', "", "Another entry with the same name already exists.",
|
||||
), (
|
||||
'unique_name_latam', "", "Another entry with the same name already exists.",
|
||||
)]
|
||||
|
||||
def _auto_init(self):
|
||||
super()._auto_init()
|
||||
# Update the generic unique name constraint to not consider the purchases in latam companies.
|
||||
# The name should be unique by partner for those documents.
|
||||
if not index_exists(self.env.cr, "account_move_unique_name_latam"):
|
||||
drop_index(self.env.cr, "account_move_unique_name", self._table)
|
||||
|
||||
# Fixup the account.move names like "sequence (N)" removing the "(N)" part
|
||||
self.env.cr.execute("""
|
||||
UPDATE account_move SET name = SUBSTRING(account_move.name, 1, strpos(account_move.name::varchar, ' ('::varchar) -1 )
|
||||
WHERE l10n_latam_document_type_id IS NOT NULL AND account_move.name LIKE '% (%)'
|
||||
AND move_type IN ('in_invoice', 'in_refund', 'in_receipt');""")
|
||||
|
||||
# Make all values of `name` different (naming them `name (1)`, `name (2)`...) so that we can add the following UNIQUE INDEX
|
||||
self.env.cr.execute("""
|
||||
WITH duplicated_sequence AS (
|
||||
SELECT name, commercial_partner_id, l10n_latam_document_type_id, state
|
||||
FROM account_move
|
||||
WHERE state = 'posted'
|
||||
AND name != '/'
|
||||
AND (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund', 'in_receipt'))
|
||||
GROUP BY commercial_partner_id, l10n_latam_document_type_id, name, state
|
||||
HAVING COUNT(*) > 1
|
||||
),
|
||||
to_update AS (
|
||||
SELECT move.id,
|
||||
move.name,
|
||||
move.state,
|
||||
move.date,
|
||||
row_number() OVER(PARTITION BY move.name, move.commercial_partner_id, move.l10n_latam_document_type_id ORDER BY move.name, move.commercial_partner_id, move.l10n_latam_document_type_id, move.date) AS row_seq
|
||||
FROM duplicated_sequence
|
||||
JOIN account_move move ON move.name = duplicated_sequence.name
|
||||
AND move.commercial_partner_id = duplicated_sequence.commercial_partner_id
|
||||
AND move.l10n_latam_document_type_id = duplicated_sequence.l10n_latam_document_type_id
|
||||
AND move.state = duplicated_sequence.state
|
||||
),
|
||||
new_vals AS (
|
||||
SELECT id,
|
||||
name || ' (' || (row_seq-1)::text || ')' AS name
|
||||
FROM to_update
|
||||
WHERE row_seq > 1
|
||||
)
|
||||
UPDATE account_move
|
||||
SET name = new_vals.name
|
||||
FROM new_vals
|
||||
WHERE account_move.id = new_vals.id;
|
||||
""")
|
||||
|
||||
self.env.cr.execute("""
|
||||
CREATE UNIQUE INDEX account_move_unique_name
|
||||
ON account_move(name, journal_id)
|
||||
WHERE (state = 'posted' AND name != '/'
|
||||
AND (l10n_latam_document_type_id IS NULL OR move_type NOT IN ('in_invoice', 'in_refund', 'in_receipt')));
|
||||
CREATE UNIQUE INDEX account_move_unique_name_latam
|
||||
ON account_move(name, commercial_partner_id, l10n_latam_document_type_id, company_id)
|
||||
WHERE (state = 'posted' AND name != '/'
|
||||
AND (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund', 'in_receipt')));
|
||||
""")
|
||||
|
||||
def _check_unique_vendor_number(self):
|
||||
return
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
[project]
|
||||
name = "odoo-bringout-oca-ocb-l10n_latam_account_sequence"
|
||||
version = "16.0.0"
|
||||
description = "Accounting Sequence - Latam Documents - Odoo addon"
|
||||
authors = [
|
||||
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
|
||||
]
|
||||
dependencies = [
|
||||
"odoo-bringout-oca-ocb-l10n_latam_invoice_document>=16.0.0",
|
||||
"odoo-bringout-oca-ocb-account_sequence>=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_latam_account_sequence"]
|
||||
|
||||
[tool.rye]
|
||||
managed = true
|
||||
dev-dependencies = [
|
||||
"pytest>=8.4.1",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue