From 174aabfbbb47ef73423bc04d27bd4b71949f2d83 Mon Sep 17 00:00:00 2001 From: jscampucci Date: Mon, 15 Sep 2025 12:58:03 +0200 Subject: [PATCH] [CLN] global : full pre-commit & ruff lint --- .editorconfig | 2 +- .eslintrc.yml | 2 +- .pre-commit-config.yaml | 2 +- .prettierrc.yml | 2 +- .pylintrc | 2 +- .pylintrc-mandatory | 2 +- .../__init__.py | 2 +- .../__manifest__.py | 20 +-- .../models/__init__.py | 2 +- .../models/account_move.py | 5 +- .../models/event_registration.py | 40 +++--- .../models/event_registration_financier.py | 48 ++++--- .../models/sale_order.py | 54 +++++--- .../security/ir.model.access.csv | 4 +- .../views/account_move_views.xml | 6 +- .../views/event_registration_views.xml | 36 +++-- .../views/sale_order_views.xml | 2 +- event_mail_attachment/__init__.py | 2 +- event_mail_attachment/__manifest__.py | 11 +- event_mail_attachment/models/__init__.py | 2 +- event_mail_attachment/models/mail_template.py | 78 ++++++----- .../views/mail_template_views.xml | 4 +- event_mail_manual/__init__.py | 2 +- event_mail_manual/__manifest__.py | 11 +- event_mail_manual/models/__init__.py | 2 +- event_mail_manual/models/event_mail.py | 74 ++++++---- event_mail_manual/views/event_event_views.xml | 47 +++++-- event_sequence/__init__.py | 2 +- event_sequence/__manifest__.py | 18 +-- event_sequence/models/__init__.py | 2 +- event_sequence/models/event_event.py | 9 +- event_sequence/models/event_sequence.py | 2 +- event_sequence/models/event_track.py | 24 ++-- event_sequence/security/ir.model.access.csv | 2 +- event_sequence/views/event_event_views.xml | 10 +- event_sequence/views/event_sequence_menu.xml | 8 +- event_sequence/views/event_sequence_views.xml | 4 +- event_sequence/views/event_track_views.xml | 130 +++++++++++++----- event_speaker/__init__.py | 2 +- event_speaker/__manifest__.py | 10 +- event_speaker/models/__init__.py | 2 +- event_speaker/models/event_track.py | 2 +- event_speaker/views/event_track_views.xml | 4 +- event_track_calendar_event/__init__.py | 2 +- event_track_calendar_event/__manifest__.py | 12 +- event_track_calendar_event/models/__init__.py | 2 +- .../models/calendar_event.py | 12 +- .../models/event_event.py | 13 +- .../models/event_registration.py | 17 ++- .../models/event_track.py | 71 ++++++---- .../views/event_track_views.xml | 8 +- .../__init__.py | 2 +- .../__manifest__.py | 10 +- .../models/__init__.py | 2 +- .../models/calendar_event.py | 11 +- .../models/event_track.py | 18 +-- .../views/event_track_views.xml | 23 +++- .../__init__.py | 2 +- .../__manifest__.py | 13 +- .../models/__init__.py | 2 +- .../models/event_track.py | 72 ++++++---- .../models/event_track_location.py | 23 ++-- .../views/event_track_location_views.xml | 16 ++- .../views/event_track_views.xml | 27 ++-- event_track_copy/__init__.py | 2 +- event_track_copy/__manifest__.py | 10 +- event_track_copy/models/__init__.py | 2 +- event_track_copy/models/event_event.py | 9 +- event_track_copy/models/event_track.py | 8 +- event_type_button_box/__manifest__.py | 8 +- .../views/event_type_views.xml | 10 +- 71 files changed, 673 insertions(+), 429 deletions(-) diff --git a/.editorconfig b/.editorconfig index 290f538..bfd7ac5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,4 +17,4 @@ end_of_line = unset indent_size = unset indent_style = unset insert_final_newline = false -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false diff --git a/.eslintrc.yml b/.eslintrc.yml index 88e125a..fed88d7 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -185,4 +185,4 @@ rules: requireReturnDescription: false requireReturnType: false valid-typeof: warn - yoda: warn \ No newline at end of file + yoda: warn diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a21cea..c7de03e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -143,4 +143,4 @@ repos: verbose: true - id: pylint_odoo args: - - --rcfile=.pylintrc-mandatory \ No newline at end of file + - --rcfile=.pylintrc-mandatory diff --git a/.prettierrc.yml b/.prettierrc.yml index 6173d54..5b6d4b3 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -5,4 +5,4 @@ printWidth: 88 proseWrap: always semi: true trailingComma: "es5" -xmlWhitespaceSensitivity: "strict" \ No newline at end of file +xmlWhitespaceSensitivity: "strict" diff --git a/.pylintrc b/.pylintrc index 18cd17c..652a781 100644 --- a/.pylintrc +++ b/.pylintrc @@ -120,4 +120,4 @@ enable=anomalous-backslash-in-string, [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} output-format=colorized -reports=no \ No newline at end of file +reports=no diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 769af28..14ca356 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -95,4 +95,4 @@ enable=anomalous-backslash-in-string, [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} output-format=colorized -reports=no \ No newline at end of file +reports=no diff --git a/event_generate_quotation_from_registration/__init__.py b/event_generate_quotation_from_registration/__init__.py index 9a7e03e..0650744 100644 --- a/event_generate_quotation_from_registration/__init__.py +++ b/event_generate_quotation_from_registration/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/event_generate_quotation_from_registration/__manifest__.py b/event_generate_quotation_from_registration/__manifest__.py index dfbc36b..1ffc260 100644 --- a/event_generate_quotation_from_registration/__manifest__.py +++ b/event_generate_quotation_from_registration/__manifest__.py @@ -5,18 +5,18 @@ "version": "16.0.1.0.0", "license": "AGPL-3", "author": "Elabore", - "website": "https://www.elabore.coop", + "website": "https://github.com/elabore-coop/event-tools", "category": "", - 'summary': 'Generate quotation from event registration', - 'description': """ - Generate quotation from event registration : + "summary": "Generate quotation from event registration", + "description": """ + Generate quotation from event registration : """, "depends": ["event_sale"], - "data": [ - 'security/ir.model.access.csv', - 'views/event_registration_views.xml', - 'views/sale_order_views.xml', - 'views/account_move_views.xml', - ], + "data": [ + "security/ir.model.access.csv", + "views/event_registration_views.xml", + "views/sale_order_views.xml", + "views/account_move_views.xml", + ], "installable": True, } diff --git a/event_generate_quotation_from_registration/models/__init__.py b/event_generate_quotation_from_registration/models/__init__.py index f035bf8..aa40f35 100644 --- a/event_generate_quotation_from_registration/models/__init__.py +++ b/event_generate_quotation_from_registration/models/__init__.py @@ -1,4 +1,4 @@ from . import event_registration from . import event_registration_financier from . import sale_order -from . import account_move \ No newline at end of file +from . import account_move diff --git a/event_generate_quotation_from_registration/models/account_move.py b/event_generate_quotation_from_registration/models/account_move.py index 86872c6..9087736 100644 --- a/event_generate_quotation_from_registration/models/account_move.py +++ b/event_generate_quotation_from_registration/models/account_move.py @@ -1,6 +1,7 @@ -from odoo import _, api, Command, fields, models +from odoo import fields, models + class AccountMove(models.Model): _inherit = "account.move" - event_registration_id = fields.Many2one('event.registration', string="Stagiaire") \ No newline at end of file + event_registration_id = fields.Many2one("event.registration", string="Stagiaire") diff --git a/event_generate_quotation_from_registration/models/event_registration.py b/event_generate_quotation_from_registration/models/event_registration.py index ec7e575..5e31e08 100644 --- a/event_generate_quotation_from_registration/models/event_registration.py +++ b/event_generate_quotation_from_registration/models/event_registration.py @@ -1,12 +1,17 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, api, Command import logging + +from odoo import api, fields, models + _logger = logging.getLogger(__name__) + class EventRegistration(models.Model): _inherit = "event.registration" - - financier_ids = fields.One2many('event.registration.financier', 'registration_id', string="Financements") + + financier_ids = fields.One2many( + "event.registration.financier", "registration_id", string="Financements" + ) def name_get(self): result = [] @@ -15,32 +20,35 @@ class EventRegistration(models.Model): name = f"{registration.partner_id.name} ({registration.event_id.name})" result.append((registration.id, name)) return result - + @api.depends("partner_id", "event_id") def _compute_display_name(self): for registration in self: if registration.partner_id and registration.event_id: - registration.display_name = f"{registration.partner_id.name} ({registration.event_id.name})" + registration.display_name = ( + f"{registration.partner_id.name} ({registration.event_id.name})" + ) else: - registration.display_name = super(EventRegistration, registration)._compute_display_name() - - + registration.display_name = super( + EventRegistration, registration + )._compute_display_name() def generate_quotation(self): for registration in self: for financier in registration.financier_ids: if not financier.quotation_id: so_values = financier.get_sale_order_values() - so_values['order_line'] = financier.get_sale_order_line_values() - sale_order = self.env['sale.order'].create(so_values) + so_values["order_line"] = financier.get_sale_order_line_values() + sale_order = self.env["sale.order"].create(so_values) financier.quotation_id = sale_order else: - order_lines = self.env['sale.order.line'].search([ - ('order_id','=',financier.quotation_id.id), - ('product_id','=',financier.get_product_id()), - ('state', '!=', 'done'), - ]) + order_lines = self.env["sale.order.line"].search( + [ + ("order_id", "=", financier.quotation_id.id), + ("product_id", "=", financier.get_product_id()), + ("state", "!=", "done"), + ] + ) if order_lines: order_lines[0].price_unit = financier.amount financier.quotation_id.write(financier.get_sale_order_values()) - \ No newline at end of file diff --git a/event_generate_quotation_from_registration/models/event_registration_financier.py b/event_generate_quotation_from_registration/models/event_registration_financier.py index 6299dae..c58445f 100644 --- a/event_generate_quotation_from_registration/models/event_registration_financier.py +++ b/event_generate_quotation_from_registration/models/event_registration_financier.py @@ -1,44 +1,52 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, api, Command import logging +from odoo import Command, fields, models from odoo.exceptions import UserError + _logger = logging.getLogger(__name__) + class EventRegistrationFinancier(models.Model): _name = "event.registration.financier" - _rec_name = 'financier_id' + _rec_name = "financier_id" company_id = fields.Many2one("res.company") - company_currency_id = fields.Many2one('res.currency', related="company_id.currency_id") - registration_id = fields.Many2one('event.registration') - quotation_id = fields.Many2one('sale.order', string="Devis") - financier_id = fields.Many2one('res.partner', string="Financeur", required=True) - terms = fields.Char('Modalités') - amount = fields.Monetary('Montant', currency_field="company_currency_id") + company_currency_id = fields.Many2one( + "res.currency", related="company_id.currency_id" + ) + registration_id = fields.Many2one("event.registration") + quotation_id = fields.Many2one("sale.order", string="Devis") + financier_id = fields.Many2one("res.partner", string="Financeur", required=True) + terms = fields.Char("Modalités") + amount = fields.Monetary("Montant", currency_field="company_currency_id") state = fields.Selection( - related='quotation_id.state', + related="quotation_id.state", string="Order Status", - copy=False, store=True, precompute=True) - + copy=False, + store=True, + precompute=True, + ) def get_product_id(self): if self.registration_id.event_ticket_id: return self.registration_id.event_ticket_id.product_id.id elif self.registration_id.event_id.event_ticket_ids: return self.registration_id.event_id.event_ticket_ids[0].product_id.id - raise UserError('Un ticket doit être défini dans la session de formation afin de générer le devis') + raise UserError( + "Un ticket doit être défini dans la session de formation afin de générer le devis" + ) def get_sale_order_values(self): return { - 'event_registration_id':self.registration_id.id, - 'partner_id':self.financier_id.id, + "event_registration_id": self.registration_id.id, + "partner_id": self.financier_id.id, } - + def get_sale_order_line_values(self): - return [Command.create({ - "price_unit": self.amount, - "product_id": self.get_product_id() - })] - + return [ + Command.create( + {"price_unit": self.amount, "product_id": self.get_product_id()} + ) + ] diff --git a/event_generate_quotation_from_registration/models/sale_order.py b/event_generate_quotation_from_registration/models/sale_order.py index 6e1f807..cb09385 100644 --- a/event_generate_quotation_from_registration/models/sale_order.py +++ b/event_generate_quotation_from_registration/models/sale_order.py @@ -1,39 +1,61 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, api, Command import logging + +from odoo import fields, models + _logger = logging.getLogger(__name__) + class SaleOrder(models.Model): _inherit = "sale.order" - event_registration_id = fields.Many2one('event.registration', string="Stagiaire") + event_registration_id = fields.Many2one("event.registration", string="Stagiaire") def _prepare_invoice(self): - """Copy event_registration_id to generated invoice """ - res = super(SaleOrder, self)._prepare_invoice() + Copy event_registration_id to generated invoice. + """ + res = super()._prepare_invoice() res["event_registration_id"] = self.event_registration_id.id return res def linked_to_registration(self): - return len(self.env['event.registration.financier'].search([('quotation_id','=',self.id)])) > 0 - - def action_confirm(self): - res = super(SaleOrder, self).action_confirm() + return ( + len( + self.env["event.registration.financier"].search( + [("quotation_id", "=", self.id)] + ) + ) + > 0 + ) - #if sale order is linked to event.registration.financier, don't open wizard - if isinstance(res, dict) and res.get('xml_id') == 'event_sale.action_sale_order_event_registration' and self.linked_to_registration(): + def action_confirm(self): + res = super().action_confirm() + + # if sale order is linked to event.registration.financier, don't open wizard + if ( + isinstance(res, dict) + and res.get("xml_id") == "event_sale.action_sale_order_event_registration" + and self.linked_to_registration() + ): return True return res - + + class SaleOrderLine(models.Model): _inherit = "sale.order.line" - - def _update_registrations(self, confirm=True, cancel_to_draft=False, registration_data=None, mark_as_paid=False): + + def _update_registrations( + self, + confirm=True, + cancel_to_draft=False, + registration_data=None, + mark_as_paid=False, + ): # bypass _update_registrations if order generated by event registration if self.order_id.linked_to_registration(): return - return super(SaleOrderLine, self)._update_registrations(confirm, cancel_to_draft, registration_data, mark_as_paid) - - \ No newline at end of file + return super()._update_registrations( + confirm, cancel_to_draft, registration_data, mark_as_paid + ) diff --git a/event_generate_quotation_from_registration/security/ir.model.access.csv b/event_generate_quotation_from_registration/security/ir.model.access.csv index 93c0a20..46787ec 100644 --- a/event_generate_quotation_from_registration/security/ir.model.access.csv +++ b/event_generate_quotation_from_registration/security/ir.model.access.csv @@ -1,2 +1,2 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_event_registration_financier,access.event.registration.financier,model_event_registration_financier,sales_team.group_sale_salesman,1,1,1,1 \ No newline at end of file +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_event_registration_financier,access.event.registration.financier,model_event_registration_financier,sales_team.group_sale_salesman,1,1,1,1 diff --git a/event_generate_quotation_from_registration/views/account_move_views.xml b/event_generate_quotation_from_registration/views/account_move_views.xml index 8365787..86208da 100644 --- a/event_generate_quotation_from_registration/views/account_move_views.xml +++ b/event_generate_quotation_from_registration/views/account_move_views.xml @@ -1,4 +1,4 @@ - + view.move.form.inherit.event.generate.quotation @@ -12,7 +12,9 @@ - view.out.invoice.tree.inherit.event.generate.quotation + view.out.invoice.tree.inherit.event.generate.quotation account.move diff --git a/event_generate_quotation_from_registration/views/event_registration_views.xml b/event_generate_quotation_from_registration/views/event_registration_views.xml index 095df3b..74d22b8 100644 --- a/event_generate_quotation_from_registration/views/event_registration_views.xml +++ b/event_generate_quotation_from_registration/views/event_registration_views.xml @@ -1,26 +1,42 @@ - - - view.event.registration.form.event.generate.quotation.from.registration - event.registration + + + view.event.registration.form.event.generate.quotation.from.registration + event.registration - - - + + + -