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