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
- Financeiro
- Inventário
- PoS
- Project
- MRP
Esta pergunta foi sinalizada
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
Está gostando da discussão? Não fique apenas lendo, participe!
Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!
Inscreva-sePublicações relacionadas | Respostas | Visualizações | Atividade | |
---|---|---|---|---|
|
1
mar. 22
|
13458 | ||
|
3
fev. 24
|
5270 | ||
SQL Query for many2many
Resolvido
|
|
13
jul. 24
|
13470 | |
|
1
jul. 19
|
4799 | ||
|
2
mar. 15
|
3542 |