[IMP] project,*: filter AAL to avoid compute many times in profitability
This commit is contained in:
committed by
Laurent Stukkens (LTU)
parent
08112964f7
commit
812940237d
@@ -743,6 +743,9 @@ class Project(models.Model):
|
||||
self.ensure_one()
|
||||
return True
|
||||
|
||||
def _get_profitability_aal_domain(self):
|
||||
return [('account_id', 'in', self.analytic_account_id.ids)]
|
||||
|
||||
def _get_profitability_items(self):
|
||||
return {
|
||||
'revenues': {'data': [], 'total': {'invoiced': 0.0, 'to_invoice': 0.0}},
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.osv import expression
|
||||
|
||||
class Project(models.Model):
|
||||
_inherit = 'project.project'
|
||||
@@ -61,9 +62,15 @@ class Project(models.Model):
|
||||
'costs': {'id': section_id, 'billed': -expense_data['untaxed_amount'], 'to_bill': 0.0},
|
||||
}
|
||||
|
||||
def _get_profitability_items(self, with_action=True):
|
||||
profitability_data = super()._get_profitability_items(with_action)
|
||||
expenses_data = self._get_expenses_profitability_items(with_action)
|
||||
def _get_profitability_aal_domain(self):
|
||||
return expression.AND([
|
||||
super()._get_profitability_aal_domain(),
|
||||
['|', ('move_id', '=', False), ('move_id.expense_id', '=', False)],
|
||||
])
|
||||
|
||||
def _get_profitability_items(self):
|
||||
profitability_data = super()._get_profitability_items()
|
||||
expenses_data = self._get_expenses_profitability_items()
|
||||
if expenses_data:
|
||||
if 'revenues' in expenses_data:
|
||||
revenues = profitability_data['revenues']
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _lt
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
@@ -36,6 +37,12 @@ class Project(models.Model):
|
||||
# Project Updates
|
||||
# ----------------------------
|
||||
|
||||
def _get_profitability_aal_domain(self):
|
||||
return expression.AND([
|
||||
super()._get_profitability_aal_domain(),
|
||||
[('category', '!=', 'manufacturing_order')],
|
||||
])
|
||||
|
||||
def _get_profitability_items(self):
|
||||
profitability_items = super()._get_profitability_items()
|
||||
mrp_category = 'manufacturing_order'
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _, _lt
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
@@ -63,6 +64,12 @@ class Project(models.Model):
|
||||
})
|
||||
return buttons
|
||||
|
||||
def _get_profitability_aal_domain(self):
|
||||
return expression.AND([
|
||||
super()._get_profitability_aal_domain(),
|
||||
['|', ('move_id', '=', False), ('move_id.purchase_line_id', '=', False)],
|
||||
])
|
||||
|
||||
def _get_profitability_items(self):
|
||||
profitability_items = super()._get_profitability_items()
|
||||
if self.analytic_account_id:
|
||||
|
||||
@@ -365,6 +365,13 @@ class Project(models.Model):
|
||||
query._where_params += timesheet_params + employee_mapping_params
|
||||
return query
|
||||
|
||||
def _get_profitability_aal_domain(self):
|
||||
domain = ['|', ('project_id', 'in', self.ids), ('so_line', 'in', self._fetch_sale_order_item_ids())]
|
||||
return expression.AND([
|
||||
super()._get_profitability_aal_domain(),
|
||||
domain,
|
||||
])
|
||||
|
||||
def _get_profitability_items_from_aal(self, profitability_items):
|
||||
if not self.allow_timesheets:
|
||||
total_invoiced = total_to_invoice = 0.0
|
||||
@@ -381,7 +388,7 @@ class Project(models.Model):
|
||||
}
|
||||
return profitability_items
|
||||
aa_line_read_group = self.env['account.analytic.line'].sudo()._read_group(
|
||||
[('so_line', 'in', self._get_all_sale_order_items().ids)],
|
||||
self.sudo()._get_profitability_aal_domain(),
|
||||
['timesheet_invoice_type', 'timesheet_invoice_id', 'unit_amount', 'amount'],
|
||||
['timesheet_invoice_type', 'timesheet_invoice_id'],
|
||||
lazy=False)
|
||||
|
||||
Reference in New Issue
Block a user