私はAPIを使用しています。まず、私は、顧客が選択した詳細な製品(ポップアップウィンドウのような)、View Selected Productこの画像(see this link)の中にあるものです。Pythonを使用して、クリックしたリストからツリービューで特定のフォームビューにリダイレクトする方法
ボタンをクリックすると、in this linkのような選択した製品のツリービューが表示されます。
私がしたかったのは、リスト/ツリービューのポップアップウィンドウで製品をクリックすると、リダイレクトリンクを作ってみたいと思います。したがって、リストでクリックした製品ののフォームビューにリダイレクトされます。リストの製品は、顧客が購入を選択した製品です。私のボタンは、顧客が買い物をするときに選択した商品のみを表示します。
私のコードに追加する必要はありますか?何を変更する必要がありますか?私はPythonとOdooの初心者です。ここで
は、ボタンのための私のPythonコードです:
from openerp import models, api, fields, _
class task_04 (models.Model):
#Inherit dari model purchase.order
_inherit = "purchase.order"
@api.multi
def action_view_related_products(self):
ids = [line.product_id.id
for line in self.order_line]
return{
'name' : ('View Chosen Products'), # Nama dari tabel pop up
'type' : 'ir.actions.act_window',
'view_type' : 'form', #Tampilan pada tabel pop-up
'view_mode' : 'tree', # Menampilkan bagian yang di pop up, tree = menampilkan tabel tree nya utk product
'res_model' : 'product.product', #Menampilkan tabel yang akan di show di pop-up screen
'target' : 'new', # Untuk menjadikan tampilan prduct yang dipilih menjadi pop-up table tampilan baru, jika dikosongin maka tidak muncul pop-up namun muncul halaman baru.
'view_id' : False,
'domain' : [('id','in',ids)] #Filter id barang yang ditampilkan
}
task_04()
そして、ここでは私のXMLコードは、ボタンを表示します:
<openerp>
<data>
<record id="task_4_purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"></field>
<field name="arch" type="xml">
<!-- Lokasi untuk menempatkan button yang akan dibuat diletakkan di sebelah button cancel -->
<xpath expr="/form/header/button[@name='button_cancel']" position="inside">
<!-- Membuat button -->
<button string="View Chosen Product(s)" type="object" name="action_view_related_products"/>
</xpath>
</field>
</record>
</data>
</openerp>
自己回答を投稿してくれてありがとう。タイトルに[解決済み]を追加しないでください。代わりにこれらの回答の隣にある目盛りをクリックすると緑色に変わります。 – halfer