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:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
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
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
1
مارس 22
|
13510 | ||
|
3
فبراير 24
|
5366 | ||
SQL Query for many2many
تم الحل
|
|
13
يوليو 24
|
13541 | |
|
1
يوليو 19
|
4859 | ||
|
2
مارس 15
|
3577 |