- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个新的向导,但我不太了解该怎么做 :(在一些指南中,我找到了这段代码:
<wizard
id="test_wizard"
keyword="client_action_multi"
model="product.product"
name="product.product.product_id"
string="Test wizard" />
在技术纪念品中我发现了这个:
<record id="action_idea_cleanup_wizard" model="ir.actions.act_window">
<field name="name">Cleanup</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">idea.cleanup.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
我应该使用哪种语法?
编辑:我试过执行向导,这是代码:
python 文件:
from openerp.osv import osv
from openerp.osv import fields
class create_ean(osv.osv_memory):
_name='generate.ean'
_columns = {
'product_def_code' : fields.text('Product Default Code'),
'product_gen_code' : fields.text('Product Generated EAN13', readonly = True),
}
#defaults calls a function that will browse your main object and fill the field with the existing information
_defaults = {
'product_def_code': lambda self, cr, uid, context: self._get_product_id(cr, uid, context),
'product_gen_code': lambda self, cr, uid, context: self.generate_ean(),
}
def save_code(self, cr, uid, ids, context=None):
if 'active_id' in context:
info = self.browse(cr,uid,ids)
self.pool.get('ean13').write(cr,uid,context['active_id'],{'ean13': info[0].product_gen_code})
return {
'type': 'ir.actions.act_window_close',
}
def generate_ean(self):
return "ouhdeguosAB13"
def _get_product_id(self, cr, uid, context=None):
if 'active_id' in context:
return self.pool.get('product.product').browse(cr, uid, context['active_id'], context).product_id
create_ean()
XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- create a view with a unique id -->
<record id="view_generate_ean13_code_wizard" model="ir.ui.view">
<field name="name">generate_ean13_code.form</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="arch" type="xml">
<!-- create a normal form view, with the fields you've created on your python file -->
<form string="Insert reformulation info" version="7.0">
<group >
<separator string="EAN13 Code Generator" colspan="2"/>
<field name="product_def_code" string="Product Default Code"/>
<field name="product_gen_code" string="Product EAN13 Generated Code"/>
<newline/>
</group>
<div style="text-align:right">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" name="save_code" string="Save the code" type="object" />
</div>
</form>
</field>
</record>
<!-- your action window refers to the view_id you've just created -->
<record id="action_generate_ean" model="ir.actions.act_window">
<field name="name">Generate EAN13</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">generate.ean</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_generate_ean13_code_wizard"/>
<field name="target">new</field>
</record>
<act_window id="action_generate_ean"
name="Generate EAN13"
res_model="generate.ean"
view_mode="form"
target="new"
/>
</data>
</openerp>
我会解释我需要做什么,基本上我需要获取产品的 product_id 并以此生成 ean13,我为代码的生成做了一个测试方法,但我不知道如何保存ean13 字段中生成的代码以及如何使用我的方法通过向他传递 product_id 来生成该代码
最佳答案
关于向导的文档有点不清楚,我(仍然)很难理解它是如何工作的,但我会在这里给你留下一个带有文本字段的工作向导的例子,它保存到一个调用对象中(您必须更改表的名称以使其适应您的需要)。
像这样创建一个 python 文件:
from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _
class ref_generic_request(osv.osv_memory):
# create a table in osv_memory, with the columns you need
# to fill in your wizard
_name = 'ref.generic.request'
_columns = {
'reformulation_info': fields.text(
'Reformulation instructions',
help='Instructions for the requestor justification the reformulation needs'),
}
# create a function that will save the info from your wizard into
# your model (active_id is the id of the record you called the wizard
# from, so you will save the info entered in wizard in that record)
def save_info(self, cr, uid, ids, context=None):
if 'active_id' in context:
info = self.browse(cr, uid, ids)[0].reformulation_info
gen_req = self.pool.get('generic.request')
gen_req.write(
cr, uid, context['active_id'],
{'reformulation_info':info, 'needs_reformulation':1}
)
return {'type':'ir.actions.act_window_close'}
ref_generic_request()
然后创建 View 以显示您的向导:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- create a view with a unique id -->
<record id="view_reformulate_generic_request_wizard" model="ir.ui.view">
<field name="name">reformulate_generic_request_wizard.form</field>
<field name="model">ref.generic.request</field>
<field name="type">form</field>
<field name="arch" type="xml">
<!-- create a normal form view, with the fields you've created on your python file -->
<form string="Insert reformulation info" version="7.0">
<group >
<separator string="Please insert instruction for the reformulation of this request" colspan="2"/>
<field name="reformulation_info" string="Reformulation info"/>
<newline/>
</group>
<div style="text-align:right">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" name="save_info" string="Send to reformulation" type="object" />
</div>
</form>
</field>
</record>
<!-- your action window refers to the view_id you've just created -->
<record id="action_reformulate_generic_request" model="ir.actions.act_window">
<field name="name">Reformulate Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ref.generic.request</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_reformulate_generic_request_wizard"/>
<field name="target">new</field>
</record>
<act_window id="action_reformulate_generic_request"
name="Reformulate Request"
res_model="ref.generic.request"
view_mode="form"
target="new"
/>
</data>
</openerp>
编辑 - 您可能想使用向导来更新已存储在数据库中的信息,为此您必须进行搜索并加载包含此信息的向导。这就是我正在做的方式(不确定这是否是最好的方式,我会把它留在这里也许有人会评论更正它!)
class review_opinion(osv.osv_memory):
_name='review.opinion'
_columns = {
'opinion_emission': fields.text('Opinion emission'),
'notes': fields.text('Additional notes'),
}
#defaults calls a function that will browse your main object and fill the field with the existing information
_defaults={
'opinion_emission': lambda self, cr, uid, context: self._get_opinion(cr, uid, context),
'notes': lambda self, cr, uid, context: self._get_notes(cr, uid, context), # populates requestor field with actual user id
}
def save_info(self, cr, uid, ids, context=None):
if 'active_id' in context:
info = self.browse(cr,uid,ids)
self.pool.get('opinion').write(cr,uid,context['active_id'],{'opinion_emission': info[0].opinion_emission,'notes': info[0].notes})
return {
'type': 'ir.actions.act_window_close',
}
#functions that get the info stored in db
def _get_opinion(self, cr, uid, context=None):
if 'active_id' in context:
return self.pool.get('opinion').browse(cr, uid, context['active_id'], context).opinion_emission
def _get_notes(self, cr, uid, context=None):
if 'active_id' in context:
return self.pool.get('opinion').browse(cr, uid, context['active_id'], context).notes
review_opinion()
关于python - OpenERP 向导语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24366986/
我正在实现 WPF MVVM 向导,我想知道执行 DoOperation 的正确方法当加载新的向导页面 (UserControl) 时。 DoOperation在 MyWizard.ViewModal
我有一个场景,我正在尝试计划开始编码,并且我正在考虑使用django向导。 我的计划是通过两个步骤构建一个 django 向导,第一个简单,但第二个有点复杂。第二步将包含一个表单,该表单将根据第一步选
我想看看这些是否“建立了……” Flash网站(以支持用户定制的订购过程)是使用常规Flash还是Flex完成的? Site 1 Site 2 Site 3 Site 4 所有这些都可以通过定制的订购
我在人们提交一些数据的表单上使用了 FuelUX 向导,我们希望将其分解为逻辑步骤。效果非常好。 现在我正在处理相同表单的编辑版本,它工作正常,但由于步骤已经加载了数据,我希望用户能够直接跳到步骤 X
我有一个足够大的模型,可以切割成 3 种形式。我想使用 FormWizzard 来做到这一点,但我想知道,如何将表单中的信息保存到数据库? 所有东西都来自同一个模型。 你知道如何做到这一点吗? 最佳答
我使用 Primefaces 3.5。并尝试在的onnext处理程序中调用js函数。我希望在当前选项卡验证结果后,onnext 返回特定选项卡上的选项卡。我的验证函数 function val
我在我的应用程序中实现了向导 Bootstrap 。 我想检索当前选项卡的索引来测试显示或隐藏按钮“下一个”“上一个” $('#rootwizard').bootstrapWizard({ '
我想创建一个基于终端的安装程序/向导。 理想情况下,它就像 Ubuntu 服务器安装程序或 Arch Linux 安装程序——一个 ncurses (?) 重的 GUI,具有很多形式和箭头键优点。 其
问题 我的 WizardPage 中有一个 Composite,如果该 Composite 比向导窗口大,我想向其中添加滚动条,但到目前为止我尝试过的方法都不起作用。有人知道如何添加滚动条吗? 我想将
我正在尝试制作一个引导步骤表单,但它不想工作。我正在使用这段代码: https://codepen.io/digitalavinash/pen/VjyAXx?fbclid=IwAR2j8hRIG0gn
我目前正在开发一个网站(与健身相关),客户想要做一个功能,允许用户根据您从类似于 this example 上的 slider 中选择的选项来选择锻炼计划。 . 我想知道这是否可以用 CSS 完成,或
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 6 年前。 Improve
这应该很简单,但我错过了。我试图通过在我的 stylesheet.css 中使用此 css 将文本居中放置在我的向导 h1 标签中 .h1textalign { text-align:center;
我已经在这里问过这个问题 Creating next and back button on tabs bootstrap 3 wizard? 但我现在已经扩展它以在最后一个选项卡上添加完成,但现在我在
摩尔庄园手游已经上线好几天了,身边不少小伙伴也都开始玩了,不过其中的还是有不少的玩法等待大家去解锁,比如大家知道怎么去传送好友,蘑菇吗?向导怎么传送呢?有哪些方法和技巧?下面就和小编一起来看看。
每次我在我的 Android Studio 中为该项目创建一个新 fragment 时,它都会创建 android.support.v4.app.Fragment ,这不是我想要的。此外,它总是会触发
我正在为我的公司项目使用 SAPUI5 向导,但由于某种原因它对我不起作用。 这是我的代码: var allSteps = oWizardElement.getSteps(); var stepOne
在扩展中,我希望能够修改现有链接。数据库中的相应字段可能包含多个链接(例如 tt_content.bodytext)。 我想尽可能多地重用现有的功能。所以我想使用已经存在的链接向导。 我找到的是现有路
长话短说,我有一个开发人员让我成为一名向导,即使我付了钱给他,他也没有在没有回复的情况下离开,并坚持使用一个半工作的Python向导。 该向导在 Kodi 内部运行,下载并解压 zip 文件。但有时我
我对 Fuel UX 向导有疑问。当我按下 fuel ux 向导上的下一步按钮时,我发送使用 validate_step(step) 选择的 category_id 并使用来自 php 的 json
我是一名优秀的程序员,十分优秀!