Skip to content

Commit

Permalink
Merge PR #271 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by adrienpeiffer
  • Loading branch information
OCA-git-bot committed Oct 10, 2024
2 parents 0ac7138 + f9375a8 commit 75ef322
Show file tree
Hide file tree
Showing 93 changed files with 3,386 additions and 17 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ jobs:
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
name: test with Odoo
makepot: "true"
exclude: "account_cutoff_picking"
name: test with Odoo w/o account_cutoff_picking
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
name: test with OCB
exclude: "account_cutoff_picking"
name: test with OCB w/o account_cutoff_picking
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
makepot: "true"
include: "account_cutoff_base,purchase_stock,sale_stock,account_cutoff_picking"
name: test with Odoo w/ account_cutoff_picking
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
include: "account_cutoff_base,purchase_stock,sale_stock,account_cutoff_picking"
name: test with OCB w/ account_cutoff_picking
env:
INCLUDE: "${{ matrix.include }}"
EXCLUDE: "${{ matrix.exclude }}"
services:
postgres:
image: postgres:12.0
Expand Down
1 change: 1 addition & 0 deletions account_cutoff_accrual_order_base/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions account_cutoff_accrual_order_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
21 changes: 21 additions & 0 deletions account_cutoff_accrual_order_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


{
"name": "Account Cut-off Accrual Order Base",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Accrued Order Base",
"author": "BCIM, Akretion, Odoo Community Association (OCA)",
"maintainers": ["jbaudoux"],
"website": "https://github.com/OCA/account-closing",
"depends": ["account_cutoff_base"],
"data": [
"views/account_cutoff_view.xml",
"views/account_cutoff_line_view.xml",
],
"installable": True,
"application": False,
}
175 changes: 175 additions & 0 deletions account_cutoff_accrual_order_base/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_cutoff_accrual_order_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-26 11:53+0000\n"
"PO-Revision-Date: 2023-10-26 11:53+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_cutoff_accrual_order_base
#: model_terms:ir.ui.view,arch_db:account_cutoff_accrual_order_base.account_cutoff_form
msgid "<span> on </span>"
msgstr "<span> sur </span>"

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_account_cutoff
msgid "Account Cut-off"
msgstr "Provision"

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_account_cutoff_line
msgid "Account Cut-off Line"
msgstr "Ligne de provision"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__amount
msgid "Amount"
msgstr "Montant"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,help:account_cutoff_accrual_order_base.field_account_cutoff_line__amount
msgid "Amount that is used as base to compute the Cut-off Amount."
msgstr "Montant qui est utilisé comme base pour calculer le montant de la provision"

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_res_company
msgid "Companies"
msgstr "Sociétés"

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres de configuration"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__cutoff_amount
msgid "Cut-off Amount"
msgstr "Montant de la provision"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,help:account_cutoff_accrual_order_base.field_account_cutoff_line__cutoff_amount
msgid "Cut-off Amount without taxes in the Company Currency."
msgstr "Montant de provision hors taxes dans la devise de la société."

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_order_line_cutoff_accrual_mixin
msgid "Cutoff Accrual Order Line Mixin"
msgstr ""

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_res_company__cutoff_exclude_locked_orders
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_res_config_settings__cutoff_exclude_locked_orders
msgid "Cutoff Exclude Locked Orders"
msgstr "Provision Exclure les commandes verrouillées"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,help:account_cutoff_accrual_order_base.field_res_company__cutoff_exclude_locked_orders
#: model:ir.model.fields,help:account_cutoff_accrual_order_base.field_res_config_settings__cutoff_exclude_locked_orders
msgid "Do not generate cut-off entries for orders that are locked"
msgstr "Ne pas générer d'écriture de provision pour les commande verrouillées"

#. module: account_cutoff_accrual_order_base
#. odoo-python
#: code:addons/account_cutoff_accrual_order_base/models/order_line_mixin.py:0
#, python-format
msgid "Error: Missing '%(label)s' on tax '%(name)s'."
msgstr "Errur: '%(label)s' manquant sur la taxe '%(name)s'."

#. module: account_cutoff_accrual_order_base
#. odoo-python
#: code:addons/account_cutoff_accrual_order_base/models/account_cutoff.py:0
#, python-format
msgid ""
"Error: Missing {map_type} account on product '{product}' or on related "
"product category."
msgstr ""
"Erreur: {map_type} compte manquant sur le produit '{product}' ou sur "
"la catégorie de product liée."

#. module: account_cutoff_accrual_order_base
#: model_terms:ir.ui.view,arch_db:account_cutoff_accrual_order_base.res_config_settings_view_form
msgid "Exclude Locked Orders"
msgstr "Exclure les commandes verrouillées"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__invoice_line_ids
#: model_terms:ir.ui.view,arch_db:account_cutoff_accrual_order_base.account_cutoff_line_form
msgid "Invoice Lines"
msgstr "Lignes de facture"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__invoiced_qty
msgid "Invoiced Quantity"
msgstr "Quantité facturée"

#. module: account_cutoff_accrual_order_base
#: model:ir.model,name:account_cutoff_accrual_order_base.model_account_move
msgid "Journal Entry"
msgstr "Pièce comptable"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff__order_line_model
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__order_line_model
msgid "Order Line Model"
msgstr ""

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__product_id
msgid "Product"
msgstr "Produit"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__quantity
msgid "Quantity"
msgstr "Quantité"

