Skip to content
Snippets Groups Projects
Commit 4c946f12 authored by Daniil Digtyar Vasilieva's avatar Daniil Digtyar Vasilieva :call_me:
Browse files

[IMP] filter out supply already in the distribution table

parent ee5bab76
No related branches found
No related tags found
3 merge requests!138Hotfix setup name error,!134Release v14.0.1.1.6,!126[IMP] Feature/add energy selfconsumption distribution table
This commit is part of merge request !134. Comments created here will be created in the context of that merge request.
from odoo import fields, models, api
class SupplyPointAssignation(models.Model):
_name = 'energy_selfconsumption.supply_point_assignation'
_description = 'Supply Point Assignation'
@api.depends('distribution_table_id')
def _compute_supply_point_filtered_ids(self):
'''
List of supply point of partners subscribed to the project and not in the list of the distribution table to
prevent multiple assignations of same supply point.
Used to filter out in the view.
:return:
'''
for record in self:
record.supply_point_filtered_ids = record.distribution_table_id.selfconsumption_project_id.inscription_ids.mapped('partner_id.supply_ids')
record.supply_point_filtered_ids = \
record.distribution_table_id.selfconsumption_project_id.inscription_ids.mapped('partner_id.supply_ids') \
.filtered_domain([('id', 'not in', record.distribution_table_id.supply_point_assignation_ids.mapped(
'supply_point_id.id'))])
distribution_table_id = fields.Many2one('energy_selfconsumption.distribution_table', required=True)
supply_point_id = fields.Many2one('energy_selfconsumption.supply_point', required=True)
......
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