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?
See this: https://www.youtube.com/watch?v=_KIsGo4sttQ