Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2715 Представления

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
дек. 23
2679
2
авг. 23
2348
1
дек. 23
4117
1
июл. 23
2950
0
мая 23
2847