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
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
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
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
1
mars 22
|
13669 | ||
|
3
févr. 24
|
5514 | ||
SQL Query for many2many
Résolu
|
|
13
juil. 24
|
13662 | |
|
1
juil. 19
|
4922 | ||
|
2
mars 15
|
3708 |