Skip to content
Snippets Groups Projects
Commit 329830bc authored by daniquilez's avatar daniquilez
Browse files

[IMP] :sparkles: Service invoicing batch creation redirects to contracts tree view

parent a38a87fa
Branches dev
No related tags found
2 merge requests!504Release 2025-03-11,!502Refactor module energy communities service invoicing
......@@ -232,6 +232,15 @@ class ContractContract(models.Model):
contract.set_close_status_type_by_date()
return True
# TODO: It would be very cool being able to use this methods on service_invoicing xml act_window definition
@api.model
def get_service_invoicing_views_domain(self):
return [("community_company_id", "!=", False)]
@api.model
def get_service_invoicing_views_context(self):
return {"search_default_not_finished": 1, "search_default_paused": 1}
# TODO: Not working. Lack of access rules
def _get_received_invoices_ids(self):
received_invoices = []
......
......@@ -22,29 +22,27 @@ _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
def service_invoicing_tree_view(env: Environment):
# return {
# "type": "ir.actions.act_window",
# "res_model": "contract.contract",
# "views": [
# (
# env.ref(
# "energy_communities_service_invoicing.view_service_invoicing_tree"
# ).id,
# "tree",
# ),
# ],
# "target": "current",
# }
return {
# 'name': _('test'),
"name": _("Service Contracts"),
"view_type": "tree",
"view_mode": "tree",
"view_id": env.ref(
"energy_communities_service_invoicing.view_service_invoicing_window_platform_manager"
).id,
"view_mode": "tree,form",
"views": [
(
env.ref(
"energy_communities_service_invoicing.view_service_invoicing_tree"
).id,
"tree",
),
(
env.ref(
"energy_communities_service_invoicing.view_contract_contract_customer_form_platform_admin"
).id,
"form",
),
],
"res_model": "contract.contract",
# 'context': "{'type':'out_invoice'}",
"context": env["contract.contract"].get_service_invoicing_views_context(),
"domain": env["contract.contract"].get_service_invoicing_views_domain(),
"type": "ir.actions.act_window",
"target": "current",
}
......
......@@ -54,6 +54,61 @@
</field>
</record>
<record id="view_contract_contract_customer_form_platform_admin" model="ir.ui.view">
<field name="name">contract.contract.form (in energy_communities service_invoicing platform admin)</field>
<field name="model">contract.contract</field>
<field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<field name="status" widget="statusbar" />
</xpath>
<xpath expr="//button[@name='action_preview']" position="after">
<button
name="action_activate_contract"
type="object"
string="Activate"
attrs="{'invisible':[('status','not in',['paused'])]}"
/>
<button
name="action_modify_contract"
type="object"
string="Modify"
attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
/>
<button
name="action_close_contract"
type="object"
string="Close"
attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
/>
<button
name="action_reopen_contract"
type="object"
string="Reopen"
attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
/>
</xpath>
<xpath expr="//field[@name='partner_id']" position="after">
<field name="community_company_id" />
</xpath>
<xpath expr="//field[@name='pricelist_id']" position="after">
<field name="service_pack_id" />
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="date_start" />
<field name="last_date_invoiced" />
<field name="recurring_next_date" />
<field name="date_end" />
<field name="discount" />
<field name="predecessor_contract_id" />
<field name="successor_contract_id" />
<field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
<field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
<field name="sale_order_id" />
</xpath>
</field>
</record>
<record id="view_contract_contract_customer_form_coord_admin" model="ir.ui.view">
<field name="name">contract.contract.form (in energy_communities service_invoicing coordinator)</field>
<field name="model">contract.contract</field>
......@@ -110,58 +165,5 @@
</field>
</record>
<record id="view_contract_contract_customer_form_platform_admin" model="ir.ui.view">
<field name="name">contract.contract.form (in energy_communities service_invoicing platform admin)</field>
<field name="model">contract.contract</field>
<field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<field name="status" widget="statusbar" />
</xpath>
<xpath expr="//button[@name='action_preview']" position="after">
<button
name="action_activate_contract"
type="object"
string="Activate"
attrs="{'invisible':[('status','not in',['paused'])]}"
/>
<button
name="action_modify_contract"
type="object"
string="Modify"
attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
/>
<button
name="action_close_contract"
type="object"
string="Close"
attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
/>
<button
name="action_reopen_contract"
type="object"
string="Reopen"
attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
/>
</xpath>
<xpath expr="//field[@name='partner_id']" position="after">
<field name="community_company_id" />
</xpath>
<xpath expr="//field[@name='pricelist_id']" position="after">
<field name="service_pack_id" />
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="date_start" />
<field name="last_date_invoiced" />
<field name="recurring_next_date" />
<field name="date_end" />
<field name="discount" />
<field name="predecessor_contract_id" />
<field name="successor_contract_id" />
<field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
<field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
<field name="sale_order_id" />
</xpath>
</field>
</record>
</odoo>
......@@ -3,12 +3,10 @@
id="view_service_invoicing_window_platform_manager"
model="ir.actions.act_window"
>
<field name="name">Service Invoicing</field>
<field name="name">Service Contracts</field>
<field name="res_model">contract.contract</field>
<field name="view_mode">tree,form</field>
<field name="domain">
[('community_company_id','!=',False)]
</field>
<field name="domain">[('community_company_id','!=',False)]</field>
<field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
</record>
......@@ -16,12 +14,10 @@
id="view_service_invoicing_window_coord_admin"
model="ir.actions.act_window"
>
<field name="name">Service Invoicing</field>
<field name="name">Service Contracts</field>
<field name="res_model">contract.contract</field>
<field name="view_mode">tree,form</field>
<field name="domain">
[('community_company_id','!=',False)]
</field>
<field name="domain">[('community_company_id','!=',False)]</field>
<field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
</record>
......
......@@ -4,7 +4,6 @@ from odoo.tools.translate import _
from odoo.addons.energy_communities.utils import (
contract_utils,
get_successful_popup_message,
sale_order_utils,
)
......@@ -13,6 +12,7 @@ from ..utils import (
get_existing_open_contract,
raise_existing_same_open_contract_error,
service_invoicing_form_view_for_platform_admins,
service_invoicing_tree_view,
)
......@@ -98,10 +98,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
community.parent_id,
self.env.company.service_invoicing_payment_mode_id,
)
return get_successful_popup_message(
_("Service invoicing contracts successfully created"),
_("Visit Community Management section to manage them"),
)
return service_invoicing_tree_view(self.env)
else:
service_invoicing_id = self._execute_create_one(
self.community_company_id, self.company_id, self.payment_mode_id
......
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