跳至內容
選單
此問題已被標幟
1 回覆
3910 瀏覽次數

Hello everyone,

I have an ir.actions.report to print the sales of a POS session with a custom template. So I put a button in the pos.session form to print that report and it work perfectly.


<record id="action_section_closure_report" model="ir.actions.report">
<field name="name">POS Section Closure Report</field>
<field name="model">pos.session</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">pos_extend.report_section_closure_report</field>
<field name="report_file">pos_extend.report_section_closure_report</field>
<field name="print_report_name">'POS Section Closure - %s' % (object.name)</field>
</record>


The problem is I also implemented an option in the Kanban view of the pos.config (Point of Sale), that must print the last closed session sales. The code of that button is like below: 


def _print_last_closure(self):
last_session = self.env['pos.session'].search([
('config_id', 'in', self.ids),
('state', '=', 'closed')
], order='id desc', limit=1)

if last_session:
return self.env.ref('pos_extend.action_section_closure_report').report_action(docids=last_session.ids)

The "_print_last_closure method" is in the pos.config model because it is the method that is trigger from the option that I added in the kanban view of the Point of Sale. But for some reason this method does nothing, when I click on the button it does nothing. Any suggestion?


頭像
捨棄
作者

Hello Akshay Babu, thanks for answering. I have tried your suggestion but it doesn't work either, when I click nothing happens. I think it has to do with context, but I'm not sure.

最佳答案

Hi,

 Try returning

last_session.env.ref('pos_extend.action_section_closure_report').report_action(docids=last_session.ids)
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
4
1月 25
44959
0
10月 24
1685
0
10月 24
5
1
5月 23
3209
5
5月 21
11773