Odoo:如何显示one2many字段中多个One字段的字段
我不知道如何放置它,但我想要的是,我想在one2many字段的树状视图中显示custom.product模型的字段。我的代码如下Odoo:如何显示one2many字段中多个One字段的字段,odoo,odoo-12,Odoo,Odoo 12,我不知道如何放置它,但我想要的是,我想在one2many字段的树状视图中显示custom.product模型的字段。我的代码如下 class CustomSale(models.Model): _name = 'custom.sale' _description = 'Sale Record' name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True,
class CustomSale(models.Model):
_name = 'custom.sale'
_description = 'Sale Record'
name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True,
default=lambda self: _('New'))
order_line = fields.One2many('custom.sale.line', 'order_id', string='Order Lines', copy=True,
auto_join=True)
class CustomSaleLine(models.Model):
_name = 'custom.sale.line'
_description = 'Sales Line'
order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)
product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )
定制、销售、表格
海关销售
但我仍然无法显示“品牌id”、“国家id”和“售价”
为要在树状图中显示的字段添加
相关的
字段
class CustomSaleLine(models.Model):
_name = 'custom.sale.line'
_description = 'Sales Line'
order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)
product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )
brand_id = fields.Many2one('BRAND_MODEL_HERE',related='product_id.brand_id')
country_id = fields.Many2one('COUNTRY_MODEL_HERE',related='product_id.country_id')
sell_price = fields.Float(related='product_id.sell_price')
<record id="form_custom_sale" model="ir.ui.view">
<field name="name">custom.sale.form</field>
<field name="model">custom.sale</field>
<field name="arch" type="xml">
<form string="Sales">
<sheet>
<group>
<group>
<field name="name"/>
</group>
</group>
<notebook>
<page string="Order Lines" name="order_lines">
<field name="order_line" widget="section_and_note_one2many" mode="tree">
<tree editable="bottom">
<control>
<create string="Add a product"/>
</control>
<field name="product_id">
<field name="brand_id"/>
<field name="country_id"/>
<field name="sell_price"/>
<field name="product_uom_qty" string="Ordered Qty"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
class CustomSaleLine(models.Model):
_name='custom.sale.line'
_description=‘销售线’
order\u id=fields.manyOne('custom.sale',string='order Reference',required=True,)
product\u id=fields.manyOne('custom.product',string='product',change\u default=True,ondelete='restrict')
产品计量单位数量=字段。整数(字符串='Ordered Quantity',required=True,)
brand\u id=fields.manyOne('brand\u MODEL\u HERE',related='product\u id.brand\u id')
country\u id=fields.manyOne('country\u MODEL\u HERE',related='product\u id.country\u id')
售价=字段.Float(related='product\u id.sell\u price')
定制、销售、表格
海关销售
class CustomSaleLine(models.Model):
_name = 'custom.sale.line'
_description = 'Sales Line'
order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)
product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )
brand_id = fields.Many2one('BRAND_MODEL_HERE',related='product_id.brand_id')
country_id = fields.Many2one('COUNTRY_MODEL_HERE',related='product_id.country_id')
sell_price = fields.Float(related='product_id.sell_price')
<record id="form_custom_sale" model="ir.ui.view">
<field name="name">custom.sale.form</field>
<field name="model">custom.sale</field>
<field name="arch" type="xml">
<form string="Sales">
<sheet>
<group>
<group>
<field name="name"/>
</group>
</group>
<notebook>
<page string="Order Lines" name="order_lines">
<field name="order_line" widget="section_and_note_one2many" mode="tree">
<tree editable="bottom">
<control>
<create string="Add a product"/>
</control>
<field name="product_id">
<field name="brand_id"/>
<field name="country_id"/>
<field name="sell_price"/>
<field name="product_uom_qty" string="Ordered Qty"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>