Skip to content
Extraits de code Groupes Projets
Valider 41e477ac rédigé par Julien - Le Filament's avatar Julien - Le Filament Validation de Rémi - Le Filament
Parcourir les fichiers

[UPD] add batch updated project/event

parent a6a0d962
Branches
Aucune étiquette associée trouvée
1 requête de fusion!1[UPD] add batch updated project/event
......@@ -4,7 +4,7 @@ env:
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions:
ecmaVersion: 2017
ecmaVersion: 2019
overrides:
- files:
......@@ -22,6 +22,7 @@ globals:
odoo: readonly
openerp: readonly
owl: readonly
luxon: readonly
# Styling is handled by Prettier, so we only need to enable AST rules;
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
......
[flake8]
max-line-length = 88
max-complexity = 16
# B = bugbear
# B9 = bugbear opinionated (incl line length)
select = C,E,F,W,B,B9
# E203: whitespace before ':' (black behaviour)
# E501: flake8 line length (covered by bugbear B950)
# W503: line break before binary operator (black behaviour)
ignore = E203,E501,W503
per-file-ignores=
__init__.py:F401
......@@ -3,6 +3,7 @@ __pycache__/
*.py[cod]
/.venv
/.pytest_cache
/.ruff_cache
# C extensions
*.so
......@@ -15,7 +16,6 @@ build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
......@@ -24,6 +24,7 @@ var/
.installed.cfg
*.egg
*.eggs
.copier-answers.yml
# Installer logs
pip-log.txt
......
[settings]
; see https://github.com/psf/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
known_odoo=odoo
known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
ensure_newline_before_comments = True
......@@ -12,6 +12,10 @@ exclude: |
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
......@@ -33,27 +37,26 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: ab1d7f6
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://le-filament.com"]
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
- id: oca-gen-addon-readme
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.3.0
- --addons-dir=.
- --branch=14.0
- --org-name=lefilament
- --repo-name=template_module
- --if-source-changed
- --keep-source-digest
- --convert-fragments-to-markdown
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
hooks:
- id: black
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks:
......@@ -100,20 +103,12 @@ repos:
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
hooks:
......
[MASTER]
load-plugins=pylint_odoo
score=n
......@@ -73,6 +75,7 @@ enable=anomalous-backslash-in-string,
invalid-commit,
missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
......
[MASTER]
load-plugins=pylint_odoo
score=n
......
fix = true
[lint]
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
]
exclude = ["setup/*"]
[format]
exclude = ["setup/*"]
[per-file-ignores]
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
"__manifest__.py" = ["B018"] # useless expression
[isort]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]
[isort.sections]
"odoo" = ["odoo"]
"odoo-addons" = ["odoo.addons"]
[mccabe]
max-complexity = 16
......@@ -9,7 +9,6 @@ from odoo.addons.portal.controllers.portal import CustomerPortal
class EventCustomerPortal(CustomerPortal):
MANDATORY_BILLING_FIELDS = ["firstname", "lastname", "email", "name"]
OPTIONAL_BILLING_FIELDS = CustomerPortal.OPTIONAL_BILLING_FIELDS + [
"phone",
......@@ -37,7 +36,8 @@ class EventCustomerPortal(CustomerPortal):
("project_ids", "in", partner.parent_id.ids),
("stage_id", "=", stage_announced),
]
).sorted(key="date_begin", reverse=False)
)
.sorted(key="date_begin", reverse=False)
)
event_past_ids = (
request.env["event.registration"]
......@@ -114,9 +114,7 @@ class EventCustomerPortal(CustomerPortal):
stage_done = request.env.ref("event.event_stage_done")
event_sudo = request.env["event.event"].sudo().browse(event_id)
valid_ids = event_sudo.provider_id.ids + event_sudo.project_ids.ids
values = {
"title": event_sudo.name + " | Alter'Incub AURA"
}
values = {"title": event_sudo.name + " | Alter'Incub AURA"}
if event_sudo.stage_id not in (stage_announced, stage_done):
return request.redirect("/my")
if partner.parent_id.id in valid_ids:
......@@ -141,9 +139,7 @@ class EventCustomerPortal(CustomerPortal):
return request.redirect("/my")
order_sudo = request.env["alterincub.order"].sudo().browse(order_id)
values = {
"title": "Commande %s | Alter'Incub AURA" % order_sudo.name
}
values = {"title": "Commande %s | Alter'Incub AURA" % order_sudo.name}
if partner.parent_id == order_sudo.partner_id and partner.is_admin_contact:
values["event"] = order_sudo
......@@ -194,8 +190,8 @@ class EventCustomerPortal(CustomerPortal):
@http.route(["/my/event/subscribe/"], type="json", auth="user", website=True)
def event_subscribe_modal(self, event):
"""
Vérifie si le porteur de projet peut s'inscrire à la journée, l'inscrit à la journée
et renvoie la modale de validation
Vérifie si le porteur de projet peut s'inscrire à la journée, l'inscrit à la
journée et renvoie la modale de validation
"""
try:
partner = request.env.user.partner_id
......@@ -218,9 +214,9 @@ class EventCustomerPortal(CustomerPortal):
if event_sudo.seats_by_project > 0:
# Vérifie que le nombre d'inscrits du même projet ne dépasse pas 2
project_registered = event_sudo.registration_ids.mapped("partner_id").filtered(
lambda p: p.parent_id == request.env.user.partner_id.parent_id
)
project_registered = event_sudo.registration_ids.mapped(
"partner_id"
).filtered(lambda p: p.parent_id == request.env.user.partner_id.parent_id)
# seats_by_project
if len(project_registered) >= event_sudo.seats_by_project:
values["event"] = False
......@@ -248,8 +244,8 @@ class EventCustomerPortal(CustomerPortal):
@http.route(["/my/event/unsubscribe/"], type="json", auth="user", website=True)
def event_unsubscribe_modal(self, event):
"""
Vérifie si le porteur de projet peut s'inscrire à la journée, l'inscrit à la journée
et renvoie la modale de validation
Vérifie si le porteur de projet peut s'inscrire à la journée, l'inscrit à la
journée et renvoie la modale de validation
"""
try:
partner = request.env.user.partner_id
......
......@@ -187,6 +187,7 @@ class EventEvent(models.Model):
# send invitation
if incubated.email:
# ruff: noqa: B023
events = self.filtered(lambda p: incubated.parent_id in p.project_ids)
event_template.with_context(events=events).send_mail(incubated.id)
# update events stage
......@@ -207,6 +208,10 @@ class EventEvent(models.Model):
firstname=partner.firstname, recipient_id=partner.id
).send_mail(self.id)
def action_update_invited_projects(self):
for event in self:
event.update_event_projects()
def action_re_plan_event(self):
self.ensure_one()
self.stage_id = self.old_stage_id
......@@ -215,7 +220,8 @@ class EventEvent(models.Model):
def update_event_projects(self):
"""
Get all existing projects and adds coressponding projects
domain = (same program_id, state="1_incub", area_id in area_ids or all if "Distanciel")
domain = (same program_id, state="1_incub", area_id in area_ids
or all if "Distanciel")
"""
self.ensure_one()
all_areas_id = self.env.ref("alterincub_partner.alterincub_area_all")
......
......@@ -45,7 +45,7 @@
}
.event_list_template {
background-color: #fff;
border: 1px solid rgba(0,0,0,.125);
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 5px;
padding: 0.5rem 15px;
margin-bottom: 2px;
......
......@@ -5,7 +5,6 @@ odoo.define("alterincub_event.CalendarModel", function (require) {
"use strict";
var calendarModel = require("web.CalendarModel");
var session = require("web.session");
calendarModel.include({
/**
......
......@@ -27,7 +27,7 @@ odoo.define("alterincub_event.event_registration", function (require) {
_onSubscribe: function (ev) {
ev.preventDefault();
ev.stopPropagation();
const event_id = parseInt(ev.target.dataset.event);
const event_id = parseInt(ev.target.dataset.event, 10);
return ajax
.jsonRpc("/my/event/subscribe/", "call", {event: event_id})
.then(function (modal) {
......@@ -47,7 +47,7 @@ odoo.define("alterincub_event.event_registration", function (require) {
_onUnSubscribe: function (ev) {
ev.preventDefault();
ev.stopPropagation();
const event_id = parseInt(ev.target.dataset.event);
const event_id = parseInt(ev.target.dataset.event, 10);
return ajax
.jsonRpc("/my/event/unsubscribe/", "call", {event: event_id})
.then(function (modal) {
......
......@@ -3,6 +3,17 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="action_updated_invited_projects" model="ir.actions.server">
<field name="name">Mettre à jour les projets invités</field>
<field name="model_id" ref="alterincub_event.model_event_event" />
<field name="binding_model_id" ref="alterincub_event.model_event_event" />
<field name="state">code</field>
<field name="code">
action = records.action_update_invited_projects()
</field>
</record>
<!-- Search view -->
<record id="view_event_search_inherit" model="ir.ui.view">
<field name="name">event.event.search</field>
......
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