تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2744 أدوات العرض

I already have basic knowledge in SQL and I need to perform it in Odoo 15.

I want to create a list view using SQL and the datas are from two different model. sale.order.receivable.lines and account.move.line.

I already display the data.



but when I go to payment menu and set to draft the record, this error appears.

الصورة الرمزية
إهمال
أفضل إجابة

Hello Lawrence,

We can achive this by creating a model with _auto = False attribute like below.

class AccountSaleRel(models.Model):
_name = 'account.sale.rel'
_description = 'Account Sale Rel'
_auto = False


account_move_line_id = fields.Many2one("account.move.line")
sale_order_receivable_lines_id = fields.Many2one("sale.order.receivable.lines")
f1 = fields.Char()
f2 = fields.Char()

c1 = fields.Boolean(compute="_compute_c1", store=False)
r1 = fields.Boolean(related="f1.active", store=False)


def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)

# We can only store fields fetched from below query like account_move_line_id, sale_order_receivable_lines_id, f1 and f2 fields. 
# rest of the fields should not be storable. 
self.env.cr.execute('''
CREATE OR REPLACE VIEW %s AS (
SELECT id as account_move_line_id, name as f1
FROM account_move_line 
FULL JOIN (SELECT id as sale_order_receivable_lines_id, name as f2 FROM sale.order.receivable.lines)
)''' % (self._table,)



def _compute_c1(self):
for rec in self:
rec.c1 = True

After this you can normally create tree view for 'account.sale.rel' model.

Reference of SQL views in Odoo: https://www.cybrosys.com/blog/how-to-create-sql-view-odoo

Hope it will be helpful to you.

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
ديسمبر 23
2687
2
أغسطس 23
2350
1
ديسمبر 23
4127
1
يوليو 23
2953
0
مايو 23
2863