Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1791 Widoki

For example, how do we aggregate the records of invoices from account.move and records of expenses from hr.expense to a new different model model.new.

The goal is to be able to access these records and create report tables/charts...

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Thanks Niyas Raphy for the support, the video answered it but one need to make some edit for newer Odoo version. Here is my working test code.

product_id = fields.Many2one('product.product')
invoice_date = fields.Date()

@api.model
def init(self):
tools.drop_view_if_exists(self.env.cr, 'cashflow_actual')
self.env.cr.execute("""​ CREATE OR REPLACE VIEW cashflow_actual AS (
​SELECT row_number() OVER () AS id, aml.product_id, am.invoice_date
​FROM account_move_line aml
​LEFT JOIN account_move am ON (am.id = aml.move_id)
​)
""")
Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

You can go through this video, which explains about the db view: Create Model/DB View Using Query In Odoo || Combine Multiple Model Into One Model

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
sie 25
2544
1
maj 25
2600
1
kwi 25
3575
1
kwi 25
4431
1
kwi 25
1887