用于在 one2many 字段上选择产品的小部件
项目描述
添加“one2many_product_picker”友好的移动小部件以创建与 product.product 记录链接的 one2many 行。
目录
<nav class="contents local" id="contents" role="doc-toc"> </nav>安装
建议安装“web_widget_numeric_step”以在触摸屏上获得更好的可用性。
配置
创建或编辑新视图并使用名为“one2many_product_picker”的新小部件。您需要定义视图字段。视图必须是表单类型。
小部件选项:
组>字典数组->声明组
name -> 组名
字符串 -> 显示的文本
域 -> 强制使用域
订单 -> 订单
name -> 要排序的字段名称
asc -> 使用“asc”顺序的标志
records_per_page > Integer -> 用于控制加载更多行为(默认16)
active -> Boolean -> 选择要使用的默认组('false' 默认情况下 = 'All' 组)
currency_field > 用于格式化货币值的模型字段(默认为“currency_id”)
field_map > 字典:
product -> 代表产品的字段(默认为product_id )
name -> 代表名称的字段(默认为'name')
product_uom -> 代表 product_uom 的字段(默认为'product_uom')
product_uom_qty -> 表示 product_uom_qty 的字段(默认为“product_uom_qty”)
price_unit -> 表示 price_unit 的字段(默认为“price_unit”)
折扣 -> 表示折扣的字段(默认为“折扣”)
搜索 > 字典数组(定义为默认使用 name_search)
name -> 要显示的名称
域 -> 要使用的域
$search -> 用搜索框的当前值替换它
$number_search -> 将所有叶子替换为搜索框的当前值作为数字
name_search_value -> 允许使用 'name_search' 而不是 'search_read' 并定义要搜索的值(默认为 '$search')
运算符 -> 'name_search' 中使用的运算符(默认为 'ilike')
edit_discount > 启用/禁用折扣编辑(默认为 False)
edit_price > 启用/禁用价格编辑(默认为真)
show_discount > 启用/禁用显示折扣(默认为 False)
show_subtotal > 启用/禁用显示小计(默认为真)
auto_save > 启用/禁用自动保存(默认为 False)
auto_save_delay > 上次交互后启动自动保存前的等待时间(以毫秒为单位)(默认为 1500)
all_domain > 'All' 部分中使用的域(默认为 [])
如果使用自动保存功能,您应该记住,“保存”和“放弃”按钮将失去部分功能,因为每次使用小部件修改/创建记录时都会保存文档。
ignore_warning > 启用/禁用显示 onchange 警告(默认为 False)
instant_search > 启用/禁用即时搜索模式(默认为 False)
trigger_refresh_fields > 主记录中调度小部件刷新的字段(默认为[“partner_id”,“currency_id”])
auto_focus > 执行搜索后保持焦点在搜索框上(默认为真)
所有小部件选项都是可选的。请注意,您可以调用 '_' 方法来使用翻译。这只能与此小部件一起使用。
例子:
options="{'search': [{'name': _('Starts With'), 'domain': [('name', '=like', '$search%')]}], 'groups': [{'name': 'cheap', 'string': _('Cheap'), 'domain': [('list_price', '<', 10.0)], 'field_map': { 'product': 'my_product_id' }}]}"
默认上下文:
小部件使用“search_read”请求发送默认上下文:
active_search_group_name > 包含活动搜索组的名称
'all' > 是“All”组的硬编码名称
'main_lines' > 是 'Lines' 组的硬编码名称
active_search_involved_fields > 包含一个字典数组,其中包含与搜索框内容一起使用的字段
“类型”> 可以是“文本”或“数字”
'field' > 字段名
'oper' > 使用的运算符
例子:
这是一个使用“sale.order.line”字段的示例:
<field
name=<s>"order_line"</s>
attrs=<s>"{'readonly': [('state', 'in', ('done','cancel'))]}"</s>
nolabel=<s>"1"</s>
mode=<s>"form"</s>
widget=<s>"one2many_product_picker"</s>
options=<s>"{'search': [{'name': 'Test', 'domain': [['name', 'ilike', '$search']]}] ,'edit_discount': True, 'show_discount': True, 'groups': [{'name': 'desk', 'string': _('Desks'), 'domain': [('name', 'ilike', '%desk%')], 'order': [{'name': 'id', 'asc': true}]}, {'name': 'chair', 'string': _('Chairs'), 'domain': [('name', 'ilike', '%chair%')]}]}"</s>
>
<form>
<field name=<s>"state"</s> invisible=<s>"1"</s> />
<field name=<s>"display_type"</s> invisible=<s>"1"</s> />
<field name=<s>"currency_id"</s> invisible=<s>"1"</s> />
<field name=<s>"discount"</s> widget=<s>"numeric_step"</s> options=<s>"{'max': 100}"</s> invisible=<s>"1"</s>/>
<field name=<s>"price_unit"</s> widget=<s>"numeric_step"</s> invisible=<s>"1"</s>/>
<field name=<s>"name"</s> invisible=<s>"1"</s> />
<field name=<s>"product_id"</s> invisible=<s>"1"</s> />
<field name=<s>"order_id"</s> invisible=<s>"1"</s>/>
<field name=<s>"product_uom_qty"</s> class=<s>"mb-1"</s> widget=<s>"numeric_step"</s> context=<s>"{
'partner_id': parent.partner_id,
'quantity': product_uom_qty,
'pricelist': parent.pricelist_id,
'uom': product_uom,
'company_id': parent.company_id
}"</s> />
<field name=<s>"product_uom"</s> force_save=<s>"1"</s> attrs=<s>"{
'readonly': [('state', 'in', ('sale','done', 'cancel'))],
'required': [('display_type', '=', False)],
}"</s> context=<s>"{'company_id': parent.company_id}"</s> class=<s>"mb-2"</s> options=<s>"{'no_open': True, 'no_create': True, 'no_edit': True}"</s> />
</form>
</field>
** 在此示例中,我们不使用 'field_map' 选项,因为默认匹配 sale.order.line 字段名称。
“purchase.order.line”字段的其他示例:
<field
name=<s>"order_line"</s>
attrs=<s>"{'readonly': [('state', 'in', ('done','cancel'))]}"</s>
nolabel=<s>"1"</s>
widget=<s>"one2many_product_picker"</s>
mode=<s>"form"</s>
options=<s>"{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}"</s>
>
<form>
<field name=<s>"name"</s> invisible=<s>"1"</s> />
<field name=<s>"product_id"</s> invisible=<s>"1"</s> />
<field name=<s>"price_unit"</s> invisible=<s>"1"</s> />
<field name=<s>"currency_id"</s> invisible=<s>"1"</s> />
<field name=<s>"order_id"</s> invisible=<s>"1"</s> />
<field name=<s>"date_planned"</s> class=<s>"mb-1"</s> />
<field name=<s>"product_qty"</s> class=<s>"mb-1"</s> widget=<s>"numeric_step"</s> required=<s>"1"</s> />
<field name=<s>"product_uom"</s> class=<s>"mb-2"</s> options=<s>"{'no_open': True, 'no_create': True, 'no_edit': True}"</s> />
</form>
</field>
Boostrap 修改:
产品选择器视图容器有一个自定义媒体查询空间,添加了一个名为“xxl”(>= 1440px)的新屏幕尺寸,并将列修改为 24 而不是 12。这意味着您可以在产品选择器视图容器。
用法
当您更改字段的值并切换到编辑另一条记录时,更改将应用于先前的记录,而无需单击接受更改。
小部件的部分:
预习:
已知问题/路线图
使用小部件的字段的 xml 'options' 属性中的翻译无法自动导出以进行翻译
产品卡片动画可以改进。目前该卡已重新创建,因此我们丢失了一些元素以应用正确的效果
将忽略影响“order_line”子字段的 sale.order onchanges 以提高性能
错误追踪器
在GitHub 问题上跟踪错误。如果遇到问题,请检查您的问题是否已被报告。如果您首先发现它,请通过提供详细且受欢迎的 反馈来帮助我们粉碎它。
不要就技术问题的支持或帮助直接联系贡献者。
学分
贡献者
维护者
该模块由 OCA 维护。
OCA 或 Odoo 社区协会是一个非营利组织,其使命是支持 Odoo 功能的协作开发并促进其广泛使用。
该模块是GitHub 上OCA/web项目的一部分。
欢迎您贡献。要了解如何,请访问https://odoo-community.org/page/Contribute。
项目详情
odoo13_addon_web_widget_one2many_product_picker -13.0.2.0.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0dfd912763424dda341fa13267877f795ac222697871197d285e3a1dbbb5ffdf |
|
MD5 | b8c2b0553597c1899417da61289039f1 |
|
布莱克2-256 | ab608dc1d40455b7078ba028c99a0f0ab95823b7e80dd287fdcb4de35852813a |