我在嚮導('pack_ids')中有一個Many2many類型字段,並且在sale.order.line中有一個Many2many('pack_id')類型字段。我希望Many2many類型的嚮導('pack_ids')字段的值在sale.order.line字段('pack_id')中返回。Odoov10中的嚮導在sales.order.line中的返回值
因爲我這個代碼是在這裏:
class SalePackWizard(models.TransientModel):
_name = "sale.pack.wizard"
_description = "Sale Pack Wizard"
@api.onchange('product_id')
def _onchange_product_pack_name(self):
print"A:", self.product_id.product_pack
res = self.product_id.product_pack
a = {}
print "res:", res
if res:
domain = {'pack_ids': [('id', 'in', [v.id for v in res])]}
a= res
print "a:", a
return {'domain': domain}
product_id = fields.Many2one('product.product', string="Product Pack", required=True, domain="[('is_pack','=',True)]")
qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0)
pack_ids = fields.Many2many('product.pack', string='Pack Products', change_default=True,
default=_onchange_product_pack_name)
@api.multi
def action_salepack_add(self):
rec = self._context.get('active_ids', [])
print "REC", rec, self.product_id.categ_id #product_uom
if rec:
line_values = {'product_id': self.product_id.id,
#'design_id':self.design_id.id,
'pack_id': self.product_id.product_pack,
'category_id':self.product_id.categ_id.id,
'order_id':rec[0],
'product_uom_qty':self.qty,
}
sale_order_line = self.env['sale.order.line'].create(line_values)
嗨,知道這是什麼領域** ** product_pack在** product.product類型**? –
這是Many2one類型字段 –