Skip to Content
Menu
This question has been flagged
1 Reply
4012 Views

Hello friends, I am trying to install the module report_analytic_line and there are one SQL statement that once is executed throws this error:

Can not drop columns from view!

This is the sql statement:

CREATE OR REPLACE VIEW report_account_analytic_line_to_invoice AS (
            SELECT
                DISTINCT(to_char(l.date,'YYYY-MM-DD')) AS name,
                MIN(l.id) AS id,
                l.product_id,
                l.account_id,
                SUM(l.amount) AS amount,
                SUM(l.unit_amount*t.list_price) AS sale_price,
                SUM(l.unit_amount) AS unit_amount,
                l.product_uom_id
            FROM
                account_analytic_line l
            left join
                product_product p on (l.product_id=p.id)
            left join
                product_template t on (p.product_tmpl_id=t.id)
            WHERE
                (invoice_id IS NULL) and (to_invoice IS NOT NULL)
            GROUP BY
                to_char(l.date,'YYYY-MM-DD'), product_id, product_uom_id, account_id
        )

Please have someone one hint to solve this issue?

Best regards,

Avatar
Discard
Best Answer

Hello Sandro Regis

As per you logic you need to drop the current view first then you can create or replace new view.


Like: -
from odoo import tools
tools.drop_view_if_exists(self._cr, self._table)

If you write query in another table then please make sure,
self._table is your view .

tools.drop_view_if_exists(self._cr, "YOUR CUSTOM VIEW")

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard