Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6718 มุมมอง

Hi,

I have these 4 tables in my code :

- Product

- Package

- Product_package

- Purchase_order.

class product(models.Model):
_name = 'tjara.product'

name = fields.Char(string="Nom du produit")
description = fields.Text(string="Description du produit")
add_date = fields.Date(string="Date d'ajout au stock")
provider_ids = fields.Many2many('tjara.provider', ondelete='cascade', string="Provider", index=True)
client_ids = fields.Many2many('tjara.client', ondelete='cascade', string="Client", index=True)
product_package_ids = fields.One2many('tjara.product_package', 'product_id', string='Package')


class product_package(models.Model):
_name = 'tjara.product_package'

name = fields.Char(string="Name", compute='_compute_name')
product_id = fields.Many2one('tjara.product', ondelete='cascade', string="Produit", index=True)
package_id = fields.Many2one('tjara.package', ondelete='cascade', string="Emballage", index=True)
price = fields.Integer(string="Prix d'unité", required=True)
description = fields.Text(string="Description d'emballage")
purchase_order_id = fields.Many2one('tjara.purchase_order', ondelete='cascade', string="Demande d'achat", index=True)


class package(models.Model):
_name = 'tjara.package'

name = fields.Char(string="Nom d'emballage")
unity = fields.Char(string="Unité", required=True)
description = fields.Text(string="Description d'emballage")


class purchase_order(models.Model):
_name = 'tjara.purchase_order'

name = fields.Char(string='Purchase Name', required=True)
  product_package_ids = fields.One2many('tjara.product_package', 'purchase_order_id', string='Product Package')


I want in the purchase_order to select a product_package. I don't want to select it by name but by selecting two fields : First, The user choose the desired product, and then the second field load the available packages for it. By saving the purchase_order will contain the concerned product_package Id.


In purchase_order Xml I added this following code :

                                <notebook>
<page string="Product_ emballage">
<label for="product_package_ids" string="Produits Emballés"/>
<field name="product_package_ids" mode="tree">
<tree editable="1">
<field name="product_id"/>
<field name="package_id"/>
</tree>
</field>
</page>
</notebook>


What can I do else to achieve this ?

Thanks a lot.

(Sorry I can't add a picture for the database structure I'm not allowed yet.)


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 18
8631
3
ธ.ค. 17
4116
1
ธ.ค. 19
9932
1
มิ.ย. 18
4000
odoo onchange function on one2many field แก้ไขแล้ว
3
ต.ค. 22
21321