我在产品包的库存中有一个 One2many 字段。而且我希望该 One2many 字段的所有字段值都应该在销售订单、行和列的 One2many 字段的字段中更新。所以,任何人都可以帮助我。
我的 Python 代码在这里:
class ProductTemplate(models.Model):
_inherit = "product.template"
product_pack = fields.One2many('product.pack', 'template_id', string='Product Pack', copy=True)
class ProductDesign(models.Model):
_description = 'Product Pack'
_name = "product.pack"
_rec_name = "product_id"
check_option = fields.Boolean('#')
template_id = fields.Many2one('product.template', string='Template', required="True", ondelete='cascade', index=True, copy=True)
product_id = fields.Many2one('product.product', string='Product', required="True", domain="[('is_pack','=',False)]")
services = fields.Many2one('gold.service')
qty = fields.Integer('Quantity', default=1)
在“向导”(One2many 字段表)中,我想更新 product_pack 的所有字段(行和列)
class SalePackWizard(models.TransientModel):
_name = "sale.pack.wizard"
_description = "Sale Pack Wizard"
product_id = fields.Many2one('product.product', string="Product Pack", required=True, domain="[('is_pack','=',True)]")
wizard = fields.One2many('product.gold','service')
@api.onchange('product_id')
def _onchange_product_pack_name(self):
for w in self.product_id.product_pack:
for s in w:
print "s:", s.product_id.name, s.services, s.qty
r = []
print"r:", r
class ProductDesign(models.Model):
_description = 'Product Pack'
_name = "product.gold"
_rec_name = "products_ids"
service= fields.Many2one('product.val', string='Templates', required="True", ondelete='cascade', index=True, copy=True)
check_box = fields.Boolean('#')
products_ids = fields.Many2one('product.product', string='Product', required="True", domain="[('is_pack','=',False)]")
services = fields.Many2one('gold.service')
qtyy = fields.Integer('Quantity', default=1)