#. module: account_cutoff_accrual_order_base
#: model:ir.model.fields,field_description:account_cutoff_accrual_order_base.field_account_cutoff_line__received_qty
msgid "Received Quantity"
msgstr "Quantité reçue"

#. module: account_cutoff_accrual_order_base
#. odoo-python
#: code:addons/account_cutoff_accrual_order_base/models/order_line_mixin.py:0
#, python-format
msgid "Wrong cutoff type %s"
msgstr "Mauvais type de cutoff %s"

#. module: account_cutoff_accrual_order_base
#. odoo-python
#: code:addons/account_cutoff_accrual_order_base/models/account_move.py:0
#, python-format
msgid ""
"You cannot validate an invoice for an accounting date that generates an entry in a closed cut-off (i.e. for which an accounting entry has already been created).\n"
" - Cut-off: {cutoff}\n"
" - Product: {product}\n"
msgstr ""
"Vous ne pouvez pas valider une facture à une date comptable qui génère une ligne dans une provision fermée (càd pour laquelle l'écriture comptable de provision a déjà été créée).\n"
" - Provision: {cutoff}\n"
" - Produit: {product}\n"

#. module: account_cutoff_accrual_order_base
#. odoo-python
#: code:addons/account_cutoff_accrual_order_base/models/account_move.py:0
#, python-format
msgid ""
"You cannot validate an invoice for an accounting date that modifies a closed cutoff (i.e. for which an accounting entry has already been created).\n"
" - Cut-off: {cutoff}\n"
" - Product: {product}\n"
" - Previous invoiced quantity: {prev_inv_qty}\n"
" - New invoiced quantity: {new_inv_qty}"
msgstr ""
"Vous ne pouvez pas valider une facture à une date comptable qui modifie une provision fermée (càd pour laquelle l'écriture comptable de provision a déjà été créée).\n"
" - Provision: {cutoff}\n"
" - Produit: {product}\n"
" - Précédente quantité facturée: {prev_inv_qty}\n"
" - Nouvelle quantité facturée: {new_inv_qty}"
7 changes: 7 additions & 0 deletions account_cutoff_accrual_order_base/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_cutoff
from . import account_cutoff_line
from . import order_line_mixin
from . import account_move
108 changes: 108 additions & 0 deletions account_cutoff_accrual_order_base/models/account_cutoff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

import logging
from datetime import datetime, time, timedelta

import pytz
from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools import split_every

_logger = logging.getLogger(__name__)


class AccountCutoff(models.Model):
_inherit = "account.cutoff"

order_line_model = fields.Selection(
selection=[],
readonly=True,
)

def _nextday_start_dt(self):
"""Convert the cutoff date into datetime as start of next day."""
next_day = self.cutoff_date + timedelta(days=1)
tz = self.env.company.partner_id.tz or "UTC"
start_next_day = datetime.combine(
next_day, time(0, 0, 0, 0, tzinfo=pytz.timezone(tz))
)
return start_next_day.replace(tzinfo=None)

def _get_product_account(self, product, fpos):
if self.cutoff_type in "accrued_revenue":
map_type = "income"
elif self.cutoff_type in "accrued_expense":
map_type = "expense"
else:
return
account = product.product_tmpl_id.get_product_accounts(fpos)[map_type]
if not account:
raise UserError(
_(
"Error: Missing {map_type} account on product '{product}' or on"
" related product category.",
).format(
map_type=map_type,
product=product.name,
)
)
return account

def get_lines(self):
self.ensure_one()
# If the computation of the cutoff is done at the cutoff date, then we
# only need to retrieve lines where there is a qty to invoice (i.e.
# delivered qty != invoiced qty).
# For any line where a move or an invoice has been done after the
# cutoff date, we need to recompute the quantities.
res = super().get_lines()
if not self.order_line_model:
return res

model = self.env[self.order_line_model]
_logger.debug("Get model lines")
line_ids = set(model.browse(model._get_cutoff_accrual_lines_query(self)).ids)
_logger.debug("Get model lines invoiced after")
line_ids |= set(model._get_cutoff_accrual_lines_invoiced_after(self).ids)
_logger.debug("Get model lines delivered after")
line_ids |= set(model._get_cutoff_accrual_lines_delivered_after(self).ids)

_logger.debug("Prepare cutoff lines per chunks")
# A good chunk size is per 1000. If bigger, it is not faster but memory
# usage increases. If too low, then it takes more cpu time.
for chunk in split_every(models.INSERT_BATCH_SIZE * 10, tuple(line_ids)):
lines = model.browse(chunk)
values = []
for line in lines:
data = line._prepare_cutoff_accrual_line(self)
if not data:
continue
values.append(data)
self.env["account.cutoff.line"].create(values)
# free memory usage
self.env.invalidate_all()
_logger.debug("Prepare cutoff lines - next chunk")
return res

@api.model
def _cron_cutoff(self, cutoff_type, model):
# Cron is expected to run at begin of new period. We need the last day
# of previous month. Support some time difference and compute last day
# of previous period.
last_day = datetime.today()
if last_day.day > 20:
last_day += relativedelta(months=1)
last_day = last_day.replace(day=1)
last_day -= relativedelta(days=1)
cutoff = self.with_context(default_cutoff_type=cutoff_type).create(
{
"cutoff_date": last_day,
"cutoff_type": cutoff_type,
"order_line_model": model,
"auto_reverse": True,
}
)
cutoff.get_lines()
Loading

0 comments on commit 75ef322

Please sign in to comment.