问题描述
这里有两个模型和字段
class SellProduct(models.Model):
_name = 'sell.product'
_rec_name = 'product_seq'
product_seq = fields.Many2one(comodel_name="product.create",string="Product ID",required=False,)
product_name = fields.Char(related='product_seq.product_name',string="Product Name",)
product_image = fields.Binary(related='product_seq.product_image',string=" Image",)
gold_quality = fields.Selection(related='product_seq.gold_quality',string="Gold
Quality",sell_product_quantity = fields.Integer(string="Product Quantity",required=True,)
sell_line = fields.Many2one(comodel_name="product.create",string="Sell Line",)
class ProductCreate(models.Model):
_name = 'product.create'
_inherit = ['mail.thread','mail.activity.mixin',]
_rec_name = 'product_seq'
# browse(vals.get("manager_id"
product_seq = fields.Char(string='PID',copy=False,randomly=True,index=True,default=lambda self: _('New'))
product_name = fields.Char(string="Product Name")
product_image = fields.Binary(string="Product Image")
product_quantity_new = fields.Integer(compute='update_value')
product_quantity = fields.Integer(string="Product Quantity",)
create_sell_line = fields.One2many(comodel_name="sell.product",inverse_name="sell_line",string="create sell line",)
这里我需要来自“sell.product 模型”的 sale_product_quantity 字段值
product_quantity_new = sell_product_quantity 这意味着 sell_product_quantity 值将存储 product_quantity_new 字段 你能帮我吗?
解决方法
这个应该可以工作,以获取您的 sale.product 模型的字段定义:
self.env['sell.product].fields_get('sell_product_quantity')
如果你想得到值,那么你必须使用
self.env['sell.product].browse(CONCRETE_ID_OF_THE_MODEL).sell_product_quantity