微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决启动弹出窗口以在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会填充其他字段。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。