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

how can i write xml content (an external address ) in a python file in odoo.

頭像
捨棄
最佳答案

Hi,

For accessing view from python we can use like this:

return {
    'type': 'ir.actions.act_window',
    'name': _('Tasks from Tickets'),
    'res_model': 'project.task',
    'res_id': new_task.id,
    'view_mode': 'form',
    'view_id': self.env.ref('project.view_task_form2').id,
    'context': {
        'fsm_mode': True,
    }
}
type refers to the type of the view ( in here a window action). name refers to be shown on view, res model: the model of view, res_id, the id to be viewed in the view, view_mode: form, tree, ..., view_id: id of the view..

if we want to create a new view, we can code like below

self.env["ir.ui.view"].create({
    "name": "Add separate label for decimal_places",
    "model": "res.currency",
    "inherit_id": self.env.ref("base.view_currency_form").id,
    "arch": """
        < data>
            < field name="decimal_places" position="attributes">
                < attribute name="nolabel">1
            < /field>
            < field name="decimal_places" position="before">
                < label for="decimal_places"/>
            < /field>
        < /data>
    """,
})
Hope it helps
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
2月 24
2663
1
3月 18
6575
2
7月 24
13565
2
12月 23
12114
3
7月 22
22343