Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
9521 Lượt xem

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?


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

   

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
926
1
thg 9 21
8743
1
thg 1 24
16462
0
thg 3 15
2878
1
thg 3 15
9449