Skip to content
Extraits de code Groupes Projets
Valider 1b3fb203 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[update] load liasse xml and function + add option to send PDF file by node ref

parent ebe9d969
Branches
Aucune étiquette associée trouvée
1 requête de fusion!1[merge] add new process LF
...@@ -6,8 +6,6 @@ exclude: | ...@@ -6,8 +6,6 @@ exclude: |
^setup/|/static/description/index\.html$| ^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files # We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized) # Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/| /static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying # Repos using Sphinx to generate docs don't need prettying
...@@ -28,7 +26,7 @@ repos: ...@@ -28,7 +26,7 @@ repos:
language: fail language: fail
files: "\\.rej$" files: "\\.rej$"
- repo: https://github.com/oca/maintainer-tools - repo: https://github.com/oca/maintainer-tools
rev: ab1d7f6 rev: 7d8a9f9ad73db0976fb03cbee43d953bc29b89e9
hooks: hooks:
# update the NOT INSTALLABLE ADDONS section above # update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons - id: oca-update-pre-commit-excluded-addons
...@@ -46,11 +44,11 @@ repos: ...@@ -46,11 +44,11 @@ repos:
- --remove-duplicate-keys - --remove-duplicate-keys
- --remove-unused-variables - --remove-unused-variables
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 20.8b1 rev: 22.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2 rev: v2.6.2
hooks: hooks:
- id: prettier - id: prettier
name: prettier (with plugin-xml) name: prettier (with plugin-xml)
...@@ -61,7 +59,7 @@ repos: ...@@ -61,7 +59,7 @@ repos:
- --plugin=@prettier/plugin-xml - --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint - repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.8.1 rev: v8.15.0
hooks: hooks:
- id: eslint - id: eslint
verbose: true verbose: true
...@@ -69,7 +67,7 @@ repos: ...@@ -69,7 +67,7 @@ repos:
- --color - --color
- --fix - --fix
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0 rev: v4.2.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
# exclude autogenerated files # exclude autogenerated files
...@@ -91,12 +89,12 @@ repos: ...@@ -91,12 +89,12 @@ repos:
- id: mixed-line-ending - id: mixed-line-ending
args: ["--fix=lf"] args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.7.2 rev: v2.32.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ["--keep-percent-format"] args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.5.1 rev: 5.10.1
hooks: hooks:
- id: isort - id: isort
name: isort except __init__.py name: isort except __init__.py
...@@ -104,13 +102,13 @@ repos: ...@@ -104,13 +102,13 @@ repos:
- --settings=. - --settings=.
exclude: /__init__\.py$ exclude: /__init__\.py$
- repo: https://gitlab.com/PyCQA/flake8 - repo: https://gitlab.com/PyCQA/flake8
rev: 3.8.3 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
name: flake8 name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"] additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/pylint - repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.3 rev: v2.11.1
hooks: hooks:
- id: pylint - id: pylint
name: pylint with optional checks name: pylint with optional checks
...@@ -119,7 +117,7 @@ repos: ...@@ -119,7 +117,7 @@ repos:
- --exit-zero - --exit-zero
verbose: true verbose: true
additional_dependencies: &pylint_deps additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0 - pylint-odoo==5.0.5
- id: pylint - id: pylint
name: pylint with mandatory checks name: pylint with mandatory checks
args: args:
......
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
"application": False, "application": False,
"depends": [ "depends": [
"cgscop_inovatic", "cgscop_inovatic",
"cgscop_liste_ministere_alfodoo", "cgscop_liasse_fiscale",
"cgscop_liste_ministere",
], ],
"data": [ "data": [
"security/ir.model.access.csv",
"datas/cron_inovatic.xml", "datas/cron_inovatic.xml",
"views/scop_liste_ministere.xml",
"wizard/load_xml_liasse.xml", "wizard/load_xml_liasse.xml",
"views/scop_liste_ministere.xml",
], ],
"installable": True, "installable": True,
"auto_install": False, "auto_install": False,
......
...@@ -32,16 +32,28 @@ class InovaticJobQueue(models.Model): ...@@ -32,16 +32,28 @@ class InovaticJobQueue(models.Model):
# Internal function # Internal function
# ------------------------------------------------------ # ------------------------------------------------------
def _get_cmis_file(self): def _get_cmis_file(self):
if not self.liasse_fiscale_id.liste_ministere_id: if (
not self.liasse_fiscale_id.node_ref
or not self.liasse_fiscale_id.liste_ministere_id
):
raise UserError( raise UserError(
_( _(
"Rechargement impossible : il n'y a pas de " "Rechargement impossible : il n'y a pas de fichier ou de "
"Liste Ministère associée à cette liasse" "Liste Ministère associé à cette liasse"
) )
) )
backend = self.env["cmis.backend"].search([]) backend = self.env["cmis.backend"].search([])
backend.ensure_one() backend.ensure_one()
cmis_client = backend.get_cmis_client() cmis_client = backend.get_cmis_client()
if self.liasse_fiscale_id.node_ref:
ref = self.liasse.node_ref.split(";")
query = """
SELECT * FROM crm:document
WHERE cmis:objectId = '%s'
""" % (
ref[0],
)
else:
query = """ query = """
SELECT * FROM crm:document as d SELECT * FROM crm:document as d
JOIN crm:organisme as o ON d.cmis:objectId = o.cmis:objectId JOIN crm:organisme as o ON d.cmis:objectId = o.cmis:objectId
......
# © 2020 Le Filament (<http://www.le-filament.com>) # © 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo import _, exceptions, fields, models from odoo import _, exceptions, fields, models
_logger = logging.getLogger(__name__)
class ListeMinistereInovatic(models.Model): class ListeMinistereInovatic(models.Model):
_inherit = "scop.liste.ministere" _inherit = "scop.liste.ministere"
...@@ -14,7 +18,7 @@ class ListeMinistereInovatic(models.Model): ...@@ -14,7 +18,7 @@ class ListeMinistereInovatic(models.Model):
last_job_queue_date_sync = fields.Datetime(related="last_job_queue.date_sync") last_job_queue_date_sync = fields.Datetime(related="last_job_queue.date_sync")
# ------------------------------------------------------ # ------------------------------------------------------
# BUTTON functions # Button functions
# ------------------------------------------------------ # ------------------------------------------------------
def inovatic_treatment(self): def inovatic_treatment(self):
liasse_id = self.create_liasse_fiscale() liasse_id = self.create_liasse_fiscale()
...@@ -47,3 +51,22 @@ class ListeMinistereInovatic(models.Model): ...@@ -47,3 +51,22 @@ class ListeMinistereInovatic(models.Model):
raise exceptions.UserError( raise exceptions.UserError(
_("Il n'y a pas de Liasse correspondante dans Alfresco") _("Il n'y a pas de Liasse correspondante dans Alfresco")
) )
# ------------------------------------------------------
# Inherit parent
# ------------------------------------------------------
def action_completed(self):
"""
Hérite la fonction parente pour envoyer autmatiquement la liasse à Inovatic
si cette liasse existe et si elle n'a pas déjà été chargée lorsque la coop
valide le dossier
"""
if (
self.scop_liasse_fiscale_id
and not self.scop_liasse_fiscale_id.source == "inovatic_api"
):
try:
self.scop_liasse_ficale_id.inovatic_treatment()
except Exception as e:
_logger.error(e)
super().action_completed()
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_load_xml_liasse,access_load_xml_liasse,model_load_xml_liasse,base.group_user,1,1,1,1
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<button <button
class="btn btn-sm btn-primary" class="btn btn-sm btn-primary"
name="load_liasse" name="load_liasse"
string="Cherger une liasse XML" string="Charger une liasse XML"
type="object" type="object"
confirm="Êtes-vous sûr(e) de vouloir charger ce fichier ?" confirm="Êtes-vous sûr(e) de vouloir charger ce fichier ?"
/> />
......
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class ScopLoadLiasseWizard(models.TransientModel):
_inherit = "scop.load.liasse.wizard"
# ------------------------------------------------------
# Inherit parent
# ------------------------------------------------------
def load_liasse(self):
super().load_liasse()
if not self.liasse_id.liste_ministere_id:
# LM d'inscription ou de renouvellement liées à la coop
lm_ids = self.liasse_id.partner_id.liste_ministere_ids.filtered(
lambda lm: lm.type_lm != "survey_adjust"
)
if lm_ids:
lm_type = "renew"
else:
lm_type = "subscribe"
# LM sur l'année N+1 de la liasse
lm_id = lm_ids.filtered(lambda lm: lm.year == str(self.liasse_id.year + 1))
if not lm_id:
# Création de la LM si elle n'existe pas
new_lm = lm_id.create_folder(
partner_id=self.liasse_id.partner_id,
year=self.liasse_id.year + 1,
lm_type=lm_type,
)
lm_id = lm_id.browse(new_lm)
# Mise à jour de la LM avec les valeurs de la liasse et de la file d'attente
lm_id.update(
{
"scop_liasse_fiscale_id": self.liasse_id.id,
"last_job_queue": self.job_queue_id.id,
}
)
else:
self.liasse_id.liste_ministere_id.update(
{
"scop_liasse_fiscale_id": self.liasse_id.id,
"last_job_queue": self.job_queue_id.id,
}
)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter