|
|
@ -50,6 +50,12 @@ class MisCashFlow(models.Model): |
|
|
|
account_internal_type = fields.Selection( |
|
|
|
related="account_id.user_type_id.type", readonly=True |
|
|
|
) |
|
|
|
state = fields.Selection(selection="_selection_parent_state",) |
|
|
|
|
|
|
|
def _selection_parent_state(self): |
|
|
|
return self.env["account.move"].fields_get(allfields=["state"])["state"][ |
|
|
|
"selection" |
|
|
|
] |
|
|
|
|
|
|
|
def init(self): |
|
|
|
query = """ |
|
|
@ -57,7 +63,7 @@ class MisCashFlow(models.Model): |
|
|
|
-- we use negative id to avoid duplicates and we don't use |
|
|
|
-- ROW_NUMBER() because the performance was very poor |
|
|
|
-aml.id as id, |
|
|
|
CAST('move_line' AS varchar) as line_type, |
|
|
|
'move_line' as line_type, |
|
|
|
aml.id as move_line_id, |
|
|
|
aml.account_id as account_id, |
|
|
|
CASE |
|
|
@ -75,12 +81,14 @@ class MisCashFlow(models.Model): |
|
|
|
aml.partner_id as partner_id, |
|
|
|
aml.company_id as company_id, |
|
|
|
aml.name as name, |
|
|
|
aml.parent_state as state, |
|
|
|
COALESCE(aml.date_maturity, aml.date) as date |
|
|
|
FROM account_move_line as aml |
|
|
|
WHERE aml.parent_state != 'cancel' |
|
|
|
UNION ALL |
|
|
|
SELECT |
|
|
|
fl.id as id, |
|
|
|
CAST('forecast_line' AS varchar) as line_type, |
|
|
|
'forecast_line' as line_type, |
|
|
|
NULL as move_line_id, |
|
|
|
fl.account_id as account_id, |
|
|
|
CASE |
|
|
@ -98,6 +106,7 @@ class MisCashFlow(models.Model): |
|
|
|
fl.partner_id as partner_id, |
|
|
|
fl.company_id as company_id, |
|
|
|
fl.name as name, |
|
|
|
'posted' as state, |
|
|
|
fl.date as date |
|
|
|
FROM mis_cash_flow_forecast_line as fl |
|
|
|
""" |
|
|
|