Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] contract: Add contract lines entry point for reporting #1175

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contract/models/abstract_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class ContractAbstractContractLine(models.AbstractModel):
_description = "Abstract Recurring Contract Line"

product_id = fields.Many2one("product.product", string="Product")

name = fields.Text(string="Description", required=True)
partner_id = fields.Many2one(
comodel_name="res.partner", related="contract_id.partner_id"
)
quantity = fields.Float(default=1.0, required=True)
product_uom_category_id = fields.Many2one( # Used for domain of field uom_id
comodel_name="uom.category",
Expand Down
7 changes: 7 additions & 0 deletions contract/views/contract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -686,4 +686,11 @@
action="action_supplier_contract"
sequence="99"
/>

<!-- Base menu for contracts reporting -->
<record model="ir.ui.menu" id="menu_contract_reporting">
<field name="name">Contracts</field>
<field name="parent_id" ref="account.menu_finance_reports" />
<field name="sequence" eval="40" />
</record>
</odoo>
100 changes: 100 additions & 0 deletions contract/views/contract_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,104 @@
</field>
</field>
</record>

<!--TREE view - reporting -->
<record id="contract_line_report_tree_view" model="ir.ui.view">
<field name="name">contract.line report tree view (in contract)</field>
<field name="model">contract.line</field>
<field name="arch" type="xml">
<tree>
<field name="contract_id" />
<field name="partner_id" />
<field name="product_id" />
<field
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
<field name="quantity" />
<field name="uom_id" />
<field name="price_unit" />
<field name="discount" groups="base.group_no_one" />
<field name="price_subtotal" />
<field name="date_start" />
<field name="date_end" />
<field name="recurring_interval" />
<field name="recurring_rule_type" />
<field name="recurring_next_date" />
<field name="last_date_invoiced" />
<field name="is_auto_renew" />
<field name="is_canceled" />
<field name="state" />

</tree>
</field>
</record>

<!-- Contract lines search view - reporting -->
<record id="contract_line_search_view" model="ir.ui.view">
<field name="name">contract.line search view (in contract)</field>
<field name="model">contract.line</field>
<field name="arch" type="xml">
<search>
<field name="contract_id" />
<field name="product_id" />
<field name="name" />
<field name="date_start" />
<field name="date_end" />
<field name="recurring_next_date" />
<field name="last_date_invoiced" />
<separator />
<filter name="is_canceled" domain="[('is_canceled', '=', True)]" />
<filter name="is_auto_renew" domain="[('is_auto_renew', '=', True)]" />
<group expand="0" string="Group By...">
<filter
string="Contract"
name="group_by_contract"
domain="[]"
context="{'group_by':'contract_id'}"
/>
</group>
</search>
</field>
</record>

<!-- Add action for contract lines -->
<record id="action_supplier_contract_lines" model="ir.actions.act_window">
<field name="name">Supplier Contract Lines</field>
<field name="res_model">contract.line</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('contract_id.contract_type', '=', 'purchase')]</field>
<field name="context">
{'search_default_group_by_contract': 1}
</field>
<field name="search_view_id" ref="contract_line_search_view" />
<field name="view_id" ref="contract_line_report_tree_view" />
</record>

<record id="action_customer_contract_lines" model="ir.actions.act_window">
<field name="name">Customer Contract Lines</field>
<field name="res_model">contract.line</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('contract_id.contract_type', '=', 'sale')]</field>
<field name="context">
{'search_default_group_by_contract': 1}
</field>
<field name="search_view_id" ref="contract_line_search_view" />
<field name="view_id" ref="contract_line_report_tree_view" />
</record>

<record model="ir.ui.menu" id="menu_customer_contract_line_report">
<field name="name">Customer Contract lines</field>
<field name="parent_id" ref="contract.menu_contract_reporting" />
<field name="action" ref="contract.action_customer_contract_lines" />
<field name="sequence" eval="10" />
</record>
<record model="ir.ui.menu" id="menu_supplier_contract_line_report">
<field name="name">Supplier Contract lines</field>
<field name="parent_id" ref="contract.menu_contract_reporting" />
<field name="action" ref="contract.action_supplier_contract_lines" />
<field name="sequence" eval="11" />
</record>

</odoo>
Loading