Skip to content
Snippets Groups Projects
Commit cca1c014 authored by Juan Pedro Sánchez's avatar Juan Pedro Sánchez
Browse files

Merge branch 'release/2025-03-11' into dev

parents 602e69cc 9ee9745d
Branches dev
No related tags found
1 merge request!510[REF] ♻️ Make sale order utils more flexible.
Pipeline #194275 passed
Showing
with 161 additions and 122 deletions
{
"name": "Energy Community",
"version": "16.0.0.1.7",
"version": "16.0.0.2.2",
"depends": [
"account",
"account_banking_mandate",
......
......@@ -155,6 +155,9 @@ class LandingPage(models.Model):
)
def to_dict(self):
# TODO: Refactor this image processing. Build it into a method
# images
# company logo
if self.company_logo:
attachment_query = [
("res_id", "=", self.company_id.id),
......@@ -165,10 +168,10 @@ class LandingPage(models.Model):
company_logo_write_date = self._get_image_write_date(
"company_logo", attachment_query
)
else:
company_logo = ""
company_logo_write_date = ""
# primary image
if self.primary_image_file:
primary_image_file = self._get_image_payload("primary_image_file")
primary_image_file_write_date = self._get_image_write_date(
......@@ -177,6 +180,7 @@ class LandingPage(models.Model):
else:
primary_image_file = ""
primary_image_file_write_date = ""
# secondary image
if self.secondary_image_file:
secondary_image_file = self._get_image_payload("secondary_image_file")
secondary_image_file_write_date = self._get_image_write_date(
......@@ -185,15 +189,7 @@ class LandingPage(models.Model):
else:
secondary_image_file = ""
secondary_image_file_write_date = ""
if self.map_place_id:
map_reference = self.map_place_id.slug_id
else:
map_reference = ""
if self.why_become_cooperator == "<p><br></p>":
self.why_become_cooperator = ""
if self.become_cooperator_process == "<p><br></p>":
self.become_cooperator_process = ""
legal_form_dict = dict(_LEGAL_FORM_VALUES)
# returned dict
return {
"landing": {
"id": self.id,
......@@ -206,7 +202,7 @@ class LandingPage(models.Model):
"community_type": self.community_type,
"community_secondary_type": self.community_secondary_type,
"legal_form": get_translation(
source=legal_form_dict[self.community_secondary_type],
source=dict(_LEGAL_FORM_VALUES)[self.community_secondary_type],
lang=self.env.context["lang"],
mods="energy_communities",
),
......@@ -228,9 +224,15 @@ class LandingPage(models.Model):
"company_logo_write_date": company_logo_write_date,
"short_description": self.short_description or "",
"long_description": self.long_description or "",
"why_become_cooperator": self.why_become_cooperator,
"become_cooperator_process": self.become_cooperator_process,
"map_reference": map_reference,
"why_become_cooperator": ""
if self.why_become_cooperator == "<p><br></p>"
or not self.why_become_cooperator
else self.why_become_cooperator,
"become_cooperator_process": ""
if self.become_cooperator_process == "<p><br></p>"
or not self.become_cooperator_process
else self.become_cooperator_process,
"map_reference": self.map_place_id.slug_id if self.map_place_id else "",
"street": self.street or "",
"postal_code": self.postal_code or "",
"city": self.city or "",
......
......@@ -9,7 +9,6 @@ from ..models.res_company import (
_HIERARCHY_LEVEL_BASE_VALUES,
_LEGAL_FORM_VALUES,
)
from ..utils import get_successful_popup_message
_logger = logging.getLogger(__name__)
......@@ -176,10 +175,17 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
self.with_delay().thread_action_accept()
else:
self.thread_action_accept()
return get_successful_popup_message(
_("Company creation successful"),
_("Community creation process has been started."),
)
return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"type": "success",
"title": _("Company creation successful"),
"message": _("Community creation process has been started."),
"sticky": False,
"next": {"type": "ir.actions.act_window_close"},
},
}
def create_company(self):
allow_new_members = False
......
......@@ -12,7 +12,7 @@
# Check https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
"category": "Cooperative management",
"version": "16.0.0.1.7",
"version": "16.0.0.1.9",
"license": "AGPL-3",
# any module necessary for this one to work correctly
"depends": [
......
......@@ -5,6 +5,15 @@ class CrmLead(models.Model):
_name = "crm.lead"
_inherit = "crm.lead"
def _get_metadata_values(self):
metadata = super()._get_metadata_values()
capital_share_meta_entry = self.metadata_line_ids.filtered(
lambda meta: meta.key == "ce_member_mandatory_contribution"
)
if capital_share_meta_entry:
metadata["capital_share"] = capital_share_meta_entry.value
return metadata
def _get_default_community_wizard(self):
creation_dict = super()._get_default_community_wizard()
......
......@@ -12,7 +12,7 @@
# Check https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
"category": "Sales/CRM",
"version": "16.0.0.1.4",
"version": "16.0.0.1.5",
"license": "AGPL-3",
# any module necessary for this one to work correctly
"depends": [
......
......@@ -30,12 +30,12 @@
string="Other COORD"
domain="[('source_id','=', %(energy_communities.ce_source_coord_web_other)d)]"
/>
<filter
<filter
name="ce_source_existing_coord_contact"
string="Contact COORD"
domain="[('source_id','=', %(energy_communities.ce_source_existing_coord_contact)d)]"
/>
<filter
<filter
name="ce_source_existing_coord_info"
string="Info COORD"
domain="[('source_id','=', %(energy_communities.ce_source_existing_coord_info)d)]"
......@@ -50,7 +50,7 @@
string="Newsletter SomComunitats"
domain="[('source_id','=', %(energy_communities.ce_source_general_info)d)]"
/>
<filter
<filter
name="ce_source_general_contact"
string="Contact SomComunitats"
domain="[('source_id','=', %(energy_communities.ce_source_general_contact)d)]"
......
......@@ -249,7 +249,6 @@
<t t-set="value" t-value="ce_member_mandatory_contribution" />
<t t-set="key" t-value="ce_member_mandatory_contribution_key" />
<t t-set="label" t-value="ce_member_mandatory_contribution_label" />
<t t-set="required" t-value="True" />
</t>
</div>
<div class="col-md-12">
......@@ -258,7 +257,6 @@
<t t-set="key" t-value="ce_registration_tool_key" />
<t t-set="label" t-value="ce_registration_tool_label" />
<t t-set="rows" t-value="5" />
<t t-set="required" t-value="True" />
<t
t-set="description"
>Non-computer support, Excels, computer program (which one?)</t>
......@@ -270,7 +268,6 @@
<t t-set="key" t-value="ce_account_management_key" />
<t t-set="label" t-value="ce_account_management_label" />
<t t-set="options" t-value="community_management_options" />
<t t-set="required" t-value="True" />
<t t-set="trigger">ce_management_can_enter_platform</t>
</t>
</div>
......@@ -280,7 +277,6 @@
<t t-set="key" t-value="ce_tax_management_key" />
<t t-set="label" t-value="ce_tax_management_label" />
<t t-set="options" t-value="community_management_options" />
<t t-set="required" t-value="True" />
<t t-set="trigger">ce_management_can_enter_platform</t>
</t>
</div>
......@@ -303,7 +299,6 @@
<t t-set="key" t-value="ce_manager_key" />
<t t-set="label" t-value="ce_manager_label" />
<t t-set="options" t-value="community_manager_options" />
<t t-set="required" t-value="True" />
<t
t-set="trigger"
>ce_manager_headline,ce_manager_firstname,ce_manager_surname,ce_manager_email,ce_manager_phone</t>
......@@ -365,7 +360,6 @@
<t t-set="key" t-value="ce_payment_method_key" />
<t t-set="label" t-value="ce_payment_method_label" />
<t t-set="options" t-value="community_payment_method_options" />
<t t-set="required" t-value="True" />
</t>
</div>
<div class="col-md-12">
......@@ -388,7 +382,6 @@
<t t-set="key" t-value="ce_extra_charges_key" />
<t t-set="label" t-value="ce_extra_charges_label" />
<t t-set="rows" t-value="5" />
<t t-set="required" t-value="True" />
</t>
</div>
<div class="col-md-12">
......@@ -397,7 +390,6 @@
<t t-set="key" t-value="ce_voluntary_contributions_key" />
<t t-set="label" t-value="ce_voluntary_contributions_label" />
<t t-set="rows" t-value="5" />
<t t-set="required" t-value="True" />
</t>
</div>
<div class="col-md-12">
......
from . import components
from . import models
from . import wizards
import logging
from odoo import SUPERUSER_ID, api
logger = logging.getLogger(__name__)
def post_setup_intercompany_invoicing_config(cr, registry):
logger.info("Running Inter company setup")
env = api.Environment(cr, SUPERUSER_ID, {})
companies = env["res.company"].search([])
for company in companies:
company.write({"invoice_auto_validation": False})
logger.info(
"Inter company invoice auto validation disabled by default on all companies."
)
......@@ -9,7 +9,7 @@
"author": "Som comunitats",
"website": "https://coopdevs.org",
"category": "Contract Management",
"version": "16.0.0.1.1",
"version": "16.0.0.1.2",
# any module necessary for this one to work correctly
"depends": [
"base",
......@@ -41,10 +41,11 @@
"views/res_partner_views.xml",
"views/sale_order_views.xml",
"views/service_invoicing_views.xml",
"views/menus.xml",
"wizards/service_invoicing_action.xml",
"wizards/service_invoicing_action_create.xml",
"views/menus.xml",
],
"post_init_hook": "post_setup_intercompany_invoicing_config",
# only loaded in demonstration mode
"demo": [],
}
......@@ -7,20 +7,14 @@ class AccountMove(models.Model):
_name = "account.move"
_inherit = ["account.move", "pack.type.mixin"]
ref_invoice_id = fields.Many2one(
comodel_name="account.move",
compute="_compute_ref_invoice_id_related_contract_id_is_contract",
compute_sudo=True,
store=False,
)
related_contract_id = fields.Many2one(
comodel_name="contract.contract",
compute="_compute_ref_invoice_id_related_contract_id_is_contract",
compute="_compute_related_contract_id_is_contract",
compute_sudo=True,
store=False,
store=True,
)
is_contract = fields.Boolean(
compute="_compute_ref_invoice_id_related_contract_id_is_contract",
compute="_compute_related_contract_id_is_contract",
compute_sudo=True,
store=True,
)
......@@ -29,26 +23,20 @@ class AccountMove(models.Model):
string="Related community",
related="related_contract_id.community_company_id",
domain="[('hierarchy_level','=','community')]",
store=True,
)
@api.depends("invoice_line_ids", "ref")
def _compute_ref_invoice_id_related_contract_id_is_contract(self):
@api.depends("invoice_line_ids", "auto_invoice_id")
def _compute_related_contract_id_is_contract(self):
for record in self:
record.ref_invoice_id = False
record.related_contract_id = False
record.is_contract = False
rel_inv = False
if record.ref:
rel_inv = (
self.env["account.move"]
.sudo()
.search([("name", "=", record.ref)], limit=1)
)
if rel_inv:
record.ref_invoice_id = rel_inv.id
record.is_contract = rel_inv.is_contract
if rel_inv.related_contract_id:
record.related_contract_id = rel_inv.related_contract_id.id
if record.auto_invoice_id:
record.is_contract = record.auto_invoice_id.is_contract
if record.auto_invoice_id.related_contract_id:
record.related_contract_id = (
record.auto_invoice_id.related_contract_id.id
)
else:
if record.invoice_line_ids:
first_move_line = record.invoice_line_ids[0]
......@@ -57,14 +45,15 @@ class AccountMove(models.Model):
record.related_contract_id = rel_contract.id
record.is_contract = True
def custom_compute_pack_type(self):
self._set_custom_pack_type_on_invoice()
@api.depends("ref", "invoice_line_ids")
@api.depends("invoice_line_ids", "auto_invoice_id")
def _compute_pack_type(self):
super()._compute_pack_type()
# define configuration intercompany journal
def custom_compute_pack_type(self):
self._set_custom_pack_type_on_invoice()
# Inter Company:
# define configuration journal
def _prepare_invoice_data(self, dest_company):
inv_data = super()._prepare_invoice_data(dest_company)
if (
......@@ -75,3 +64,15 @@ class AccountMove(models.Model):
"journal_id"
] = dest_company.sudo().service_invoicing_purchase_journal_id.id
return inv_data
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
# Inter Company:
# propagate name from origin invoice
@api.model
def _prepare_account_move_line(self, dest_move, dest_company):
vals = super()._prepare_account_move_line(dest_move, dest_company)
vals["name"] = self.name
return vals
......@@ -274,8 +274,8 @@ class ContractContract(models.Model):
]
)
for invoice in all_received_invoices:
if invoice.sudo().ref_invoice_id:
if invoice.sudo().ref_invoice_id.id in issued_invoices:
if invoice.sudo().auto_invoice_id:
if invoice.sudo().auto_invoice_id.id in issued_invoices:
received_invoices.append(invoice.id)
return received_invoices
......
<odoo>
<record id="account_move_search" model="ir.ui.view">
<field name="name">account.move search view (in service invoicing)</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_invoice_filter" />
<field name="arch" type="xml">
<filter name="groupy_by_partner" position="after">
<filter
string="Related community"
name="group_by_related_community"
domain="[]"
context="{'group_by':'related_community_company_id'}"
/>
</filter>
</field>
</record>
<record id="account_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit</field>
<field name="model">account.move</field>
......@@ -9,8 +24,9 @@
<field name="is_contract" invisible="True" />
<field name="invoice_origin" attrs="{'invisible': [('is_contract','=',False)]}" />
<field name="related_contract_id" attrs="{'invisible': [('is_contract','=',False)]}" />
<field name="related_community_company_id" attrs="{'invisible': [('pack_type' ,'=', 'platform_pack')]}" />
<field name="related_community_company_id" attrs="{'invisible': [('pack_type' ,'!=', 'platform_pack')]}" />
</xpath>
</field>
</record>
</odoo>
......@@ -32,14 +32,14 @@
<menuitem
name="Service invoices issued"
id="view_service_invoices_issued_menu"
action="view_service_invoices_issued_window"
action="view_service_invoices_issued_act_window"
groups="energy_communities.role_platform_admin_res_groups"
sequence="500"
/>
<menuitem
name="Service invoices received"
id="view_service_invoices_received_menu"
action="view_service_invoices_received_window"
action="view_service_invoices_received_act_window"
groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
sequence="500"
/>
......
......@@ -9,6 +9,22 @@
<field name="domain">[('community_company_id','!=',False)]</field>
<field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
</record>
<record
id="action_view_service_invoicing_tree_platform_manager"
model="ir.actions.act_window.view"
>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_service_invoicing_tree"/>
<field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
</record>
<record
id="action_view_contract_contract_customer_form_platform_manager"
model="ir.actions.act_window.view"
>
<field name="view_mode">form</field>
<field name="view_id" ref="view_contract_contract_customer_form_platform_admin"/>
<field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
</record>
<record
id="view_service_invoicing_window_coord_admin"
......@@ -20,6 +36,22 @@
<field name="domain">[('community_company_id','!=',False)]</field>
<field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
</record>
<record
id="action_view_service_invoicing_tree_coord_admin"
model="ir.actions.act_window.view"
>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_service_invoicing_tree"/>
<field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
</record>
<record
id="action_view_contract_contract_customer_form_coord_admin"
model="ir.actions.act_window.view"
>
<field name="view_mode">form</field>
<field name="view_id" ref="view_contract_contract_customer_form_coord_admin"/>
<field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
</record>
<record
id="view_service_packs_window"
......@@ -52,23 +84,25 @@
</record>
<record
id="view_service_invoices_issued_window"
id="view_service_invoices_issued_act_window"
model="ir.actions.act_window"
>
<field name="name">Service invoices (issued)</field>
<field name="res_model">account.move</field>
<field name="view_mode">tree,form</field>
<field name="domain" eval="[('move_type', 'in', ['out_invoice', 'out_refund']), ('pack_type', '=', 'platform_pack')]"/>
<field name="context">{"default_move_type": "out_invoice","search_default_group_by_related_community":1}</field>
</record>
<record
id="view_service_invoices_received_window"
id="view_service_invoices_received_act_window"
model="ir.actions.act_window"
>
<field name="name">Service invoices (received)</field>
<field name="res_model">account.move</field>
<field name="view_mode">tree,form</field>
<field name="domain" eval="[('move_type', 'in', ['in_invoice', 'in_refund']), ('pack_type', '=', 'platform_pack')]"/>
<field name="context">{"default_move_type": "in_invoice","search_default_group_by_related_community":1}</field>
</record>
<record
......@@ -81,44 +115,4 @@
<field name="domain">[('service_invoicing_action','!=','none')]</field>
</record>
<record
id="action_view_service_invoicing_tree_platform_manager"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_service_invoicing_tree"/>
<field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
</record>
<record
id="action_view_service_invoicing_tree_coord_admin"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_service_invoicing_tree"/>
<field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
</record>
<record
id="action_view_contract_contract_customer_form_platform_manager"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_contract_contract_customer_form_platform_admin"/>
<field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
</record>
<record
id="action_view_contract_contract_customer_form_coord_admin"
model="ir.actions.act_window.view"
>
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_contract_contract_customer_form_coord_admin"/>
<field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
</record>
</odoo>
......@@ -9,7 +9,7 @@
"author": "Coopdevs Treball SCCL & Som Energia SCCL",
"website": "https://coopdevs.org",
"category": "Customizations",
"version": "16.0.0.1.7",
"version": "16.0.0.2.1",
"license": "AGPL-3",
"depends": [
"base",
......@@ -61,7 +61,7 @@
"wizards/change_state_inscription_wizard_views.xml",
"reports/selfconsumption_reports.xml",
"reports/invoice_template.xml",
"wizards/change_distribution_table_import_wizard.xml"
"wizards/change_distribution_table_import_wizard.xml",
],
"demo": [
"demo/energy_selfconsumption_demo.xml",
......
......@@ -210,11 +210,11 @@ class Selfconsumption(models.Model):
"type": "ir.actions.act_window",
"name": "Contracts",
"views": [
[self.env.ref("energy_selfconsumption.contract_tree_view").id, "tree"],
[
(self.env.ref("energy_selfconsumption.contract_tree_view").id, "tree"),
(
self.env.ref("contract.contract_contract_customer_form_view").id,
"form",
],
),
],
"res_model": "contract.contract",
"domain": [("project_id", "=", self.id)],
......
......@@ -24,12 +24,12 @@
<field name="arch" type="xml">
<xpath expr="/search" position="inside">
<group expand="1" string="Group By">
<filter
string="Next Period Date Start"
name="filter_next_period_date_end"
domain="[]"
context="{'group_by':'next_period_date_end'}"
/>
<filter
string="Next Period Date Start"
name="filter_next_period_date_end"
domain="[]"
context="{'group_by':'next_period_date_end'}"
/>
</group>
</xpath>
</field>
......
import setuptools
setuptools.setup(
name="odoo_addon_energy_communities",
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
import setuptools
setuptools.setup(
name="odoo_addon_energy_communities_cooperator",
setup_requires=['setuptools-odoo'],
odoo_addon=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