diff --git a/README.rst b/README.rst old mode 100755 new mode 100644 index 327a8f4f95f00cd6aae3acee8b27cc389bb1ada4..2fc370882ff2a5099d9be409f8933363a0595242 --- a/README.rst +++ b/README.rst @@ -36,4 +36,3 @@ Maintainer :target: https://le-filament.com This module is maintained by Le Filament - diff --git a/__init__.py b/__init__.py index 62a105e4211523554a7ffe95a3c65a6542ab18a3..11671ffaead3d4042e93185d6ee1d4b81a032dd5 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,4 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import models -from . import wizard \ No newline at end of file +from . import models, wizard diff --git a/__manifest__.py b/__manifest__.py old mode 100755 new mode 100644 index 13dbee2e63b3bc5b634f1d0bc6f49a3c8c7e8a7d..24d4b8f0842b872d622086c9f6acc0d2ef36ed8d --- a/__manifest__.py +++ b/__manifest__.py @@ -1,37 +1,35 @@ { - 'name': "ACC - Gestion de la facturation", - 'summary': "Gestion de la facturation", - 'author': "Le Filament", - 'website': "https://www.le-filament.com", - 'version': '14.0.1.0.1', - 'license': "AGPL-3", - 'depends': [ - 'acc_operation', 'portal', 'web_widget_x2many_2d_matrix' - ], - 'data': [ + "name": "ACC - Gestion de la facturation", + "summary": "Gestion de la facturation", + "author": "Le Filament", + "website": "https://www.le-filament.com", + "version": "14.0.1.0.1", + "license": "AGPL-3", + "depends": ["acc_operation", "portal", "web_widget_x2many_2d_matrix"], + "data": [ "security/ir.model.access.csv", # datas - 'data/data.xml', + "data/data.xml", # wizard - 'wizard/acc_sale_price_wizard_views.xml', - 'wizard/acc_sale_price_surplus_wizard_views.xml', - 'wizard/acc_account_wizard_views.xml', - 'wizard/acc_account_surplus_wizard_views.xml', + "wizard/acc_sale_price_wizard_views.xml", + "wizard/acc_sale_price_surplus_wizard_views.xml", + "wizard/acc_account_wizard_views.xml", + "wizard/acc_account_surplus_wizard_views.xml", # views - 'views/acc_sale_price_views.xml', - 'views/acc_operation_views.xml', - 'views/acc_counter_views.xml', - 'views/acc_account_views.xml', - 'views/res_partner_views.xml', + "views/acc_sale_price_views.xml", + "views/acc_operation_views.xml", + "views/acc_counter_views.xml", + "views/acc_account_views.xml", + "views/res_partner_views.xml", # views menu - 'views/menu_views.xml', - 'report/report_template.xml', - 'report/account_template.xml', - 'report/account_report.xml', + "views/menu_views.xml", + "report/report_template.xml", + "report/account_template.xml", + "report/account_report.xml", ], - 'qweb': [ + "qweb": [ # "static/src/xml/*.xml", ], - 'installable': True, - 'auto_install': False, + "installable": True, + "auto_install": False, } diff --git a/data/data.xml b/data/data.xml index f8316324135b6157a99cb89cf1d95dab78fd182b..0581bc9acac6635bfe15264dfeb07ac73b887b06 100644 --- a/data/data.xml +++ b/data/data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data noupdate="1"> <!-- diff --git a/models/__init__.py b/models/__init__.py index b8f54228fdd1bd555b5a2ecd79d67e3ae71dc4e5..7545f9fa668f82c1097f3e5b3db18fe1ebf09f0b 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -5,4 +5,4 @@ from . import acc_sale_price from . import acc_operation from . import acc_account from . import acc_counter -from . import res_partner \ No newline at end of file +from . import res_partner diff --git a/models/acc_account.py b/models/acc_account.py index a62d04725e20cfdb8919803ac7ffe2c7246cca6b..03bef89ad9b4f0793964c9a9e64fbd60a301ba5d 100644 --- a/models/acc_account.py +++ b/models/acc_account.py @@ -1,12 +1,12 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import api, fields, models class AccAccount(models.Model): _name = "acc.account" - _inherit = ['portal.mixin', 'mail.thread'] + _inherit = ["portal.mixin", "mail.thread"] _description = "Factures" _order = "date desc, name desc, id desc" @@ -23,31 +23,23 @@ class AccAccount(models.Model): store=True, index=True, tracking=True, - default='/') + default="/", + ) date = fields.Date( string="Date", required=True, index=True, readonly=True, copy=False, - default=fields.Date.context_today - ) - start_date = fields.Date( - string="Date de début", - default=fields.Date.context_today - ) - end_date = fields.Date( - string="Date de fin", - default=fields.Date.context_today + default=fields.Date.context_today, ) + start_date = fields.Date(string="Date de début", default=fields.Date.context_today) + end_date = fields.Date(string="Date de fin", default=fields.Date.context_today) currency_id = fields.Many2one( - "res.currency", - string="Devise", - required=True, - default=_get_default_currency_id) + "res.currency", string="Devise", required=True, default=_get_default_currency_id + ) is_account_buyer = fields.Boolean("Est une facture Surplus") - acc_operation_id = fields.Many2one( - "acc.operation", string="Opération") + acc_operation_id = fields.Many2one("acc.operation", string="Opération") pmo_id = fields.Many2one( "res.partner", string="PMO", @@ -55,68 +47,63 @@ class AccAccount(models.Model): ) acc_injection_id = fields.Many2one( "acc.counter", - domain=[("is_injection", '=', True)], + domain=[("is_injection", "=", True)], string="Point d'injection", - ondelete="cascade" + ondelete="cascade", ) producer_id = fields.Many2one( comodel_name="res.partner", related="acc_injection_id.partner_id", - string="Producteur") - is_tva = fields.Boolean("Assujetti à la TVA", related='producer_id.is_tva') - tax_id = fields.Many2one( - "acc.account.tax", - "Taxe", related='producer_id.tax_id') + string="Producteur", + ) + is_tva = fields.Boolean("Assujetti à la TVA", related="producer_id.is_tva") + tax_id = fields.Many2one("acc.account.tax", "Taxe", related="producer_id.tax_id") acc_delivery_id = fields.Many2one( "acc.counter", - domain=[("is_delivery", '=', True)], + domain=[("is_delivery", "=", True)], string="Point de soutirage", - ondelete="cascade" + ondelete="cascade", ) consumer_id = fields.Many2one( comodel_name="res.partner", related="acc_delivery_id.partner_id", - string="Consommateur") + string="Consommateur", + ) buyer_id = fields.Many2one( comodel_name="res.partner", - domain=[("is_buyer_surplus", '=', True)], + domain=[("is_buyer_surplus", "=", True)], ondelete="cascade", - string="Acheteur") + string="Acheteur", + ) line_ids = fields.One2many( "acc.account.line", "acc_account_id", string="Lignes de facturation mensuelle", - copy=True) + copy=True, + ) amount_untaxed = fields.Monetary( string="Montant H.T.", store=True, readonly=True, tracking=True, - compute='_compute_amount') + compute="_compute_amount", + ) amount_tax = fields.Monetary( - string="Taxe", - store=True, - readonly=True, - compute='_compute_amount') + string="Taxe", store=True, readonly=True, compute="_compute_amount" + ) amount_tax_tcfe = fields.Monetary( - string="Taxes CPSE/TCF", - store=True, - readonly=True, - compute='_compute_amount') + string="Taxes CPSE/TCF", store=True, readonly=True, compute="_compute_amount" + ) amount_total = fields.Monetary( - string="Total", - store=True, - readonly=True, - compute='_compute_amount') - # inverse='_inverse_amount_total') - price_kwh = fields.Float( - "Prix de l'électricité au kWh", digits="Sale Price") + string="Total", store=True, readonly=True, compute="_compute_amount" + ) + # inverse='_inverse_amount_total') + price_kwh = fields.Float("Prix de l'électricité au kWh", digits="Sale Price") power_cons = fields.Float("Consommation locale (index Enedis)") url = fields.Char("URL", compute="_compute_url", store=True) tax_tcfe = fields.Float( - "Taxes CPSE/TCF (en €/kWh)", - digits="Sale Price", - default=0.105) + "Taxes CPSE/TCF (en €/kWh)", digits="Sale Price", default=0.105 + ) @api.model_create_multi def create(self, vals_list): @@ -125,22 +112,30 @@ class AccAccount(models.Model): if res.is_account_buyer: seq = str(rec.acc_injection_id.acc_account_surplus_count).zfill(3) rec.name = ( - rec.acc_operation_id.name + "-" + rec.acc_injection_id.name + "-" + seq + rec.acc_operation_id.name + + "-" + + rec.acc_injection_id.name + + "-" + + seq ) else: seq = str(rec.acc_injection_id.acc_account_injection_count).zfill(3) rec.name = ( - rec.acc_operation_id.name + "-" + rec.acc_injection_id.name + "-" + seq + rec.acc_operation_id.name + + "-" + + rec.acc_injection_id.name + + "-" + + seq ) return res @api.depends( - 'line_ids', - 'line_ids.price_total', - 'line_ids.price_unit', - 'line_ids.quantity', - 'tax_tcfe' - ) + "line_ids", + "line_ids.price_total", + "line_ids.price_unit", + "line_ids.quantity", + "tax_tcfe", + ) def _compute_amount(self): for move in self: total_tax = 0.0 @@ -153,7 +148,7 @@ class AccAccount(models.Model): tot_qty += line.quantity if move.is_tva and move.tax_id: - total_tax = ((total * move.tax_id.amount) / 100) + total_tax = (total * move.tax_id.amount) / 100 if move.tax_tcfe > 0: amount_tax_tcfe = (tot_qty * move.tax_tcfe) / 100 @@ -165,7 +160,7 @@ class AccAccount(models.Model): def _compute_url(self): for account in self: - account.url = account.get_portal_url(report_type='pdf', download=True) + account.url = account.get_portal_url(report_type="pdf", download=True) class AccAccountLine(models.Model): @@ -175,45 +170,46 @@ class AccAccountLine(models.Model): acc_account_id = fields.Many2one( "acc.account", - string='Facture', + string="Facture", index=True, - required=True, readonly=True, auto_join=True, ondelete="cascade") - acc_account_name = fields.Char(string="Numéro", related="acc_account_id.name", store=True, index=True) + required=True, + readonly=True, + auto_join=True, + ondelete="cascade", + ) + acc_account_name = fields.Char( + string="Numéro", related="acc_account_id.name", store=True, index=True + ) acc_operation_id = fields.Many2one( "acc.operation", string="Opération", related="acc_account_id.acc_operation_id", - store=True + store=True, ) date = fields.Date( - related="acc_account_id.date", - store=True, - readonly=True, index=True, copy=False) - quantity = fields.Float( - string="Quantité", - default=1.0) - price_unit = fields.Float( - string="Prix unitaire", - digits="Sale Price") + related="acc_account_id.date", store=True, readonly=True, index=True, copy=False + ) + quantity = fields.Float(string="Quantité", default=1.0) + price_unit = fields.Float(string="Prix unitaire", digits="Sale Price") currency_id = fields.Many2one( - "res.currency", - string="Devise", - related="acc_account_id.currency_id" + "res.currency", string="Devise", related="acc_account_id.currency_id" ) price_total = fields.Monetary( string="Total", - store=True, readonly=True, + store=True, + readonly=True, currency_field="currency_id", - compute='_compute_amount') + compute="_compute_amount", + ) tax_id = fields.Many2one( - comodel_name="acc.account.tax", - string="Taxes", related='acc_account_id.tax_id') + comodel_name="acc.account.tax", string="Taxes", related="acc_account_id.tax_id" + ) start_date = fields.Date("Début de la période") end_date = fields.Date("Fin de la période") description = fields.Text("Description de la ligne") - is_tva = fields.Boolean(related='acc_account_id.is_tva') + is_tva = fields.Boolean(related="acc_account_id.is_tva") - @api.depends('quantity', 'price_unit') + @api.depends("quantity", "price_unit") def _compute_amount(self): for line in self: line.price_total = line.quantity * line.price_unit diff --git a/models/acc_counter.py b/models/acc_counter.py index 023f0cd3f17d14bc327abd07f831f23e99ed4327..5f9d1738f1e2c723235a791cf83163e4635a74b2 100644 --- a/models/acc_counter.py +++ b/models/acc_counter.py @@ -1,28 +1,29 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import api, fields, models class AccCounter(models.Model): - _inherit = 'acc.counter' + _inherit = "acc.counter" # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ acc_account_surplus_ids = fields.One2many( - "acc.account", "acc_delivery_id", - domain=[('is_account_buyer', '=', True)], - string="Factures Surplus liées" + "acc.account", + "acc_delivery_id", + domain=[("is_account_buyer", "=", True)], + string="Factures Surplus liées", ) acc_account_delivery_ids = fields.One2many( - "acc.account", "acc_delivery_id", - string="Factures liées" + "acc.account", "acc_delivery_id", string="Factures liées" ) acc_account_injection_ids = fields.One2many( - "acc.account", "acc_injection_id", - domain=[('is_account_buyer', '=', False)], - string="Factures liées" + "acc.account", + "acc_injection_id", + domain=[("is_account_buyer", "=", False)], + string="Factures liées", ) acc_account_delivery_count = fields.Integer( compute="_compute_acc_account_count", string="Nombre de factures clients" @@ -31,9 +32,12 @@ class AccCounter(models.Model): compute="_compute_acc_account_count", string="Nombre de factures producteurs" ) acc_account_surplus_count = fields.Integer( - compute="_compute_acc_account_count", string="Nombre de factures surplus producteurs" + compute="_compute_acc_account_count", + string="Nombre de factures surplus producteurs", + ) + is_account_auto_activate = fields.Boolean( + "Facturation de l’autoconsommation automatisée" ) - is_account_auto_activate = fields.Boolean("Facturation de l’autoconsommation automatisée") is_account_surplus_activate = fields.Boolean("Facturation du surplus automatisée") # ------------------------------------------------------ @@ -54,11 +58,12 @@ class AccCounter(models.Model): [("acc_delivery_id", "=", res.id)] ) res.acc_account_injection_count = self.env["acc.account"].search_count( - [("acc_injection_id", "=", res.id), ('is_account_buyer', '=', False)] + [("acc_injection_id", "=", res.id), ("is_account_buyer", "=", False)] ) res.acc_account_surplus_count = self.env["acc.account"].search_count( - [("acc_injection_id", "=", res.id), ('is_account_buyer', '=', True)] + [("acc_injection_id", "=", res.id), ("is_account_buyer", "=", True)] ) + # ------------------------------------------------------ # Onchange / Constraints # ------------------------------------------------------ @@ -75,9 +80,7 @@ class AccCounter(models.Model): action = self.env["ir.actions.actions"]._for_xml_id( "acc_account.action_acc_account" ) - action["domain"] = [ - ("acc_injection_id", "=", self.id) - ] + action["domain"] = [("acc_injection_id", "=", self.id)] return action def action_view_acc_delivery_accounts(self): @@ -85,10 +88,9 @@ class AccCounter(models.Model): action = self.env["ir.actions.actions"]._for_xml_id( "acc_account.action_acc_account" ) - action["domain"] = [ - ("acc_delivery_id", "=", self.id) - ] + action["domain"] = [("acc_delivery_id", "=", self.id)] return action + # ------------------------------------------------------ # Business methods # ------------------------------------------------------ diff --git a/models/acc_operation.py b/models/acc_operation.py index e7fc362ca2f8096d4b2692a297f960db2b919615..3f2e2f9afde3b0531500aebf67685b6b74a87108 100644 --- a/models/acc_operation.py +++ b/models/acc_operation.py @@ -1,40 +1,42 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api -from odoo.tools import date_utils - from dateutil.relativedelta import relativedelta +from odoo import api, fields, models +from odoo.tools import date_utils + class AccOperation(models.Model): - _inherit = 'acc.operation' + _inherit = "acc.operation" # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ is_account_active = fields.Boolean("Facturation activée") - acc_sale_price_ids = fields.One2many( - "acc.sale.price", "acc_operation_id") + acc_sale_price_ids = fields.One2many("acc.sale.price", "acc_operation_id") acc_sale_price_surplus_ids = fields.One2many( - "acc.sale.price.buyer", "acc_operation_id") + "acc.sale.price.buyer", "acc_operation_id" + ) acc_account_ids = fields.One2many( - "acc.account", "acc_operation_id", + "acc.account", + "acc_operation_id", domain=[("is_account_buyer", "=", False)], - string="Factures" + string="Factures", ) acc_account_surplus_ids = fields.One2many( - "acc.account", "acc_operation_id", + "acc.account", + "acc_operation_id", domain=[("is_account_buyer", "=", True)], - string="Factures Surplus" - ) - acc_account_line_ids = fields.One2many( - "acc.account.line", "acc_operation_id" + string="Factures Surplus", ) + acc_account_line_ids = fields.One2many("acc.account.line", "acc_operation_id") acc_account_count = fields.Integer( - string="Nombre de factures", compute="_compute_acc_account_count") + string="Nombre de factures", compute="_compute_acc_account_count" + ) tax_tcfe = fields.Float( - "Taxes CPSE/TCF (en €/kWh)", digits="Sale Price", default=0.105) + "Taxes CPSE/TCF (en €/kWh)", digits="Sale Price", default=0.105 + ) # ------------------------------------------------------ # SQL Constraints @@ -51,6 +53,7 @@ class AccOperation(models.Model): def _compute_acc_account_count(self): for res in self: res.acc_account_count = len(res.acc_account_ids) + # ------------------------------------------------------ # Onchange / Constraints # ------------------------------------------------------ @@ -67,47 +70,58 @@ class AccOperation(models.Model): action = self.env["ir.actions.actions"]._for_xml_id( "acc_account.action_acc_account" ) - action["domain"] = [ - ("acc_operation_id", "=", self.id) - ] + action["domain"] = [("acc_operation_id", "=", self.id)] return action def get_power_by_cons(self, acc_delivery_id, date_start, date_end): """ - Fonction retournant l'énergie consommée d'un consommateur donné pour une période donnée. + Fonction retournant l'énergie consommée d'un consommateur donné pour une + période donnée. :param acc_delivery_id: consommateur date_start: date début date_end: date de fin :return: un dictionnaire de valeurs (consommateur + power + type) """ - power_tab_by_cons = self.env['acc.enedis.cdc'].read_group( - [('acc_operation_id', '=', self.id), - ('acc_counter_id', '=', acc_delivery_id.id), - ('date_slot', '>=', date_start), - ('date_slot', '<=', date_end), - ('comp_data_type', '=', 'cons')], - ['power', 'acc_operation_id', 'date_slot'], - ['acc_counter_id'], orderby='acc_counter_id', lazy=False) + power_tab_by_cons = self.env["acc.enedis.cdc"].read_group( + [ + ("acc_operation_id", "=", self.id), + ("acc_counter_id", "=", acc_delivery_id.id), + ("date_slot", ">=", date_start), + ("date_slot", "<=", date_end), + ("comp_data_type", "=", "cons"), + ], + ["power", "acc_operation_id", "date_slot"], + ["acc_counter_id"], + orderby="acc_counter_id", + lazy=False, + ) return power_tab_by_cons def get_power_by_prod(self, acc_injection_id, date_start, date_end): """ - Fonction retournant l'énergie produite et en surplus d'un producteur donné pour une période donnée. + Fonction retournant l'énergie produite et en surplus d'un producteur donné + pour une période donnée. :param acc_injection_id: producteur date_start: date début date_end: date de fin :return: un dictionnaire de valeurs (producteur + power + type) """ - power_tab_by_prod = self.env['acc.enedis.cdc'].read_group( - [('acc_operation_id', '=', self.id), - ('acc_counter_id', '=', acc_injection_id.id), - ('date_slot', '>=', date_start), - ('date_slot', '<=', date_end), - '|', ('comp_data_type', '=', 'prod'), - ('comp_data_type', '=', 'surplus')], - ['power', 'acc_operation_id', 'date_slot'], - ['comp_data_type'], orderby='comp_data_type', lazy=False) + power_tab_by_prod = self.env["acc.enedis.cdc"].read_group( + [ + ("acc_operation_id", "=", self.id), + ("acc_counter_id", "=", acc_injection_id.id), + ("date_slot", ">=", date_start), + ("date_slot", "<=", date_end), + "|", + ("comp_data_type", "=", "prod"), + ("comp_data_type", "=", "surplus"), + ], + ["power", "acc_operation_id", "date_slot"], + ["comp_data_type"], + orderby="comp_data_type", + lazy=False, + ) return power_tab_by_prod @@ -116,56 +130,66 @@ class AccOperation(models.Model): Fonction permettant de générer les factures à une date donné. Création des factures + Création des lignes de facture associées. :param date_month: date à laquelle on lance la facture - account_periodicity: périodicité (1 pour mois, 3 pour trimestre, 6 pour semestre, 12 pour année) + account_periodicity: périodicité (1 pour mois, 3 pour trimestre, + 6 pour semestre, 12 pour année) :return: """ account_list = [] - date_end = date_utils.end_of(date_month, 'month') + date_end = date_utils.end_of(date_month, "month") if account_periodicity == "1": - date_start = date_utils.start_of(date_month, 'month') + date_start = date_utils.start_of(date_month, "month") else: - date_start = date_end - relativedelta(months=int(account_periodicity)-1) - date_start = date_utils.start_of(date_start, 'month') + date_start = date_end - relativedelta(months=int(account_periodicity) - 1) + date_start = date_utils.start_of(date_start, "month") for acc_injection_id in self.acc_injection_ids: if acc_injection_id.is_account_auto_activate: for acc_delivery_id in self.acc_delivery_ids: - power_total = self.calc_power_by_cons_by_prod(acc_injection_id, acc_delivery_id, - date_start, date_end) - Account = self.env['acc.account'] - - acc_account = Account.create({ - 'acc_operation_id': self.id, - 'acc_injection_id': acc_injection_id.id, - 'acc_delivery_id': acc_delivery_id.id, - 'power_cons': power_total, - 'start_date': date_start, - 'end_date': date_end, - 'tax_tcfe': self.tax_tcfe, - }) - - interval_ids = self.env['acc.sale.price'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', acc_injection_id.id), - ('acc_delivery_id', '=', acc_delivery_id.id), - ('start_date', '<=', date_start), - ('end_date', '=', False) - ]) + power_total = self.calc_power_by_cons_by_prod( + acc_injection_id, acc_delivery_id, date_start, date_end + ) + Account = self.env["acc.account"] + + acc_account = Account.create( + { + "acc_operation_id": self.id, + "acc_injection_id": acc_injection_id.id, + "acc_delivery_id": acc_delivery_id.id, + "power_cons": power_total, + "start_date": date_start, + "end_date": date_end, + "tax_tcfe": self.tax_tcfe, + } + ) + + interval_ids = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", acc_injection_id.id), + ("acc_delivery_id", "=", acc_delivery_id.id), + ("start_date", "<=", date_start), + ("end_date", "=", False), + ] + ) if not interval_ids: - price_ids = self.env['acc.sale.price'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', acc_injection_id.id), - ('acc_delivery_id', '=', acc_delivery_id.id), - ('end_date', '>=', date_start), - ]) - price2_ids = self.env['acc.sale.price'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', acc_injection_id.id), - ('acc_delivery_id', '=', acc_delivery_id.id), - ('start_date', '<=', date_end) - ]) + price_ids = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", acc_injection_id.id), + ("acc_delivery_id", "=", acc_delivery_id.id), + ("end_date", ">=", date_start), + ] + ) + price2_ids = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", acc_injection_id.id), + ("acc_delivery_id", "=", acc_delivery_id.id), + ("start_date", "<=", date_end), + ] + ) interval_ids = price_ids & price2_ids for interval in interval_ids: @@ -182,32 +206,44 @@ class AccOperation(models.Model): else: date_interval_end = date_end - power_total = self.calc_power_by_cons_by_prod(acc_injection_id, acc_delivery_id, date_interval_start, date_interval_end) - - AccountLine = self.env['acc.account.line'] - - # Création de la ligne de facture par intervalle de période de prix - acc_account_line = AccountLine.create({ - 'quantity': power_total, - 'price_unit': interval.price, - 'acc_account_id': acc_account.id, - 'start_date': date_interval_start, - 'end_date': date_interval_end, - 'description': 'Période du ' + str(date_interval_start) + ' au ' + str(date_interval_end) - }) + power_total = self.calc_power_by_cons_by_prod( + acc_injection_id, + acc_delivery_id, + date_interval_start, + date_interval_end, + ) + + AccountLine = self.env["acc.account.line"] + + # Création de la ligne de facture + # par intervalle de période de prix + AccountLine.create( + { + "quantity": power_total, + "price_unit": interval.price, + "acc_account_id": acc_account.id, + "start_date": date_interval_start, + "end_date": date_interval_end, + "description": "Période du " + + str(date_interval_start) + + " au " + + str(date_interval_end), + } + ) account_list.append(acc_account) action = self.env["ir.actions.actions"]._for_xml_id( "acc_account.action_acc_account" ) - action["domain"] = [ - ("id", "in", account_list) - ] + action["domain"] = [("id", "in", account_list)] return action - def calc_power_by_cons_by_prod(self, acc_injection_id, acc_delivery_id, date_start, date_end): + def calc_power_by_cons_by_prod( + self, acc_injection_id, acc_delivery_id, date_start, date_end + ): """ - Fonction permettant de calculer la puissance en kWh consommée pour un consommateur donnée en fonction + Fonction permettant de calculer la puissance en kWh consommée + pour un consommateur donnée en fonction en rapport à un producteur défini pour un intervalle de temps donné. :param acc_injection_id: producteur acc_delivery_id: consommateur @@ -215,23 +251,36 @@ class AccOperation(models.Model): date_end: date de fin :return: une valeur représentant la puissance consommée en kWh """ - power_tab_by_prod = self.env['acc.enedis.cdc'].read_group( - [('acc_operation_id', '=', self.id), - ('date_slot', '>=', date_start), - ('date_slot', '<=', date_end), - '|', ('comp_data_type', '=', 'prod'), - ('comp_data_type', '=', 'surplus')], - ['power', 'acc_operation_id', 'date_slot'], - ['comp_data_type'], orderby='comp_data_type', lazy=False) - - prod_tot = power_tab_by_prod[0]['power'] - power_tab_by_prod[1]['power'] - - power_tab_by_prod = self.get_power_by_prod(acc_injection_id, date_start, date_end) - - power_autoprod_percent = ((power_tab_by_prod[0]['power'] - power_tab_by_prod[1][ - 'power']) * 100) / prod_tot - power_tab_by_cons = self.get_power_by_cons(acc_delivery_id, date_start, date_end) - power_total = (power_tab_by_cons[0]['power'] / 1000 / 2) * (power_autoprod_percent / 100) + power_tab_by_prod = self.env["acc.enedis.cdc"].read_group( + [ + ("acc_operation_id", "=", self.id), + ("date_slot", ">=", date_start), + ("date_slot", "<=", date_end), + "|", + ("comp_data_type", "=", "prod"), + ("comp_data_type", "=", "surplus"), + ], + ["power", "acc_operation_id", "date_slot"], + ["comp_data_type"], + orderby="comp_data_type", + lazy=False, + ) + + prod_tot = power_tab_by_prod[0]["power"] - power_tab_by_prod[1]["power"] + + power_tab_by_prod = self.get_power_by_prod( + acc_injection_id, date_start, date_end + ) + + power_autoprod_percent = ( + (power_tab_by_prod[0]["power"] - power_tab_by_prod[1]["power"]) * 100 + ) / prod_tot + power_tab_by_cons = self.get_power_by_cons( + acc_delivery_id, date_start, date_end + ) + power_total = (power_tab_by_cons[0]["power"] / 1000 / 2) * ( + power_autoprod_percent / 100 + ) return power_total def create_account_surplus(self, date_month, account_periodicity): @@ -239,53 +288,64 @@ class AccOperation(models.Model): Fonction permettant de générer les factures se surplus à une date donnée. Création des factures + Création des lignes de facture associées. :param date_month: date à laquelle on lance la facture - account_periodicity: périodicité (1 pour mois, 3 pour trimestre, 6 pour semestre, 12 pour année) + account_periodicity: périodicité (1 pour mois, 3 pour trimestre, + 6 pour semestre, 12 pour année) :return: """ account_list = [] - date_end = date_utils.end_of(date_month, 'month') - date_start = date_end - relativedelta(months=int(account_periodicity)-1) - date_start = date_utils.start_of(date_start, 'month') + date_end = date_utils.end_of(date_month, "month") + date_start = date_end - relativedelta(months=int(account_periodicity) - 1) + date_start = date_utils.start_of(date_start, "month") for injection_id in self.acc_injection_ids: if injection_id.is_account_surplus_activate: - power_surplus = self.get_power_by_prod(injection_id, date_start, date_end) - Account = self.env['acc.account'] - - acc_account = Account.create({ - 'acc_operation_id': self.id, - 'buyer_id': injection_id.buyer_id.id, - 'acc_injection_id': injection_id.id, - 'power_cons': power_surplus[1]['power'], - 'start_date': date_start, - 'end_date': date_end, - # 'price_kwh': price_kwh, - 'is_account_buyer': True, - 'tax_tcfe': self.tax_tcfe, - }) - - interval_ids = self.env['acc.sale.price.buyer'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', injection_id.id), - ('acc_buyer_id', '=', injection_id.buyer_id.id), - ('start_date', '<=', date_start), - ('end_date', '=', False) - ]) + power_surplus = self.get_power_by_prod( + injection_id, date_start, date_end + ) + Account = self.env["acc.account"] + + acc_account = Account.create( + { + "acc_operation_id": self.id, + "buyer_id": injection_id.buyer_id.id, + "acc_injection_id": injection_id.id, + "power_cons": power_surplus[1]["power"], + "start_date": date_start, + "end_date": date_end, + # 'price_kwh': price_kwh, + "is_account_buyer": True, + "tax_tcfe": self.tax_tcfe, + } + ) + + interval_ids = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", injection_id.id), + ("acc_buyer_id", "=", injection_id.buyer_id.id), + ("start_date", "<=", date_start), + ("end_date", "=", False), + ] + ) if not interval_ids: - price_ids = self.env['acc.sale.price.buyer'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', injection_id.id), - ('acc_buyer_id', '=', injection_id.buyer_id.id), - ('end_date', '>=', date_start), - ]) - price2_ids = self.env['acc.sale.price.buyer'].search([ - ('acc_operation_id', '=', self.id), - ('acc_injection_id', '=', injection_id.id), - ('acc_buyer_id', '=', injection_id.buyer_id.id), - ('start_date', '<=', date_end) - ]) + price_ids = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", injection_id.id), + ("acc_buyer_id", "=", injection_id.buyer_id.id), + ("end_date", ">=", date_start), + ] + ) + price2_ids = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", self.id), + ("acc_injection_id", "=", injection_id.id), + ("acc_buyer_id", "=", injection_id.buyer_id.id), + ("start_date", "<=", date_end), + ] + ) interval_ids = price_ids & price2_ids for interval in interval_ids: @@ -302,31 +362,37 @@ class AccOperation(models.Model): else: date_interval_end = date_end - power_surplus = self.get_power_by_prod(injection_id, date_interval_start, date_interval_end) - AccountLine = self.env['acc.account.line'] + power_surplus = self.get_power_by_prod( + injection_id, date_interval_start, date_interval_end + ) + AccountLine = self.env["acc.account.line"] # Création de la ligne du mois - acc_account_line = AccountLine.create({ - 'quantity': power_surplus[1]['power'], - 'price_unit': interval.price, - 'acc_account_id': acc_account.id, - 'start_date': date_interval_start, - 'end_date': date_interval_end, - 'description': 'Période du ' + str(date_interval_start) + ' au ' + str(date_interval_end) - }) + AccountLine.create( + { + "quantity": power_surplus[1]["power"], + "price_unit": interval.price, + "acc_account_id": acc_account.id, + "start_date": date_interval_start, + "end_date": date_interval_end, + "description": "Période du " + + str(date_interval_start) + + " au " + + str(date_interval_end), + } + ) account_list.append(acc_account) action = self.env["ir.actions.actions"]._for_xml_id( "acc_account.action_acc_account" ) - action["domain"] = [ - ("id", "in", account_list) - ] + action["domain"] = [("id", "in", account_list)] return action def _open_x2m_matrix(self, view_xmlid): """ - Fonction qui appelle le wizard matrix 2D pour la défintion des prix par consommateur/producteur + Fonction qui appelle le wizard matrix 2D pour la défintion des prix + par consommateur/producteur :param view_xmlid: Vue appelée :return: action """ @@ -353,39 +419,46 @@ class AccOperation(models.Model): # Financial method APP # ------------------------------------------------------ def get_financial_monitoring(self, type, prm_id=None): - account_list = [] date_first = fields.Date.today() - relativedelta(months=1) - date_end = date_utils.end_of(date_first, 'month') + date_end = date_utils.end_of(date_first, "month") if prm_id: - acc_counter_ids = self.env['acc.counter'].browse(prm_id) + acc_counter_ids = self.env["acc.counter"].browse(prm_id) else: - if type == 'cons': + if type == "cons": acc_counter_ids = self.acc_delivery_ids else: acc_counter_ids = self.acc_injection_ids # Consommation - power_tab_by_cons = self.env['acc.enedis.cdc'].read_group( - [('acc_operation_id', '=', self.id), - ('date_slot', '<=', date_end), - ('comp_data_type', '=', 'cons'), - ('acc_counter_id', 'in', acc_counter_ids.ids)], - ['power', 'acc_counter_id', 'date_slot'], - ['date_slot:month', 'acc_counter_id'], orderby='acc_counter_id', lazy=False) + power_tab_by_cons = self.env["acc.enedis.cdc"].read_group( + [ + ("acc_operation_id", "=", self.id), + ("date_slot", "<=", date_end), + ("comp_data_type", "=", "cons"), + ("acc_counter_id", "in", acc_counter_ids.ids), + ], + ["power", "acc_counter_id", "date_slot"], + ["date_slot:month", "acc_counter_id"], + orderby="acc_counter_id", + lazy=False, + ) return power_tab_by_cons # prod_tot = power_tab_by_prod[0]['power'] - power_tab_by_prod[1]['power'] # for acc_injection_id in self.acc_injection_ids: # if acc_injection_id.is_account_auto_activate: - # power_tab_by_prod = self.get_power_by_prod(acc_injection_id, date_start, date_end) + # power_tab_by_prod = self.get_power_by_prod( + # acc_injection_id, date_start, date_end) # - # power_autoprod_percent = ((power_tab_by_prod[0]['power'] - power_tab_by_prod[1]['power']) * 100) / prod_tot + # power_autoprod_percent = ((power_tab_by_prod[0]['power'] - + # power_tab_by_prod[1]['power']) * 100) / prod_tot # power_tab_by_cons = self.get_power_by_cons(date_start, date_end) # for power_cons in power_tab_by_cons: # - # power_month = (power_cons['power'] / 1000 / 2) * (power_autoprod_percent / 100) + # power_month = (power_cons['power'] / 1000 / 2) * + # (power_autoprod_percent / 100) # # price_kwh = self.env['acc.sale.price'].search([ # ('acc_operation_id', '=', self.id), @@ -393,4 +466,4 @@ class AccOperation(models.Model): # ('acc_delivery_id', '=', power_cons['acc_counter_id'][0]), # ('start_date', '<=', date_month), # ('end_date', '>=', date_month) - # ]).price \ No newline at end of file + # ]).price diff --git a/models/acc_sale_price.py b/models/acc_sale_price.py index 7be4f42ce64be4013fe5b75700f71047791e4b82..249af7e131d1d7ebac06a6da2a6b104a209e00a5 100644 --- a/models/acc_sale_price.py +++ b/models/acc_sale_price.py @@ -1,15 +1,15 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api from dateutil.relativedelta import relativedelta +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class AccSalePrice(models.Model): - _name = 'acc.sale.price' - _description = 'Prix de vente' + _name = "acc.sale.price" + _description = "Prix de vente" def _get_default_currency_id(self): return self.env.company.currency_id.id @@ -17,27 +17,25 @@ class AccSalePrice(models.Model): # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ - acc_operation_id = fields.Many2one( - "acc.operation", - "Opération", - ondelete="cascade") + acc_operation_id = fields.Many2one("acc.operation", "Opération", ondelete="cascade") acc_injection_id = fields.Many2one( - 'acc.counter', - domain=[('is_injection', '=', True)], + "acc.counter", + domain=[("is_injection", "=", True)], string="Point d'injection", - ondelete="cascade" + ondelete="cascade", ) acc_delivery_id = fields.Many2one( - 'acc.counter', - domain=[('is_delivery', '=', True)], + "acc.counter", + domain=[("is_delivery", "=", True)], string="Point de soutirage", - ondelete="cascade" + ondelete="cascade", ) start_date = fields.Date("Début de la période") end_date = fields.Date("Fin de la période") currency_id = fields.Many2one( - 'res.currency', 'Devise', default=_get_default_currency_id) - price = fields.Float("Tarif", digits='Sale Price') + "res.currency", "Devise", default=_get_default_currency_id + ) + price = fields.Float("Tarif", digits="Sale Price") @api.model_create_multi def create(self, vals_list): @@ -54,14 +52,18 @@ class AccSalePrice(models.Model): start_date = fields.Date.to_date(vals["start_date"]) # If date start period doesn't exist - price_ids = self.env["acc.sale.price"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_delivery_id", "=", acc_delivery_id), - ("acc_injection_id", "=", acc_injection_id)]) + price_ids = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_delivery_id", "=", acc_delivery_id), + ("acc_injection_id", "=", acc_injection_id), + ] + ) if acc_operation.date_start_contract > start_date: raise ValidationError( - "L'opération n'est pas active à cette période là") + _("L'opération n'est pas active à cette période là") + ) # Creation d'une nouvelle période date anniversaire à date renseignée - 1 jour if not price_ids and acc_operation.date_start_contract < start_date: @@ -71,27 +73,34 @@ class AccSalePrice(models.Model): "acc_delivery_id": acc_delivery_id, "price": vals["price"], "start_date": acc_operation.date_start_contract, - "end_date": start_date - relativedelta(days=1) + "end_date": start_date - relativedelta(days=1), } new_vals.append(val_new) # Si une période existe après la date renseignée - price_ids = self.env["acc.sale.price"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_delivery_id", "=", acc_delivery_id), - ("acc_injection_id", "=", acc_injection_id), - ("start_date", "<=", start_date), - ("end_date", ">", start_date), - ]) + price_ids = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_delivery_id", "=", acc_delivery_id), + ("acc_injection_id", "=", acc_injection_id), + ("start_date", "<=", start_date), + ("end_date", ">", start_date), + ] + ) if price_ids: raise ValidationError( - "Un prix de vente existe déjà pour cette date là") - - price_id = self.env["acc.sale.price"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_delivery_id", "=", acc_delivery_id), - ("acc_injection_id", "=", acc_injection_id), - ], limit=1, order="create_date desc") + _("Un prix de vente existe déjà pour cette date là") + ) + + price_id = self.env["acc.sale.price"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_delivery_id", "=", acc_delivery_id), + ("acc_injection_id", "=", acc_injection_id), + ], + limit=1, + order="create_date desc", + ) if price_id: price_id.end_date = start_date - relativedelta(days=1) vals_list += new_vals @@ -100,8 +109,8 @@ class AccSalePrice(models.Model): class AccSalePriceBuyer(models.Model): - _name = 'acc.sale.price.buyer' - _description = 'Prix de vente' + _name = "acc.sale.price.buyer" + _description = "Prix de vente" def _get_default_currency_id(self): return self.env.company.currency_id.id @@ -109,27 +118,25 @@ class AccSalePriceBuyer(models.Model): # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ - acc_operation_id = fields.Many2one( - "acc.operation", - "Opération", - ondelete="cascade") + acc_operation_id = fields.Many2one("acc.operation", "Opération", ondelete="cascade") acc_injection_id = fields.Many2one( - 'acc.counter', - domain=[('is_injection', '=', True)], + "acc.counter", + domain=[("is_injection", "=", True)], string="Point d'injection", - ondelete="cascade" + ondelete="cascade", ) acc_buyer_id = fields.Many2one( - 'res.partner', - domain=[('is_buyer_surplus', '=', True)], + "res.partner", + domain=[("is_buyer_surplus", "=", True)], string="Acheteur de surplus", ondelete="cascade", ) start_date = fields.Date("Début de la période") end_date = fields.Date("Fin de la période") currency_id = fields.Many2one( - 'res.currency', 'Devise', default=_get_default_currency_id) - price = fields.Float("Tarif", digits='Sale Price') + "res.currency", "Devise", default=_get_default_currency_id + ) + price = fields.Float("Tarif", digits="Sale Price") @api.model_create_multi def create(self, vals_list): @@ -146,16 +153,21 @@ class AccSalePriceBuyer(models.Model): start_date = fields.Date.to_date(vals["start_date"]) # If date start period doesn't exist - price_ids = self.env["acc.sale.price.buyer"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_injection_id", "=", acc_injection_id), - ("acc_buyer_id", "=", acc_buyer_id)]) + price_ids = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_injection_id", "=", acc_injection_id), + ("acc_buyer_id", "=", acc_buyer_id), + ] + ) if acc_operation.date_start_contract > start_date: raise ValidationError( - "L'opération n'est pas active à cette période là") + _("L'opération n'est pas active à cette période là") + ) - # Creation d'une nouvelle période date anniversaire à date renseignée - 1 jour + # Creation d'une nouvelle période + # date anniversaire à date renseignée - 1 jour if not price_ids and acc_operation.date_start_contract < start_date: val_new = { "acc_operation_id": acc_operation_id, @@ -163,27 +175,34 @@ class AccSalePriceBuyer(models.Model): "acc_buyer_id": acc_buyer_id, "price": vals["price"], "start_date": acc_operation.date_start_contract, - "end_date": start_date - relativedelta(days=1) + "end_date": start_date - relativedelta(days=1), } new_vals.append(val_new) # Si une période existe après la date renseignée - price_ids = self.env["acc.sale.price.buyer"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_buyer_id", "=", acc_buyer_id), - ("acc_injection_id", "=", acc_injection_id), - ("start_date", "<=", start_date), - ("end_date", ">", start_date), - ]) + price_ids = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_buyer_id", "=", acc_buyer_id), + ("acc_injection_id", "=", acc_injection_id), + ("start_date", "<=", start_date), + ("end_date", ">", start_date), + ] + ) if price_ids: raise ValidationError( - "Un prix de vente existe déjà pour cette date là") - - price_id = self.env["acc.sale.price.buyer"].search([ - ("acc_operation_id", "=", acc_operation_id), - ("acc_buyer_id", "=", acc_buyer_id), - ("acc_injection_id", "=", acc_injection_id), - ], limit=1, order="create_date desc") + _("Un prix de vente existe déjà pour cette date là") + ) + + price_id = self.env["acc.sale.price.buyer"].search( + [ + ("acc_operation_id", "=", acc_operation_id), + ("acc_buyer_id", "=", acc_buyer_id), + ("acc_injection_id", "=", acc_injection_id), + ], + limit=1, + order="create_date desc", + ) if price_id: price_id.end_date = start_date - relativedelta(days=1) vals_list += new_vals diff --git a/models/res_partner.py b/models/res_partner.py index 6a52cfcb83558353452601bd22c10db6a5e5c9f1..e41c4601bf451d8bb0b26214a750c8600c1498ee 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -1,11 +1,11 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" # ------------------------------------------------------ # Fields declaration diff --git a/report/account_report.xml b/report/account_report.xml index 05f8bec5352af86ff10b456b694a15d4d6d1da4e..59b108f654c4f732db8921865253e04547ad14c8 100644 --- a/report/account_report.xml +++ b/report/account_report.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -9,7 +9,7 @@ <field name="report_name">acc_account.report_account</field> <field name="report_file">account.report_account</field> <field name="print_report_name">'Facture - %s' % (object.name)</field> - <field name="binding_model_id" ref="model_acc_account"/> + <field name="binding_model_id" ref="model_acc_account" /> <field name="binding_type">report</field> </record> diff --git a/report/account_template.xml b/report/account_template.xml index c54316011a8ab4c017e7700f35e059fd1f6783d6..4116fa19e0ff2485b36aab4ba2ff4107450373ba 100644 --- a/report/account_template.xml +++ b/report/account_template.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -14,14 +14,22 @@ style="max-height: 80px;" alt="Logo" /> - <p class="mt-2" t-field="o.producer_id.name"/> + <p class="mt-2" t-field="o.producer_id.name" /> </div> - <div class="col-9 text-right" > + <div class="col-9 text-right"> <p class="font-weight-bold"> - <span class="text-uppercase text-uppercase mt0 ">Autoconsommation Collective <t t-esc="o.acc_operation_id.name"/></span><br/> - <span class="text-uppercase mt0 ">Vente d'électricité d'origine renouvelable</span><br/> - <span>Facture <t t-esc="o.name"/> du <t t-esc="o.date"/></span> + <span + class="text-uppercase text-uppercase mt0 " + >Autoconsommation Collective <t + t-esc="o.acc_operation_id.name" + /></span><br /> + <span + class="text-uppercase mt0 " + >Vente d'électricité d'origine renouvelable</span><br /> + <span>Facture <t t-esc="o.name" /> du <t + t-esc="o.date" + /></span> </p> </div> </div> @@ -30,42 +38,73 @@ <div class="col-4"> <div> <p> - <span class="text-center font-weight-bold">Vos références utiles</span><br/> - <span class="font-weight-bold">Titulaire du contrat:</span><br/> + <span + class="text-center font-weight-bold" + >Vos références utiles</span><br /> + <span + class="font-weight-bold" + >Titulaire du contrat:</span><br /> <t t-set="address"> - <address t-field="o.consumer_id" t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' /><br/> + <address + t-field="o.consumer_id" + t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' + /><br /> </t> - <span class="font-weight-bold">Courrier:</span><br/> - <span t-field="o.consumer_id.email"/><br/> - <span class="font-weight-bold">Référence Client:</span><br/> - <span t-field="o.consumer_id.ref"/> + <span class="font-weight-bold">Courrier:</span><br + /> + <span t-field="o.consumer_id.email" /><br /> + <span + class="font-weight-bold" + >Référence Client:</span><br /> + <span t-field="o.consumer_id.ref" /> </p> - <hr/> + <hr /> <p> - <span class="font-weight-bold">Référence Point de livraison:</span><br/> - <span t-field="o.acc_delivery_id.name"/><br/> - <span class="font-weight-bold">Lieu de consommation:</span><br/> - <span t-field="o.consumer_id.street"/> + <span + class="font-weight-bold" + >Référence Point de livraison:</span><br /> + <span t-field="o.acc_delivery_id.name" /><br /> + <span + class="font-weight-bold" + >Lieu de consommation:</span><br /> + <span t-field="o.consumer_id.street" /> </p> </div> <div> <p> - <span class="text-center font-weight-bold">Pour répondre à vos questions</span><br/> - <span class="font-weight-bold">Contact PMO</span><br/> - <span class="font-weight-bold" t-field="o.pmo_id.name"/><br/> - <span t-field="o.pmo_id.street"/><br/> - <t t-if="o.pmo_id.street2"><span t-field="o.pmo_id.street2"/><br/></t> - <span t-field="o.pmo_id.zip"/> - <span t-field="o.pmo_id.city"/><br/> - <span class="font-weight-bold">Téléphone:</span><br/> - <span t-field="o.pmo_id.phone"/><br/> - <span class="text-center font-weight-bold">Courrier:</span><br/> - <span t-field="o.consumer_id.email"/> + <span + class="text-center font-weight-bold" + >Pour répondre à vos questions</span><br /> + <span class="font-weight-bold">Contact PMO</span><br + /> + <span + class="font-weight-bold" + t-field="o.pmo_id.name" + /><br /> + <span t-field="o.pmo_id.street" /><br /> + <t t-if="o.pmo_id.street2"><span + t-field="o.pmo_id.street2" + /><br /></t> + <span t-field="o.pmo_id.zip" /> - <span + t-field="o.pmo_id.city" + /><br /> + <span class="font-weight-bold">Téléphone:</span><br + /> + <span t-field="o.pmo_id.phone" /><br /> + <span + class="text-center font-weight-bold" + >Courrier:</span><br /> + <span t-field="o.consumer_id.email" /> </p> - <hr/> + <hr /> <p> - <span class="text-center font-weight-bold">Référence Autoconsommation collective:</span><br/> - <span t-field="o.acc_operation_id.name"/><br/> - <span class="text-center font-weight-bold">Lieu de production:</span><br/> + <span + class="text-center font-weight-bold" + >Référence Autoconsommation collective:</span><br /> + <span t-field="o.acc_operation_id.name" /><br /> + <span + class="text-center font-weight-bold" + >Lieu de production:</span><br /> <!-- <p t-field="o.consumer_id.street"/>--> </p> </div> @@ -73,50 +112,85 @@ <div class="col-8"> <div class="text-right"> <p> - <span class="text-center font-weight-bold">Coordonnées de facturation</span><br/> - <span class="font-weight-bold" t-field="o.consumer_id.name"/><br/> - <span t-field="o.consumer_id.street"/><br/> - <t t-if="o.consumer_id.street2"><span t-field="o.consumer_id.street2"/><br/></t> - <span t-field="o.consumer_id.zip"/> - <span t-field="o.consumer_id.city"/><br/> + <span + class="text-center font-weight-bold" + >Coordonnées de facturation</span><br /> + <span + class="font-weight-bold" + t-field="o.consumer_id.name" + /><br /> + <span t-field="o.consumer_id.street" /><br /> + <t t-if="o.consumer_id.street2"><span + t-field="o.consumer_id.street2" + /><br /></t> + <span t-field="o.consumer_id.zip" /> - <span + t-field="o.consumer_id.city" + /><br /> </p> </div> <div> <p> - <span class="font-weight-bold">Synthèse de votre facture</span><br/> - <span class="font-weight-bold">Période de livraison concernée : du <t t-esc="start_date"/> au <t t-esc="end_date"/></span><br/> + <span + class="font-weight-bold" + >Synthèse de votre facture</span><br /> + <span + class="font-weight-bold" + >Période de livraison concernée : du <t + t-esc="start_date" + /> au <t t-esc="end_date" /></span><br /> </p> - <table class="table table-sm o_main_table" name="account_line_table"> + <table + class="table table-sm o_main_table" + name="account_line_table" + > <tr> <td>Prix de l'électricité locale</td> <td class="text-right"> - <span t-field="o.price_kwh" t-options='{"widget": "monetary", "display_currency": o.currency_id}'> HT/kWh</span> + <span + t-field="o.price_kwh" + t-options='{"widget": "monetary", "display_currency": o.currency_id}' + > HT/kWh</span> </td> </tr> <tr> <td>Consommation locale (index Enedis)</td> <td class="text-right"> - <span t-field="o.power_cons"/> <span>kWh</span> + <span t-field="o.power_cons" /> <span + >kWh</span> </td> </tr> <tr> <td>Taxes CPSE/TCF</td> <td class="text-right"> - <span t-field="o.tax_tcfe"/> <span>en €/kWh</span> + <span t-field="o.tax_tcfe" /> <span + >en €/kWh</span> </td> </tr> - <t t-set="lines" t-value="o.line_ids"/> - <t t-set="current_subtotal" t-value="0"/> + <t t-set="lines" t-value="o.line_ids" /> + <t t-set="current_subtotal" t-value="0" /> <t t-foreach="lines" t-as="line"> - <t t-set="current_subtotal" t-value="current_subtotal + line.price_total"/> + <t + t-set="current_subtotal" + t-value="current_subtotal + line.price_total" + /> <tr class="border-black"> <t name="account_invoice_line_accountable"> <td name="account_invoice_line_name"> - <span t-field="line.description" t-options="{'widget': 'text'}"/><br/> - à <span class="text-nowrap" t-field="line.price_unit"/> € + <span + t-field="line.description" + t-options="{'widget': 'text'}" + /><br /> + à <span + class="text-nowrap" + t-field="line.price_unit" + /> € </td> <td class="text-right"> - <span class="text-nowrap" t-field="line.price_total"/> + <span + class="text-nowrap" + t-field="line.price_total" + /> </td> </t> </tr> @@ -128,35 +202,58 @@ <div class="clearfix"> <div id="total" class="row"> <div t-attf-class="col-6 ml-auto"> - <table class="table table-sm" style="page-break-inside: avoid;"> - <tr class="border-black o_subtotal" style=""> + <table + class="table table-sm" + style="page-break-inside: avoid;" + > + <tr + class="border-black o_subtotal" + style="" + > <td><strong>Sous-Total</strong></td> <td class="text-right"> - <span t-field="o.amount_untaxed"/> + <span t-field="o.amount_untaxed" /> </td> </tr> <t t-if="o.is_tva"> <tr style=""> <t> - <td><span class="text-nowrap"/>TVA</td> - <td class="text-right o_price_total"> - <span class="text-nowrap" t-field="o.amount_tax"/> + <td><span + class="text-nowrap" + />TVA</td> + <td + class="text-right o_price_total" + > + <span + class="text-nowrap" + t-field="o.amount_tax" + /> </td> </t> </tr> </t> <tr style=""> <t> - <td><span class="text-nowrap"/>Taxes CPSE/TCF</td> - <td class="text-right o_price_total"> - <span class="text-nowrap" t-field="o.amount_tax_tcfe"/> + <td><span + class="text-nowrap" + />Taxes CPSE/TCF</td> + <td + class="text-right o_price_total" + > + <span + class="text-nowrap" + t-field="o.amount_tax_tcfe" + /> </td> </t> </tr> <tr class="border-black o_total"> <td><strong>Total</strong></td> <td class="text-right"> - <span class="text-nowrap" t-field="o.amount_total"/> + <span + class="text-nowrap" + t-field="o.amount_total" + /> </td> </tr> </table> @@ -167,12 +264,17 @@ </div> <p t-if="o.producer_id.iban" name="payment_term" class="mt32 "> - <span class="font-weight-bold">Modalités de paiement : règlement par virement</span><br/> - <span>Le règlement par virement bancaire doit être effectué sur le compte suivant :</span><br/> - <span>IBAN : <t t-esc="o.producer_id.iban"/></span><br/> - <span>BIC : <t t-esc="o.producer_id.bic"/></span><br/> - <br/> - <span>Merci de bien vouloir indiquer le numéro de facture et/ou votre référence client sur l’ordre de virement</span> + <span + class="font-weight-bold" + >Modalités de paiement : règlement par virement</span><br /> + <span + >Le règlement par virement bancaire doit être effectué sur le compte suivant :</span><br + /> + <span>IBAN : <t t-esc="o.producer_id.iban" /></span><br /> + <span>BIC : <t t-esc="o.producer_id.bic" /></span><br /> + <br /> + <span + >Merci de bien vouloir indiquer le numéro de facture et/ou votre référence client sur l’ordre de virement</span> </p> </div> @@ -181,16 +283,34 @@ <div class="text-center"> <ul class="list-inline"> <li class="list-inline-item"> - <t t-if="o.producer_id.name"><span t-field="o.producer_id.name"/></t> - <t t-if="o.producer_id.company_form"> - <span t-field="o.producer_id.company_form"/></t> - <t t-if="o.producer_id.street"> - <span t-field="o.producer_id.street"/></t> - <t t-if="o.producer_id.zip">, <span t-field="o.producer_id.zip"/></t> - <t t-if="o.producer_id.city"> <span t-field="o.producer_id.city"/></t> - <br/> - <t t-if="o.producer_id.siret"><span t-field="o.producer_id.siret" /></t> - <t t-if="o.producer_id.naf"> - <span t-field="o.producer_id.naf"/></t> - <t t-if="o.producer_id.rcs"> - <span t-field="o.producer_id.rcs"/></t> - <t t-if="o.producer_id.vat"> - <span t-field="o.producer_id.vat"/></t> + <t t-if="o.producer_id.name"><span + t-field="o.producer_id.name" + /></t> + <t t-if="o.producer_id.company_form"> - <span + t-field="o.producer_id.company_form" + /></t> + <t t-if="o.producer_id.street"> - <span + t-field="o.producer_id.street" + /></t> + <t t-if="o.producer_id.zip">, <span + t-field="o.producer_id.zip" + /></t> + <t t-if="o.producer_id.city"> <span + t-field="o.producer_id.city" + /></t> + <br /> + <t t-if="o.producer_id.siret"><span + t-field="o.producer_id.siret" + /></t> + <t t-if="o.producer_id.naf"> - <span + t-field="o.producer_id.naf" + /></t> + <t t-if="o.producer_id.rcs"> - <span + t-field="o.producer_id.rcs" + /></t> + <t t-if="o.producer_id.vat"> - <span + t-field="o.producer_id.vat" + /></t> </li> </ul> <div t-if="report_type == 'pdf'"> diff --git a/report/report_template.xml b/report/report_template.xml index b85bc40cf492cf356f3e75ba965ee6f5a24b8824..1f6d80c02af38499e8189d4d1585f58a286a6622 100644 --- a/report/report_template.xml +++ b/report/report_template.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -34,4 +34,4 @@ </template> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv old mode 100755 new mode 100644 index 5a4dea61265f1f5d2577759cda343235abac6850..d95fc03162ed4524ec00eb48e2c465a3d2662ca9 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -16,4 +16,4 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink "access_acc_account_wizard_group_partner_manager","acc_account_wizard group_partner_manager","model_acc_account_wizard","base.group_partner_manager",1,1,1,1 "access_acc_account_wizard_group_user","acc_account_wizard group_user","model_acc_account_wizard","base.group_user",1,0,0,0 "access_acc_account_surplus_wizard_group_partner_manager","acc_account_surplus_wizard group_partner_manager","model_acc_account_surplus_wizard","base.group_partner_manager",1,1,1,1 -"access_acc_account_surplus_wizard_group_user","acc_account_surplus_wizard group_user","model_acc_account_surplus_wizard","base.group_user",1,0,0,0 \ No newline at end of file +"access_acc_account_surplus_wizard_group_user","acc_account_surplus_wizard group_user","model_acc_account_surplus_wizard","base.group_user",1,0,0,0 diff --git a/views/acc_account_views.xml b/views/acc_account_views.xml index 0c3a336f8e8d406c7f4bbc15dcb1d6a7610bca83..f2c91fdcdaabbc14c09acd63263c648b1b9785f2 100644 --- a/views/acc_account_views.xml +++ b/views/acc_account_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -12,20 +12,23 @@ <form string="Ligne de Vente" create="false"> <sheet> <group> - <field name="acc_operation_id" - readonly="1"/> + <field name="acc_operation_id" readonly="1" /> </group> <notebook colspan="4"> <page string="Information" name="information"> <group> <group string="Montant"> - <field name="description"/> - <field name="acc_account_id" options="{'no_create': True}" readonly="1"/> - <field name="quantity" readonly="1"/> + <field name="description" /> + <field + name="acc_account_id" + options="{'no_create': True}" + readonly="1" + /> + <field name="quantity" readonly="1" /> </group> <group string="Dates"> - <field name="start_date"/> - <field name="end_date"/> + <field name="start_date" /> + <field name="end_date" /> </group> <!-- <group string="Taxes" attrs="{'invisible': [('tax_line_id','=',False), ('tax_ids','=',[])]}">--> @@ -34,8 +37,11 @@ <!-- <field name="tax_exigible" readonly="1"/>--> <!-- <field name="tax_audit"/>--> <!-- </group>--> - <group string="Devise" groups="base.group_multi_currency"> - <field name="currency_id" invisible="1"/> + <group + string="Devise" + groups="base.group_multi_currency" + > + <field name="currency_id" invisible="1" /> </group> </group> </page> @@ -51,7 +57,7 @@ <field name="arch" type="xml"> <pivot string="Journal Items" sample="1"> <!-- <field name="journal_id" type="row"/>--> - <field name="date" type="col"/> + <field name="date" type="col" /> <!-- <field name="balance" type="measure"/>--> </pivot> </field> @@ -62,8 +68,14 @@ <field name="model">acc.account.line</field> <field name="arch" type="xml"> <tree string="Journal Items" create="false" edit="false" sample="1"> - <field name="date" optional="show"/> - <field name="currency_id" readonly="1" groups="base.group_multi_currency" optional="hide" string="Original Currency"/> + <field name="date" optional="show" /> + <field + name="currency_id" + readonly="1" + groups="base.group_multi_currency" + optional="hide" + string="Original Currency" + /> </tree> </field> </record> @@ -73,7 +85,7 @@ <field name="model">acc.account.line</field> <field name="arch" type="xml"> <graph string="Account Statistics" type="bar" sample="1"> - <field name="date"/> + <field name="date" /> </graph> </field> </record> @@ -88,15 +100,26 @@ <!-- groups="account.group_account_user"--> <!-- invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund', 'out_receipt', 'in_invoice', 'in_refund','in_receipt')"/>--> <!-- </header>--> - <field name="date"/> - <field name="name"/> - <field name="acc_operation_id" optional="show"/> - <field name="acc_injection_id" optional="show"/> - <field name="acc_delivery_id" optional="show"/> - <field name="amount_untaxed" string="Montant H.T." sum="Total" optional="show"/> - <field name="amount_tax" string="Tax" sum="Total" optional="hide"/> - <field name="amount_total" string="Total" sum="Total" decoration-bf="1" optional="show"/> - <field name="currency_id" invisible="1"/> + <field name="date" /> + <field name="name" /> + <field name="acc_operation_id" optional="show" /> + <field name="acc_injection_id" optional="show" /> + <field name="acc_delivery_id" optional="show" /> + <field + name="amount_untaxed" + string="Montant H.T." + sum="Total" + optional="show" + /> + <field name="amount_tax" string="Tax" sum="Total" optional="hide" /> + <field + name="amount_total" + string="Total" + sum="Total" + decoration-bf="1" + optional="show" + /> + <field name="currency_id" invisible="1" /> </tree> </field> </record> @@ -106,10 +129,10 @@ <field name="model">acc.account</field> <field name="arch" type="xml"> <kanban class="o_kanban_mobile" sample="1"> - <field name="acc_operation_id"/> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> - <field name="date"/> + <field name="acc_operation_id" /> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> + <field name="date" /> <templates> <t t-name="kanban-box"> <div t-attf-class="oe_kanban_global_click"> @@ -118,18 +141,29 @@ <strong> <span> <field name="acc_injection_id" /> - <field name="acc_delivery_id"/> + <field name="acc_delivery_id" /> </span> </strong> </div> <div class="col-6 text-right"> - <strong><i class="fa fa-clock-o" aria-label="Date" role="img" title="Date"/> <t t-esc="record.date.value"/></strong> + <strong><i + class="fa fa-clock-o" + aria-label="Date" + role="img" + title="Date" + /> <t t-esc="record.date.value" /></strong> </div> </div> <div class="row"> <div class="col-6"> - <span><field name="amount_total" widget='monetary'/></span> - <span><field name="currency_id" invisible="1"/></span> + <span><field + name="amount_total" + widget='monetary' + /></span> + <span><field + name="currency_id" + invisible="1" + /></span> </div> <div class="col-6"> <span class="float-right"> @@ -156,7 +190,7 @@ <!-- Payment status for invoices / receipts --> <!-- <widget name="web_ribbon" title="Paid"/>--> <!-- Invisible fields --> - <field name="id" invisible="1"/> + <field name="id" invisible="1" /> <div class="oe_title"> <h1 attrs="{'invisible': [('name', '!=', '/')]}"> @@ -164,36 +198,57 @@ </h1> <!-- Number --> <h1 class="mt0" attrs="{'invisible':[('name', '=', '/')]}"> - <field name="name"/> + <field name="name" /> </h1> </div> <group> <group string="Opération"> - <field name="is_account_buyer"/> - <field name="acc_operation_id" - options='{"always_reload": True, "no_quick_create": True}'/> - <field name="pmo_id" options='{"always_reload": True, "no_quick_create": True}'/> - <field name="acc_injection_id" - options='{"always_reload": True, "no_quick_create": True}'/> - <field name="producer_id" - options='{"always_reload": True, "no_quick_create": True}'/> - <field name="acc_delivery_id" - options='{"always_reload": True, "no_quick_create": True}' - attrs="{'invisible': [('is_account_buyer', '=', True)]}"/> - <field name="consumer_id" - options='{"always_reload": True, "no_quick_create": True}' - attrs="{'invisible': [('is_account_buyer', '=', True)]}"/> - <field name="buyer_id" - options='{"always_reload": True, "no_quick_create": True}' - attrs="{'invisible': [('is_account_buyer', '=', False)]}"/> + <field name="is_account_buyer" /> + <field + name="acc_operation_id" + options='{"always_reload": True, "no_quick_create": True}' + /> + <field + name="pmo_id" + options='{"always_reload": True, "no_quick_create": True}' + /> + <field + name="acc_injection_id" + options='{"always_reload": True, "no_quick_create": True}' + /> + <field + name="producer_id" + options='{"always_reload": True, "no_quick_create": True}' + /> + <field + name="acc_delivery_id" + options='{"always_reload": True, "no_quick_create": True}' + attrs="{'invisible': [('is_account_buyer', '=', True)]}" + /> + <field + name="consumer_id" + options='{"always_reload": True, "no_quick_create": True}' + attrs="{'invisible': [('is_account_buyer', '=', True)]}" + /> + <field + name="buyer_id" + options='{"always_reload": True, "no_quick_create": True}' + attrs="{'invisible': [('is_account_buyer', '=', False)]}" + /> </group> <group string="Période de facturation"> <field name="start_date" /> <field name="end_date" /> - <field name="power_cons"/> - <field name="price_kwh" options="{'field_digits': True}"/> - <field name="tax_tcfe" options="{'field_digits': True}"/> + <field name="power_cons" /> + <field + name="price_kwh" + options="{'field_digits': True}" + /> + <field + name="tax_tcfe" + options="{'field_digits': True}" + /> </group> </group> <group> @@ -203,40 +258,59 @@ <field name="tax_id" /> </group> <notebook> - <page id="invoice_tab" - string="Lignes de Facture"> - <field name="line_ids" - widget="section_and_note_one2many" - mode="tree,kanban" - context="{'default_currency_id': currency_id}"> - <tree editable="bottom" string="Lignes de facture" default_order="description asc"> - <field name="acc_account_id" - options="{'no_create': True}" invisible="1"/> - <field name="description"/> - <field name="quantity"/> - <field name="price_unit" string="Price" options="{'field_digits': True}"/> - <field name="is_tva" invisible="1"/> - <field name="tax_id" - options="{'no_create': True}" - attrs="{'invisible': [('is_tva', '=', False)]}"/> - <field name="price_total" - string="Total"/> - <field name="acc_operation_id" invisible="1"/> - <field name="currency_id" invisible="1"/> - <field name="date" invisible="1"/> + <page id="invoice_tab" string="Lignes de Facture"> + <field + name="line_ids" + widget="section_and_note_one2many" + mode="tree,kanban" + context="{'default_currency_id': currency_id}" + > + <tree + editable="bottom" + string="Lignes de facture" + default_order="description asc" + > + <field + name="acc_account_id" + options="{'no_create': True}" + invisible="1" + /> + <field name="description" /> + <field name="quantity" /> + <field + name="price_unit" + string="Price" + options="{'field_digits': True}" + /> + <field name="is_tva" invisible="1" /> + <field + name="tax_id" + options="{'no_create': True}" + attrs="{'invisible': [('is_tva', '=', False)]}" + /> + <field name="price_total" string="Total" /> + <field name="acc_operation_id" invisible="1" /> + <field name="currency_id" invisible="1" /> + <field name="date" invisible="1" /> </tree> </field> <group class="oe_subtotal_footer oe_right"> <field name="amount_untaxed" /> - <field name="amount_tax" attrs="{'invisible': [('is_tva', '=', False)]}"/> - <field name="amount_tax_tcfe" readonly="1"/> - <field name="amount_total" class="oe_subtotal_footer_separator" /> + <field + name="amount_tax" + attrs="{'invisible': [('is_tva', '=', False)]}" + /> + <field name="amount_tax_tcfe" readonly="1" /> + <field + name="amount_total" + class="oe_subtotal_footer_separator" + /> </group> </page> </notebook> </sheet> <!-- Attachment preview --> - <div class="o_attachment_preview"/> + <div class="o_attachment_preview" /> <!-- Chatter --> <!-- <div class="oe_chatter">--> <!-- <field name="message_follower_ids" groups="base.group_user"/>--> @@ -275,7 +349,7 @@ <field name="model">acc.account.tax</field> <field name="arch" type="xml"> <tree string="Taxes"> - <field name="name"/> + <field name="name" /> </tree> </field> </record> @@ -288,10 +362,10 @@ <sheet> <group> <group> - <field name="name"/> - <label for="amount"/> + <field name="name" /> + <label for="amount" /> <div> - <field name="amount" class="oe_inline"/> + <field name="amount" class="oe_inline" /> <span class="o_form_label oe_inline">%</span> </div> </group> @@ -305,7 +379,7 @@ <field name="name">Taxes</field> <field name="res_model">acc.account.tax</field> <field name="view_mode">tree,form</field> - <field name="view_id" ref="acc_view_tax_tree"/> + <field name="view_id" ref="acc_view_tax_tree" /> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Créer une nouvelle taxe diff --git a/views/acc_counter_views.xml b/views/acc_counter_views.xml index 364599154afe4c894dd6d02d57b8a1bb7d47076f..a224154892ad194e40e3e8282b7ab2a3cc6541ff 100644 --- a/views/acc_counter_views.xml +++ b/views/acc_counter_views.xml @@ -1,11 +1,11 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> - + <record id="acc_place_form_view" model="ir.ui.view"> <field name="name">acc.account.place.form</field> <field name="model">acc.counter</field> - <field name="inherit_id" ref="acc_operation.acc_place_form_view"/> + <field name="inherit_id" ref="acc_operation.acc_place_form_view" /> <field name="arch" type="xml"> <div class="oe_title" position="before"> <div name="button_box" class="oe_button_box"> @@ -61,34 +61,36 @@ <page string="Facturation" name="account"> <group> <group> - <field name="is_account_auto_activate" widget="boolean_toggle"/> + <field + name="is_account_auto_activate" + widget="boolean_toggle" + /> </group> <group> - <field name="is_account_surplus_activate" widget="boolean_toggle"/> + <field + name="is_account_surplus_activate" + widget="boolean_toggle" + /> </group> </group> - <field - name="acc_account_delivery_ids" - widget="one2many"> + <field name="acc_account_delivery_ids" widget="one2many"> <tree string="Facturation" editable="bottom"> - <field name="acc_operation_id" invisible="1"/> - <field name="name"/> + <field name="acc_operation_id" invisible="1" /> + <field name="name" /> <!-- <field name="date"/>--> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> - <field name="amount_total"/> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> + <field name="amount_total" /> </tree> </field> - <field - name="acc_account_injection_ids" - widget="one2many"> + <field name="acc_account_injection_ids" widget="one2many"> <tree string="Facturation" editable="bottom"> - <field name="acc_operation_id" invisible="1"/> - <field name="name"/> + <field name="acc_operation_id" invisible="1" /> + <field name="name" /> <!-- <field name="date"/>--> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> - <field name="amount_total"/> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> + <field name="amount_total" /> </tree> </field> </page> @@ -96,6 +98,6 @@ </group> </field> </record> - + </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/acc_operation_views.xml b/views/acc_operation_views.xml index 052d41f2f385c62a634f60ae5c45bf2b398a5ec0..dae2b0598eaab3297a3c5420c09e18a6b8fb947c 100644 --- a/views/acc_operation_views.xml +++ b/views/acc_operation_views.xml @@ -1,24 +1,26 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="acc_operation_form_view" model="ir.ui.view"> <field name="name">acc_account.acc_operation.form</field> <field name="model">acc.operation</field> - <field name="inherit_id" ref="acc_operation.acc_operation_form_view"/> - <field name="priority" eval="8"/> + <field name="inherit_id" ref="acc_operation.acc_operation_form_view" /> + <field name="priority" eval="8" /> <field name="arch" type="xml"> <header position="inside"> - <button string="Générer les factures" - type="action" - name="%(acc_account.acc_account_wizard_action)d" - class="btn-primary" - attrs="{'invisible': [('is_account_active', '=', False)]}" + <button + string="Générer les factures" + type="action" + name="%(acc_account.acc_account_wizard_action)d" + class="btn-primary" + attrs="{'invisible': [('is_account_active', '=', False)]}" /> - <button string="Générer les factures Acheteur" - type="action" - name="%(acc_account.acc_account_surplus_wizard_action)d" - class="btn-primary" + <button + string="Générer les factures Acheteur" + type="action" + name="%(acc_account.acc_account_surplus_wizard_action)d" + class="btn-primary" /> </header> <div class="oe_title" position="before"> @@ -42,18 +44,23 @@ </div> <notebook position="before"> <group> - <field name="is_account_active"/> + <field name="is_account_active" /> </group> </notebook> <notebook position="inside"> - <page string="Prix de vente" name="account_price" - attrs="{'invisible': [('is_account_active', '=', False)]}"> + <page + string="Prix de vente" + name="account_price" + attrs="{'invisible': [('is_account_active', '=', False)]}" + > <header> - <button string="Générer des Prix de vente" + <button + string="Générer des Prix de vente" type="action" name="%(acc_account.act_x2many_2d_matrix_demo)d" class="btn-primary" - attrs="{'invisible': [('is_account_active', '=', False)]}"/> + attrs="{'invisible': [('is_account_active', '=', False)]}" + /> </header> <field name="acc_sale_price_ids" widget="one2many"> <tree editable="bottom" default_order="start_date desc"> @@ -61,19 +68,24 @@ <field name="acc_delivery_id" /> <field name="start_date" /> <field name="end_date" /> - <field name="currency_id" invisible="1"/> + <field name="currency_id" invisible="1" /> <field name="price" widget="monetary" /> </tree> </field> </page> - <page string="Prix de vente Surplus" name="account_price_surplus" - attrs="{'invisible': [('is_account_active', '=', False)]}"> + <page + string="Prix de vente Surplus" + name="account_price_surplus" + attrs="{'invisible': [('is_account_active', '=', False)]}" + > <header> - <button string="Générer des Prix de vente Surplus" + <button + string="Générer des Prix de vente Surplus" type="action" name="%(acc_account.act_x2many_2d_matrix_demo_surplus)d" class="btn-primary" - attrs="{'invisible': [('is_account_active', '=', False)]}"/> + attrs="{'invisible': [('is_account_active', '=', False)]}" + /> </header> <field name="acc_sale_price_surplus_ids" widget="one2many"> <tree editable="bottom" default_order="start_date desc"> @@ -81,53 +93,61 @@ <field name="acc_buyer_id" /> <field name="start_date" /> <field name="end_date" /> - <field name="currency_id" invisible="1"/> + <field name="currency_id" invisible="1" /> <field name="price" widget="monetary" /> </tree> </field> </page> - <page string="Facturation" name="account" - attrs="{'invisible': [('is_account_active', '=', False)]}"> + <page + string="Facturation" + name="account" + attrs="{'invisible': [('is_account_active', '=', False)]}" + > <group> - <field name="tax_tcfe" options="{'field_digits': True}"/> + <field name="tax_tcfe" options="{'field_digits': True}" /> </group> <field - name="acc_account_ids" - widget="one2many" - options="{'no_create': True}" - context="{'default_acc_operation_id': active_id}" - readonly="1"> + name="acc_account_ids" + widget="one2many" + options="{'no_create': True}" + context="{'default_acc_operation_id': active_id}" + readonly="1" + > <tree string="Facturation"> - <field name="acc_operation_id" invisible="1"/> - <field name="name"/> - <field name="date"/> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> - <field name="start_date"/> - <field name="end_date"/> + <field name="acc_operation_id" invisible="1" /> + <field name="name" /> + <field name="date" /> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> + <field name="start_date" /> + <field name="end_date" /> <field name="amount_total" sum="Total" /> - <field name="is_account_buyer" invisible="1"/> + <field name="is_account_buyer" invisible="1" /> </tree> </field> </page> - <page string="Facturation Surplus" name="account" - attrs="{'invisible': [('is_account_active', '=', False)]}"> + <page + string="Facturation Surplus" + name="account" + attrs="{'invisible': [('is_account_active', '=', False)]}" + > <field - name="acc_account_surplus_ids" - widget="one2many" - options="{'no_create': True}" - readonly="1" - context="{'default_acc_operation_id': active_id, 'default_is_account_active': True}"> + name="acc_account_surplus_ids" + widget="one2many" + options="{'no_create': True}" + readonly="1" + context="{'default_acc_operation_id': active_id, 'default_is_account_active': True}" + > <tree string="Facturation Surplus"> - <field name="acc_operation_id" invisible="1"/> - <field name="is_account_buyer" invisible="1"/> - <field name="name"/> - <field name="date"/> - <field name="acc_injection_id"/> - <field name="buyer_id"/> - <field name="start_date"/> - <field name="end_date"/> - <field name="amount_total" sum="Total"/> + <field name="acc_operation_id" invisible="1" /> + <field name="is_account_buyer" invisible="1" /> + <field name="name" /> + <field name="date" /> + <field name="acc_injection_id" /> + <field name="buyer_id" /> + <field name="start_date" /> + <field name="end_date" /> + <field name="amount_total" sum="Total" /> </tree> </field> </page> @@ -135,4 +155,4 @@ </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/acc_sale_price_views.xml b/views/acc_sale_price_views.xml index f9550c62a9aeffe32e112f7297562f1176fa611b..305199a36d3797f5650df5b3cc79a9abce02d869 100644 --- a/views/acc_sale_price_views.xml +++ b/views/acc_sale_price_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -10,17 +10,19 @@ <sheet> <group> <group> - <field name="acc_operation_id"/> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> + <field name="acc_operation_id" /> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> </group> <group> - <field name="start_date"/> - <field name="end_date"/> - <field name="price" - widget='monetary' - options="{'field_digits': True}"/> - <field name="currency_id"/> + <field name="start_date" /> + <field name="end_date" /> + <field + name="price" + widget='monetary' + options="{'field_digits': True}" + /> + <field name="currency_id" /> </group> </group> </sheet> @@ -33,15 +35,17 @@ <field name="model">acc.sale.price</field> <field name="arch" type="xml"> <tree string="Prix de vente" default_order="start_date desc"> - <field name="acc_operation_id"/> - <field name="acc_injection_id"/> - <field name="acc_delivery_id"/> - <field name="start_date"/> - <field name="end_date"/> - <field name="currency_id" invisible="1"/> - <field name="price" - widget="monetary" - options="{'field_digits': True}"/> + <field name="acc_operation_id" /> + <field name="acc_injection_id" /> + <field name="acc_delivery_id" /> + <field name="start_date" /> + <field name="end_date" /> + <field name="currency_id" invisible="1" /> + <field + name="price" + widget="monetary" + options="{'field_digits': True}" + /> </tree> </field> </record> @@ -66,16 +70,18 @@ <sheet> <group> <group> - <field name="acc_injection_id"/> - <field name="acc_buyer_id"/> + <field name="acc_injection_id" /> + <field name="acc_buyer_id" /> </group> <group> - <field name="start_date"/> - <field name="end_date"/> - <field name="price" - widget="monetary" - options="{'field_digits': True}"/> - <field name="currency_id"/> + <field name="start_date" /> + <field name="end_date" /> + <field + name="price" + widget="monetary" + options="{'field_digits': True}" + /> + <field name="currency_id" /> </group> </group> </sheet> @@ -88,14 +94,16 @@ <field name="model">acc.sale.price.buyer</field> <field name="arch" type="xml"> <tree string="Prix de vente Acheteur" default_order="start_date desc"> - <field name="acc_injection_id"/> - <field name="acc_buyer_id"/> - <field name="start_date"/> - <field name="end_date"/> - <field name="currency_id" invisible="1"/> - <field name="price" - widget="monetary" - options="{'field_digits': True}"/> + <field name="acc_injection_id" /> + <field name="acc_buyer_id" /> + <field name="start_date" /> + <field name="end_date" /> + <field name="currency_id" invisible="1" /> + <field + name="price" + widget="monetary" + options="{'field_digits': True}" + /> </tree> </field> </record> @@ -113,4 +121,4 @@ </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/menu_views.xml b/views/menu_views.xml index 9e39f277ee1d5acff4e8c5a6a03c89ab20b9c72b..9b74b585654439567141dbee2926a226e2bef500 100644 --- a/views/menu_views.xml +++ b/views/menu_views.xml @@ -1,35 +1,45 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> - <menuitem id="menu_account" - parent="acc_operation.menu_acc" - name="Facturation" - sequence="30"/> + <menuitem + id="menu_account" + parent="acc_operation.menu_acc" + name="Facturation" + sequence="30" + /> - <menuitem id="acc_account_menu" - parent="menu_account" - name="Factures" - sequence="10" - action="acc_account.action_acc_account"/> + <menuitem + id="acc_account_menu" + parent="menu_account" + name="Factures" + sequence="10" + action="acc_account.action_acc_account" + /> - <menuitem id="acc_sale_price_menu" - parent="menu_account" - name="Prix de vente" - sequence="20" - action="acc_sale_price_act_window"/> + <menuitem + id="acc_sale_price_menu" + parent="menu_account" + name="Prix de vente" + sequence="20" + action="acc_sale_price_act_window" + /> - <menuitem id="acc_sale_price_buyer_menu" - parent="menu_account" - name="Prix de vente Acheteur" - sequence="30" - action="acc_sale_price_buyer_act_window"/> + <menuitem + id="acc_sale_price_buyer_menu" + parent="menu_account" + name="Prix de vente Acheteur" + sequence="30" + action="acc_sale_price_buyer_act_window" + /> - <menuitem id="acc_acc_account_menu" - parent="menu_account" - name="Taxes" - sequence="40" - action="acc_action_tax_form"/> + <menuitem + id="acc_acc_account_menu" + parent="menu_account" + name="Taxes" + sequence="40" + action="acc_action_tax_form" + /> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml index 27abd5e63722c0360caa6f9f42f63afc229fafb6..174fbdde12e060254b51859832b1f6ec96875878 100644 --- a/views/res_partner_views.xml +++ b/views/res_partner_views.xml @@ -1,32 +1,35 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> - + <record id="view_partner_form" model="ir.ui.view"> <field name="name">res.partner.form.account</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="acc_operation.view_partner_form"/> + <field name="inherit_id" ref="acc_operation.view_partner_form" /> <field name="arch" type="xml"> <xpath expr="//notebook" position="inside"> <page name="account" string="Facturation"> <group> <group> - <field name="is_tva"/> - <field name="tax_id" attrs="{'invisible': [('is_tva', '=', False)]}"/> - <field name="company_form"/> - <field name="siret"/> - <field name="naf"/> - <field name="rcs"/> + <field name="is_tva" /> + <field + name="tax_id" + attrs="{'invisible': [('is_tva', '=', False)]}" + /> + <field name="company_form" /> + <field name="siret" /> + <field name="naf" /> + <field name="rcs" /> </group> <group> - <field name="iban"/> - <field name="bic"/> + <field name="iban" /> + <field name="bic" /> </group> </group> </page> </xpath> </field> </record> - + </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/wizard/acc_account_surplus_wizard.py b/wizard/acc_account_surplus_wizard.py index 5a9f8a386840faec8ed181a9fc2e73b6244d75a0..44c4d36015b345fa14e56160fe28bb24f6828c71 100644 --- a/wizard/acc_account_surplus_wizard.py +++ b/wizard/acc_account_surplus_wizard.py @@ -12,10 +12,11 @@ class AccAccountSurplusWizard(models.TransientModel): # Fields declaration # ------------------------------------------------------ start_date = fields.Date("Date de début") - account_periodicity = fields.Selection([ - ("3", "Trimestrielle"), - ("12", "Annuelle") - ], string='Périodicité Facturation', default="trimestrial") + account_periodicity = fields.Selection( + [("3", "Trimestrielle"), ("12", "Annuelle")], + string="Périodicité Facturation", + default="trimestrial", + ) # ------------------------------------------------------ # SQL Constraints # ------------------------------------------------------ @@ -41,10 +42,12 @@ class AccAccountSurplusWizard(models.TransientModel): # ------------------------------------------------------ def create_invoice_surplus(self): context = dict(self._context or {}) - if context.get('active_ids', False): - self.env['acc.operation'].browse(context.get('active_ids')).create_account_surplus( - self.start_date, self.account_periodicity) - return {'type': 'ir.actions.act_window_close'} + if context.get("active_ids", False): + self.env["acc.operation"].browse( + context.get("active_ids") + ).create_account_surplus(self.start_date, self.account_periodicity) + return {"type": "ir.actions.act_window_close"} + # ------------------------------------------------------ # Business methods # ------------------------------------------------------ diff --git a/wizard/acc_account_surplus_wizard_views.xml b/wizard/acc_account_surplus_wizard_views.xml index 763b7f5aa3abb9c955d1c69533000f11a723f651..19bbc962da0adefcbfb6174c35267ea65aebf17a 100644 --- a/wizard/acc_account_surplus_wizard_views.xml +++ b/wizard/acc_account_surplus_wizard_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" ?> <odoo> <!-- WIZARD FORM --> <record id="acc_account_surplus_wizard_view_form" model="ir.ui.view"> @@ -7,14 +7,23 @@ <field name="arch" type="xml"> <form string="Création Factures"> <group name="period" string="Période de facturation" col="2"> - <field name="start_date" required="1"/> + <field name="start_date" required="1" /> </group> <group> - <field name="account_periodicity"/> + <field name="account_periodicity" /> </group> <footer> - <button class="btn btn-sm btn-primary" name="create_invoice_surplus" string="Créer" type="object" /> - <button class="btn btn-sm btn-default" special="cancel" string="Annuler"/> + <button + class="btn btn-sm btn-primary" + name="create_invoice_surplus" + string="Créer" + type="object" + /> + <button + class="btn btn-sm btn-default" + special="cancel" + string="Annuler" + /> </footer> </form> </field> @@ -25,7 +34,7 @@ <field name="type">ir.actions.act_window</field> <field name="res_model">acc.account.surplus.wizard</field> <field name="view_mode">form</field> - <field name="view_id" ref="acc_account.acc_account_surplus_wizard_view_form"/> + <field name="view_id" ref="acc_account.acc_account_surplus_wizard_view_form" /> <field name="target">new</field> </record> diff --git a/wizard/acc_account_wizard.py b/wizard/acc_account_wizard.py index 8d2fe8c94b40f9b3523963d80418d84cffb7f1aa..c2dbe2ae34ae500813320ce94f541a2ec7fb3b27 100644 --- a/wizard/acc_account_wizard.py +++ b/wizard/acc_account_wizard.py @@ -1,7 +1,7 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import fields, models class AccAccountWizard(models.TransientModel): @@ -12,12 +12,16 @@ class AccAccountWizard(models.TransientModel): # Fields declaration # ------------------------------------------------------ start_date = fields.Date("Date de début") - account_periodicity = fields.Selection([ - ("1", "Mensuelle"), - ("3", "Trimestrielle"), - ("6", "Semestrielle"), - ("12", "Annuelle") - ], string='Périodicité Facturation', default="1") + account_periodicity = fields.Selection( + [ + ("1", "Mensuelle"), + ("3", "Trimestrielle"), + ("6", "Semestrielle"), + ("12", "Annuelle"), + ], + string="Périodicité Facturation", + default="1", + ) # ------------------------------------------------------ # SQL Constraints # ------------------------------------------------------ @@ -43,10 +47,12 @@ class AccAccountWizard(models.TransientModel): # ------------------------------------------------------ def create_invoice(self): context = dict(self._context or {}) - if context.get('active_ids', False): - self.env['acc.operation'].browse(context.get('active_ids')).create_account( - self.start_date, self.account_periodicity) - return {'type': 'ir.actions.act_window_close'} + if context.get("active_ids", False): + self.env["acc.operation"].browse(context.get("active_ids")).create_account( + self.start_date, self.account_periodicity + ) + return {"type": "ir.actions.act_window_close"} + # ------------------------------------------------------ # Business methods # ------------------------------------------------------ diff --git a/wizard/acc_account_wizard_views.xml b/wizard/acc_account_wizard_views.xml index af7c2c43904c534955d96f281f65c667d00c9ebf..7d5a4c0c4809d95177192388b7c99909b049e20d 100644 --- a/wizard/acc_account_wizard_views.xml +++ b/wizard/acc_account_wizard_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" ?> <odoo> <!-- WIZARD FORM --> <record id="acc_account_wizard_view_form" model="ir.ui.view"> @@ -7,14 +7,23 @@ <field name="arch" type="xml"> <form string="Création Factures"> <group name="period" string="Période de facturation" col="2"> - <field name="start_date" required="1"/> + <field name="start_date" required="1" /> </group> <group> - <field name="account_periodicity"/> + <field name="account_periodicity" /> </group> <footer> - <button class="btn btn-sm btn-primary" name="create_invoice" string="Créer" type="object" /> - <button class="btn btn-sm btn-default" special="cancel" string="Annuler"/> + <button + class="btn btn-sm btn-primary" + name="create_invoice" + string="Créer" + type="object" + /> + <button + class="btn btn-sm btn-default" + special="cancel" + string="Annuler" + /> </footer> </form> </field> @@ -25,7 +34,7 @@ <field name="type">ir.actions.act_window</field> <field name="res_model">acc.account.wizard</field> <field name="view_mode">form</field> - <field name="view_id" ref="acc_account.acc_account_wizard_view_form"/> + <field name="view_id" ref="acc_account.acc_account_wizard_view_form" /> <field name="target">new</field> </record> diff --git a/wizard/acc_sale_price_surplus_wizard.py b/wizard/acc_sale_price_surplus_wizard.py index 53fee58a3f054c3b933501e1d630c19a933feece..936b09ce623ae61503be915d85101e390232b574 100644 --- a/wizard/acc_sale_price_surplus_wizard.py +++ b/wizard/acc_sale_price_surplus_wizard.py @@ -1,7 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models, api - -from dateutil.relativedelta import relativedelta +from odoo import api, fields, models class AccSalePriceWizardSurplus(models.TransientModel): @@ -9,26 +7,28 @@ class AccSalePriceWizardSurplus(models.TransientModel): _description = "Prix de vente Surplus wizard" def _default_operation_id(self): - return self.env.context.get('active_id') + return self.env.context.get("active_id") acc_sale_price_ids = fields.Many2many( "acc.sale.price.buyer", default=lambda self: self._default_sale_price_ids() ) start_date = fields.Date("Début de période", default=fields.Date.context_today) - acc_operation_id = fields.Many2one('acc.operation', default=_default_operation_id) + acc_operation_id = fields.Many2one("acc.operation", default=_default_operation_id) - @api.onchange('start_date') + @api.onchange("start_date") def _onchange_start_date(self): if self.start_date: for price in self.acc_sale_price_ids: price.start_date = self.start_date def _default_sale_price_ids(self): - inj_ids = self.env["acc.counter"].search([ - ('is_injection', '=', True), - ('acc_operation_id', '=', self.env.context.get('active_id')), - ('buyer_id', '!=', False) - ]) + inj_ids = self.env["acc.counter"].search( + [ + ("is_injection", "=", True), + ("acc_operation_id", "=", self.env.context.get("active_id")), + ("buyer_id", "!=", False), + ] + ) return [ ( @@ -37,7 +37,7 @@ class AccSalePriceWizardSurplus(models.TransientModel): { "acc_buyer_id": inj.buyer_id.id, "acc_injection_id": inj.id, - "acc_operation_id": self.env.context.get('active_id'), + "acc_operation_id": self.env.context.get("active_id"), }, ) # # if there isn't a demo line record for the user, create a new one diff --git a/wizard/acc_sale_price_surplus_wizard_views.xml b/wizard/acc_sale_price_surplus_wizard_views.xml index 9ceb43007d4099b21f7335678b5c5fdfc0a92384..d0aa74561d2c846cf64b8d4b1a46f693a91451f5 100644 --- a/wizard/acc_sale_price_surplus_wizard_views.xml +++ b/wizard/acc_sale_price_surplus_wizard_views.xml @@ -6,10 +6,10 @@ <field name="type">form</field> <field name="arch" type="xml"> <form> - <field name="acc_operation_id" invisible="1"/> + <field name="acc_operation_id" invisible="1" /> <group> <group> - <field name="start_date"/> + <field name="start_date" /> </group> </group> <field @@ -38,7 +38,7 @@ <field name="type">ir.actions.act_window</field> <field name="res_model">acc.sale.price.surplus.wizard</field> <field name="view_mode">form</field> - <field name="view_id" ref="x2many_2d_matrix_demo_surplus"/> + <field name="view_id" ref="x2many_2d_matrix_demo_surplus" /> <field name="target">new</field> </record> diff --git a/wizard/acc_sale_price_wizard.py b/wizard/acc_sale_price_wizard.py index 42b7c5fe6abb28ed940df7d7a0c5230d351edf87..dce4c398938f916e5218ee6ba0b282cc5008d4d7 100644 --- a/wizard/acc_sale_price_wizard.py +++ b/wizard/acc_sale_price_wizard.py @@ -1,7 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models, api - -from dateutil.relativedelta import relativedelta +from odoo import api, fields, models class AccSalePriceWizard(models.TransientModel): @@ -9,29 +7,33 @@ class AccSalePriceWizard(models.TransientModel): _description = "Prix de vente wizard" def _default_operation_id(self): - return self.env.context.get('active_id') + return self.env.context.get("active_id") acc_sale_price_ids = fields.Many2many( "acc.sale.price", default=lambda self: self._default_sale_price_ids() ) start_date = fields.Date("Début de période", default=fields.Date.context_today) - acc_operation_id = fields.Many2one('acc.operation', default=_default_operation_id) + acc_operation_id = fields.Many2one("acc.operation", default=_default_operation_id) - @api.onchange('start_date') + @api.onchange("start_date") def _onchange_start_date(self): if self.start_date: for price in self.acc_sale_price_ids: price.start_date = self.start_date def _default_sale_price_ids(self): - inj_ids = self.env["acc.counter"].search([ - ('is_injection', '=', True), - ('acc_operation_id', '=', self.env.context.get('active_id')) - ]) - recs = self.env["res.partner"].search([ - ('is_b', '=', True), - ('acc_operation_id', '=', self.env.context.get('active_id')) - ]) + inj_ids = self.env["acc.counter"].search( + [ + ("is_injection", "=", True), + ("acc_operation_id", "=", self.env.context.get("active_id")), + ] + ) + recs = self.env["res.partner"].search( + [ + ("is_b", "=", True), + ("acc_operation_id", "=", self.env.context.get("active_id")), + ] + ) return [ ( @@ -40,7 +42,7 @@ class AccSalePriceWizard(models.TransientModel): { "acc_delivery_id": rec.id, "acc_injection_id": inj.id, - "acc_operation_id": self.env.context.get('active_id'), + "acc_operation_id": self.env.context.get("active_id"), }, ) # # if there isn't a demo line record for the user, create a new one diff --git a/wizard/acc_sale_price_wizard_views.xml b/wizard/acc_sale_price_wizard_views.xml index 910c317ca98f86cba9abc889654145c442581f18..dbeabb59377083328f3245367e18e8a8fe328075 100644 --- a/wizard/acc_sale_price_wizard_views.xml +++ b/wizard/acc_sale_price_wizard_views.xml @@ -6,10 +6,10 @@ <field name="type">form</field> <field name="arch" type="xml"> <form> - <field name="acc_operation_id" invisible="1"/> + <field name="acc_operation_id" invisible="1" /> <group> <group> - <field name="start_date"/> + <field name="start_date" /> </group> </group> <field @@ -43,7 +43,7 @@ <field name="type">ir.actions.act_window</field> <field name="res_model">acc.sale.price.wizard</field> <field name="view_mode">form</field> - <field name="view_id" ref="x2many_2d_matrix_demo"/> + <field name="view_id" ref="x2many_2d_matrix_demo" /> <field name="target">new</field> </record>