mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - show related sale orders in contract form
This commit is contained in:
@@ -10,7 +10,11 @@
|
||||
'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/oca/contract',
|
||||
'depends': ['product', 'contract_sale'],
|
||||
'data': ['views/product_template.xml', 'views/sale_order.xml'],
|
||||
'data': [
|
||||
'views/contract.xml',
|
||||
'views/product_template.xml',
|
||||
'views/sale_order.xml'
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import contract
|
||||
from . import contract_line
|
||||
from . import product_template
|
||||
from . import sale_order
|
||||
|
||||
35
product_contract/models/contract.py
Normal file
35
product_contract/models/contract.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright 2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.translate import _
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
_name = 'account.analytic.account'
|
||||
_inherit = 'account.analytic.account'
|
||||
|
||||
sale_order_count = fields.Integer(compute="_compute_sale_order_count")
|
||||
|
||||
@api.depends('recurring_invoice_line_ids')
|
||||
def _compute_sale_order_count(self):
|
||||
for rec in self:
|
||||
rec.sale_order_count = len(
|
||||
rec.recurring_invoice_line_ids.mapped(
|
||||
'sale_order_line_id.order_id'
|
||||
)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_view_sales_orders(self):
|
||||
self.ensure_one()
|
||||
orders = self.recurring_invoice_line_ids.mapped(
|
||||
'sale_order_line_id.order_id'
|
||||
)
|
||||
return {
|
||||
"name": _("Sales Orders"),
|
||||
"view_mode": "tree,form",
|
||||
"res_model": "sale.order",
|
||||
"type": "ir.actions.act_window",
|
||||
"domain": [("id", "in", orders.ids)],
|
||||
}
|
||||
29
product_contract/views/contract.xml
Normal file
29
product_contract/views/contract.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 ACSONE SA/NV.
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
-->
|
||||
<odoo>
|
||||
|
||||
<record id="account_analytic_account_recurring_form_form"
|
||||
model="ir.ui.view">
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id"
|
||||
ref="contract.account_analytic_account_recurring_form_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button class="oe_stat_button" name="action_view_sales_orders"
|
||||
type="object" icon="fa-edit"
|
||||
attrs="{'invisible': [('sale_order_count', '=', 0)]}">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="sale_order_count"/>
|
||||
</span>
|
||||
<span class="o_stat_text">Sale Orders</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user