-
Emanuel Buzey authored
In this commit, I have implemented the following developments in the 'electric_distribution' module: 1. Created a new model for electric distribution company. 2. Added a menu with corresponding form and tree views. These views are now only visible to users with admin or platform-level access rights in the Settings section. 3. Implemented the standard Odoo import functionality to allow users to import a list of electric distribution companies efficiently. 4. The new companies, are added without removing any existing data. This ensures data continuity and prevents data loss. 5. The form view of the model, include all the fields required by the CNMC list.
Emanuel Buzey authoredIn this commit, I have implemented the following developments in the 'electric_distribution' module: 1. Created a new model for electric distribution company. 2. Added a menu with corresponding form and tree views. These views are now only visible to users with admin or platform-level access rights in the Settings section. 3. Implemented the standard Odoo import functionality to allow users to import a list of electric distribution companies efficiently. 4. The new companies, are added without removing any existing data. This ensures data continuity and prevents data loss. 5. The form view of the model, include all the fields required by the CNMC list.
distributor.py 1.19 KiB
from odoo import api, fields, models
class Distributor(models.Model):
_name = "energy_project.distributor"
_description = "Electrical Distributor"
nif = fields.Char(string="NIF empresa")
order = fields.Char(string="Nº de orden")
name = fields.Char(string="Nombre empresa")
phone = fields.Char(string="Teléfono Att cliente gratuito")
portal = fields.Char(string="Portal de medidas")
def _load_records(self, data_list, update=False):
new_data_list = []
for data in data_list:
values = data["values"]
if values.get("order"):
xml_id = "energy_project.distributor_%s" % (values.get("order"))
new_data_list.append(dict(xml_id=xml_id, values=values, noupdate=True))
else:
new_data_list.append(data)
return super()._load_records(new_data_list, update)
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
def button_open_distributors(self):
return {
"type": "ir.actions.act_window",
"res_model": "energy_project.distributor",
"view_mode": "tree,form",
"target": "current",
}