From 58dcea0835b6d47ebe449ba4334c4bf2486d8fe8 Mon Sep 17 00:00:00 2001 From: Emanuel Buzey <buzeyemanuel@gmail.com> Date: Mon, 9 Oct 2023 13:39:25 +0200 Subject: [PATCH] [FIX] energy_project: remove product_ids --- energy_project/models/project.py | 4 --- .../models/selfconsumption.py | 26 +++++++------------ .../views/selfconsumption_views.xml | 14 ---------- .../wizards/define_invoicing_mode_wizard.py | 11 ++------ 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/energy_project/models/project.py b/energy_project/models/project.py index f4d642305..2cf03d35c 100644 --- a/energy_project/models/project.py +++ b/energy_project/models/project.py @@ -43,7 +43,3 @@ class Project(models.Model): required=True, default=lambda self: self.env.ref("base.es"), ) - product_ids = fields.One2many( - "product.product", - "project_id", - ) diff --git a/energy_selfconsumption/models/selfconsumption.py b/energy_selfconsumption/models/selfconsumption.py index 89c3659cd..0aa999f94 100644 --- a/energy_selfconsumption/models/selfconsumption.py +++ b/energy_selfconsumption/models/selfconsumption.py @@ -3,6 +3,15 @@ from datetime import datetime from odoo import _, fields, models from odoo.exceptions import ValidationError +INVOICING_VALUES = [ + ("power_acquired", _("Power Acquired")), + ("energy_delivered", _("Energy Delivered")), + ( + "energy_delivered_variable", + _("Energy Delivered Variable Hourly Coefficient"), + ), +] + class Selfconsumption(models.Model): _name = "energy_selfconsumption.selfconsumption" @@ -46,10 +55,6 @@ class Selfconsumption(models.Model): else: record.report_distribution_table = False - def _compute_invoicing_name(self): - for record in self: - record.invoicing_mode = record.project_id.product_ids[0].name.split("-")[0] - project_id = fields.Many2one( "energy_project.project", required=True, ondelete="cascade" ) @@ -80,7 +85,7 @@ class Selfconsumption(models.Model): ) inscription_count = fields.Integer(compute=_compute_inscription_count) contracts_count = fields.Integer(compute=_compute_contract_count) - invoicing_mode = fields.Char(compute=_compute_invoicing_name) + invoicing_mode = fields.Char() def get_distribution_tables(self): self.ensure_one() @@ -115,17 +120,6 @@ class Selfconsumption(models.Model): "context": {"create": True, "default_project_id": self.id}, } - def get_product(self): - self.ensure_one() - return { - "type": "ir.actions.act_window", - "name": "Product", - "view_mode": "tree,form", - "res_model": "product.product", - "domain": [("project_id", "=", self.id)], - "context": {"create": True, "default_project_id": self.id}, - } - def distribution_table_state(self, actual_state, new_state): distribution_table_to_activate = self.distribution_table_ids.filtered( lambda table: table.state == actual_state diff --git a/energy_selfconsumption/views/selfconsumption_views.xml b/energy_selfconsumption/views/selfconsumption_views.xml index 203b3efd0..2d41095be 100644 --- a/energy_selfconsumption/views/selfconsumption_views.xml +++ b/energy_selfconsumption/views/selfconsumption_views.xml @@ -133,20 +133,6 @@ /> </button> - <button - class="oe_stat_button" - type="object" - name="get_product" - icon="fa-file-text" - attrs="{'visible': [('invoicing_mode', '!=', False)]}" - > - <field - string="Invoicing Mode" - name="invoicing_mode" - widget="statinfo" - /> - </button> - </div> <widget name="web_ribbon" diff --git a/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py b/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py index 7fc52332a..d5c29b067 100644 --- a/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py +++ b/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py @@ -1,18 +1,11 @@ from odoo import _, fields, models +from ..models.selfconsumption import INVOICING_VALUES + class ContractGenerationWizard(models.TransientModel): _name = "energy_selfconsumption.define_invoicing_mode.wizard" - INVOICING_VALUES = [ - ("power_acquired", _("(PA) Power Acquired")), - ("energy_delivered", _("(ED) Energy Delivered")), - ( - "energy_delivered_variable", - _("(VHC) Energy Delivered Variable Hourly Coefficient"), - ), - ] - RULE_TYPE_OPTIONS = [ ("daily", _("Day(s)")), ("weekly", _("Week(s)")), -- GitLab