I am creating a view using self.env.cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" % (self._table, self._query( ))).
This query includes a function but when i update it says error near Create Or Replace.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hello Adilak,
You can use below code:
self.env.cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" % (self._table, self._query()))
Moreover, If you want to call function from query then refer below code:
cr.execute(
"""CREATE OR REPLACE FUNCTION l10n_mx_edi_locality()
RETURNS trigger AS $locality$
DECLARE
new_array text[];
BEGIN
new_array := (SELECT regexp_split_to_array(NEW.name, E'--+'));
NEW.name := new_array[1];
NEW.state_id := (SELECT res_id FROM ir_model_data
WHERE name=new_array[2] and model='res.country.state');
NEW.country_id := (SELECT res_id FROM ir_model_data
WHERE name='mx' and model='res.country');
RETURN NEW;
END;
$locality$ LANGUAGE plpgsql;
CREATE TRIGGER l10n_mx_edi_locality BEFORE INSERT
ON l10n_mx_edi_res_locality
FOR EACH ROW EXECUTE PROCEDURE l10n_mx_edi_locality();
CREATE TRIGGER l10n_mx_edi_locality BEFORE INSERT ON res_city
FOR EACH ROW EXECUTE PROCEDURE l10n_mx_edi_locality();
""")
Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Mar 22
|
12679 | ||
|
3
Feb 24
|
4791 | ||
SQL Query for many2many
Solved
|
|
13
Jul 24
|
12530 | |
|
1
Jul 19
|
4237 | ||
|
2
Mar 15
|
3158 |