Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
9468 Visualizações

Hi,

I have a report with a non database table model which based on a SQL View, see below.

class ReportFee(models.Model):
_name = "fee.report"
_auto = False

        partner_id = fields.Many2one(comodel_name='res.partner', string='Partner', readonly=True)
percent = fields.Char(readonly=True)
invoice_id = fields.Char(readonly=True)
@api.multi
def button_create_inv(self):
print('OK')
        @api.model_cr
def init(self):
""" Event Question main report """
tools.drop_view_if_exists(self._cr, 'fee_report')
self._cr.execute(""" CREATE VIEW fee_report AS (
    SELECT
concat(account_invoice.id, fee_fee_line.fee_partner_id) as ID,
fee_fee_line.fee_partner_id as partner_id,
fee_fee_line.fee_percent as percent,
                account_invoice.number as invoice_id
FROM account_invoice
INNER JOIN fee_fee ON account_invoice.fee_identifier = fee_fee.id
INNER JOIN fee_fee_line ON fee_fee.id = fee_fee_line.fee_id
)""")

It works fine for the tree view. But if I click on an entry, the form view doesn't show any detail values. The button doesn't work, too.

Here my Form View Code:

<record id="view_form_fee_report" model="ir.ui.view" >
<field name="name">Fee List</field>
<field name="model">fee.report</field>
<field name="arch" type="xml">
        <form>
    <header>
               <button name="button_create_inv" type="object" string="Create Invoice" />
            </header>
    <group>
               <field name="partner_id"/>
               <field name="percent"/>
       <field name="invoice_id" />
    </group>
    </form>
</field>
</record>

Is it possible to have a detail form view for SQL View models which are no models in database and use buttons for actions?


Avatar
Cancelar
Autor Melhor resposta

Thanks for your answer.

I solved the problem. It was the concat of the ID. It should always be an integer. With cast as integer the detail view works fine.

cast(concat(account_invoice.id, fee_fee_line.fee_partner_id) as integer) as ID
Avatar
Cancelar
Melhor resposta

Hello Silberlicht,

set Group by clause in query

SELECT
concat(account_invoice.id, fee_fee_line.fee_partner_id) as ID,
fee_fee_line.fee_partner_id as partner_id,
fee_fee_line.fee_percent as percent,
account_invoice.number as invoice_id
FROM account_invoice
INNER JOIN fee_fee ON account_invoice.fee_identifier = fee_fee.id
INNER JOIN fee_fee_line ON fee_fee.id = fee_fee_line.fee_id
GROUP BY partner_id, percent, invoice_id


Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
nov. 24
826
1
set. 21
8702
1
jan. 24
16406
0
mar. 15
2842
1
mar. 15
9395