Skip to content
Snippets Groups Projects
Commit 8e3f2036 authored by emanuel buzey's avatar emanuel buzey
Browse files

[IMP] Calculate PS name format, adjust views in Supply Point and PSA

1. Improve PS name calculation: Changed the calculation logic for PS names
   follow the format "First Name Last Name - Address". This helps the user with searching for PS.

2. The name field of the supply point form: is auto-filled using the name of the owner - street. This is related to the previous point.

3. Optimize PSA view: Removed name display in PSA view for
   Avoid duplication when displayed in modal forms. This improves vision
   interface consistency.
parent 47660010
No related branches found
No related tags found
2 merge requests!195[REL] 14.0.2.0.0,!194[FIX] Energy_selfconsumption: Added street field to view and added web_m2x_options module to modify "many2one" fields giving new control options.
Pipeline #46089 passed with warnings
from odoo import _, fields, models
from odoo import _, api, fields, models
class SupplyPoint(models.Model):
......@@ -14,7 +14,7 @@ class SupplyPoint(models.Model):
)
}
name = fields.Char(required=True)
name = fields.Char(compute="_compute_supply_point_name", store=True)
code = fields.Char(string="CUPS", required=True)
owner_id = fields.Many2one(
"res.partner",
......@@ -53,3 +53,11 @@ class SupplyPoint(models.Model):
"supply_point_id",
readonly=True,
)
@api.depends("owner_id", "street")
def _compute_supply_point_name(self):
for record in self:
if record.owner_id and record.street:
record.name = f"{record.owner_id.name} - {record.street}"
else:
record.name = _("New Supply Point")
......@@ -81,7 +81,6 @@
options="{'no_create': True, 'search_more': True}"
domain="[('id', 'in', supply_point_filtered_ids)]"
/>
<field name="owner_id" />
<field name="code" />
<field
name="coefficient"
......
......@@ -11,7 +11,7 @@
<div class="oe_title">
<label for="name" />
<h1>
<field name="name" placeholder="Title" />
<field name="name" placeholder="Title" readonly="1" />
</h1>
</div>
<group>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment