启动弹出窗口以在sale.order.line视图中选择某种类型的产品

问题描述

自上几周以来,我一直在尝试为销售模块订单/报价中的每种产品添加不同的BOM字段。但不幸的是,我无法做到这一点。下面是我到目前为止完成的屏幕截图和代码。

enter image description here

enter image description here

这是我的代码:

 from odoo import models,fields
 class bom_Listing(models.Model):
_inherit = 'product.product'

productName = fields.Char('Product Name')
width = fields.Char('Width')
length = fields.Char('Length')
color = fields.Char('Color')

Xml视图

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="product_normal_form_view" model="ir.ui.view">
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="categ_id" position="after">
       <h4 style="color:DarkOrchid;">Add New BOM</h4>
           <field name="productName"/>
           <field name="width"/>
           <field name="length"/>
           <field name="color"/>
     </field>
     </field>
     </record> 
     </data>
     </odoo>

我想要的是单击突出显示的黄色按钮选择一个特定的产品,并立即在弹出窗口中根据添加的产品将(添加新物料)下的字段更改为不同的字段。如果你们能帮助我解决这个问题,我将非常感谢您。

解决方法

您应将productName字段从char更改为 product.product 对象的many2one。 在 productName 字段上添加 onchange 方法,以便当您从列表中选择任何产品时,onchange会填充其他字段。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...