跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

T

tedi3231

@tedi3231
关于
帖子
20
主题
7
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • 9.0社区版中开发自定义widget
    T tedi3231

    的确是这个样子,以前都没注意过。 ;D
    [quote author=Jeff link=topic=17658.msg32388#msg32388 date=1467122427]
    界面上对一个字段展示两次,前一个字段的值不显示
    [/quote]


  • 9.0社区版中开发自定义widget
    T tedi3231

    在FORM报表中添加饼状图的方法
    无锡特迪 [email protected] QQ:85920312

    在ODOO9.0社区版中对JS的调用方式略有变化,简单介绍下如何通过JS自定义控件。

    创建目录
    在模块下创建"static/src/js/"目录用来存放JS文件,如果需要用到QWEB模板的话应该再建一个“static/src/view”,名称可自行定义。

    添加JS文件
    这里添加一个名为"widgets.js"的文件,具体9.0下的语法可参考官方文档(注意9.0下的那个和petstore有关的文档都没有更新,JS的语法有些变化.饼状图使用了Highcharts的JS报表,具体使用方法可参考文档.

    <br /> odoo.define(&#039;crm_cm.crm_cm&#039;, function (require) {<br />&quot;use strict&quot;;<br /><br />var core = require(&#039;web.core&#039;);<br />var form_common = require(&#039;web.form_common&#039;);<br />var formats = require(&#039;web.formats&#039;);<br />var Model = require(&#039;web.Model&#039;);<br /><br />var _t = core._t;<br />var QWeb = core.qweb;<br /><br />var BarChart = form_common.AbstractField.extend({<br />render_value:function(){<br />&nbsp; &nbsp; var self = this;<br />&nbsp; &nbsp; console.log(this.get(&quot;value&quot;));<br />&nbsp; &nbsp; //这里的value对于one2many字段来讲就是多个Id数组,如[1,5,3]<br />&nbsp; &nbsp; var line_ids = this.get(&quot;value&quot;);<br />&nbsp; &nbsp; var mod = new Model(&quot;crm.cm.asset.allocation.result.line&quot;);<br /><br />&nbsp; &nbsp; mod.query([&quot;rule_name&quot;,&quot;rule_percent&quot;,&quot;amount&quot;])<br />&nbsp; &nbsp; &nbsp; &nbsp; .filter([&#91;&#039;id&#039;,&#039;in&#039;,line_ids]])<br />&nbsp; &nbsp; &nbsp; &nbsp; .all().then(function(lines){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(lines);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var data = lines.map(function(item,index){return [item.rule_name,item.amount];});<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.$el.highcharts({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chart: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: &#039;pie&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options3d: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enabled: true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha: 45,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; beta: 0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text: &#039;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tooltip: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pointFormat: &#039;{series.name}{point.amount}: &lt;b&gt;{point.percentage:.1f}%&lt;/b&gt;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plotOptions: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pie: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allowPointSelect: true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cursor: &#039;pointer&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; depth: 35,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataLabels: {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enabled: true,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: &#039;{point.name}-{point.percentage:.1f}%&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; series: [{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: &#039;pie&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: &#039;占比&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: data<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; }<br />});<br /><br />//这句话一定要有,要不然找不到这个控件的<br />core.form_widget_registry.add(&quot;barchart&quot;,BarChart);<br />});<br /><br />
    



    将JS文件在头部进行引用
    在模块的views文件中添加一个assets.xml文件,内容如下:

    <br /> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;openerp&gt;<br />&nbsp; &nbsp; &lt;data&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;template id=&quot;assets_backend&quot; name=&quot;crm_cm_assets2&quot; inherit_id=&quot;web.assets_backend&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xpath expr=&quot;.&quot; position=&quot;inside&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;script type=&quot;text/javascript&quot; src=&quot;/crm_cm/static/src/js/widgets.js&quot;&gt;&lt;/script&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;script src=&quot;http://cdn.hcharts.cn/highcharts/highcharts.js&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;  &lt;/xpath&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/template&gt;<br />&nbsp; &nbsp; &lt;/data&gt;<br />&lt;/openerp&gt;<br /><br />在openerp.py的data中添加涉及到的文件<br /><br /> &#039;data&#039;: [<br />&nbsp; &nbsp; #其他视图省略<br />&nbsp; &nbsp; &quot;views/assets.xml&quot;,<br />&nbsp; &nbsp; #&quot;report/gold_report.xml&quot;,<br />],<br />
    


    在FORM中使用饼状图控件
    在FORM视图中使用上面的饼图控件,将fields的widget属性设为"barchart"就可以了,我目前是用在one2many字段上的。代码如下:

    <br />&nbsp; &nbsp;  &lt;group string=&quot;Asset Allocation Result Line&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;result_lines_2&quot; nolabel=&quot;1&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;tree string=&quot;Asset Allocation Result Line&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;rule_id&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;rule_percent&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;amount&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tree&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;  &lt;/field&gt;<br />&nbsp; &nbsp; &lt;/group&gt;<br /><br />&nbsp; &nbsp; &lt;group string=&quot;Bar Chart&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;result_lines&quot; widget=&quot;barchart&quot; nolabel=&quot;1&quot;/&gt;<br />&nbsp; &nbsp; &lt;/group&gt;<br />
    


    注意事项
    我目前只在one2many字段上测试过,而且引用了外部的highcharts,有其他朋友建议可以使用odoo中原有的饼图控件nvd3,有空研究下。另外 result_lines_2 字段是个冗余字段,只是用在同时展示列表和饼图时使用,因为测试过程中发现界面上对一个字段展示两次的时候有可能不显示,具体原因尚未研究出来。这样的用法应该也只能用在one2many字段上,代码如下:

    <br />result_lines = fields.One2many(&quot;crm.cm.asset.allocation.result.line&quot;,&quot;result_id&quot;,string=&quot;Asset Allocation Result Line&quot;)<br />result_lines_2 = fields.One2many(&quot;crm.cm.asset.allocation.result.line&quot;,&quot;result_id&quot;,string=&quot;Asset Allocation Result Line&quot;)<br />
    

  • 测试给客户发送会议邀请,客户无法激活的问题
    T tedi3231

    在 calendar 中新建会议,并将客户回到会议中来,创建成功后系统会自动发送一封邀请邮件给客户。内容如下图:
    [img [检测到链接无效,已移除] /img]
    当用户点击接受后可能会出现下面的错误信息:
    [img [检测到链接无效,已移除] /img]
    哈哈这个问题很简单,但容易被忽略,就是你打开邮件的浏览器目前也正登陆着ODOO的其他账号,请确认你已经注销了账号后再打开邮件接受。成功接受后的页面:
    [img [检测到链接无效,已移除] /img]


  • 请教:ubuntu源码安装成功,浏览器打开创建数据出错
    T tedi3231

    [quote author=laowoo link=topic=16754.msg29503#msg29503 date=1417942334]
    按照坛子里的教程在在 Ubuntu Server 14.04上安装了odoo8,一切都顺利

    但是在浏览器里打开之后,第一步:Create a New Database
    就出现如下错误:
    [attachimg=1]

    是/etc/odoo-server.conf 里面的信息填写不正确吗?
    [/quote]
    最好能把CONSOLE里面的信息帖出来


  • 大家看看我这个Domain如何写
    T tedi3231

    问题解决了,还是基础不牢。对这种情况,可以添加<field name="room_id" domain = "[('store_id','=',parent.store_id)]"/>
    用parent就可以解决类似的问题


  • 大家看看我这个Domain如何写
    T tedi3231
    <br />class Reservation(osv.osv):<br />&nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; 客户预约<br />&nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; _name = &quot;spa.reservation&quot;<br /><br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; # &#039;name&#039; : fields.char(string=&quot;Name&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;name&#039; : fields.related(&quot;partner_id&quot;, &quot;name&quot;, type=&quot;char&quot;, string=&quot;Name&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;partner_id&#039; : fields.many2one(&#039;res.partner&#039;, string=&quot;Customer&quot;, required=True, domain=&quot;[(&#039;customer&#039;,&#039;=&#039;,1)]&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;store_id&#039; : fields.many2one(&#039;spa.store&#039;, string=&quot;Store&quot; , required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;emp_id&#039; : fields.many2one(&#039;hr.employee&#039;, string=&quot;Employee&quot;, domain=&quot;[(&#039;store_id&#039;,&#039;=&#039;,store_id)]&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;reservationdate&#039; : fields.datetime(string=&quot;Reservation Date&quot;, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;remark&#039; : fields.char(string=&quot;Remark&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;reservationlines&#039;: fields.one2many(&#039;spa.reservationline&#039;, &#039;reservation_id&#039;, string=&quot;Reservation Lines&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;state&#039; : fields.selection([(&#039;draft&#039;, &#039;Draft&#039;), (&#039;cancel&#039;, &#039;Cancel&#039;), (&#039;complete&#039;, &#039;Complete&#039;)], string=&quot;State&quot;, readonly=True),<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; _defaults = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;state&#039;:lambda self, cr, uid, context:&#039;draft&#039;,<br />&nbsp; &nbsp; }<br />Reservation()<br /><br />class ReservationLine(osv.osv):<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; # &quot;name&quot;:fields.related(&quot;product_id&quot;,&quot;name&quot;,type=&quot;string&quot;,string=&quot;Name&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;reservation_id&quot;: fields.many2one(&quot;spa.reservation&quot;, string=&quot;Reservation&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;product_id&quot; : fields.many2one(&quot;spa.product&quot;, string=&quot;Product&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;room_id&quot; : fields.many2one(&quot;spa.room&quot;, string=&quot;Room&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;emp_id&quot; : fields.many2one(&quot;hr.employee&quot; , string=&quot;Employee&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;price&quot; : fields.float(string=&quot;Price&quot;, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;unit&quot; : fields.char(string=&quot;Unit&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;count&quot;:fields.integer(string=&quot;Product Count&quot;, required=True),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;amount&quot; : fields.float(string=&quot;Amount&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; # &quot;amount&quot; : fields.function(_get_reservation_line_amount, string=&quot;Amount&quot;),<br />&nbsp; &nbsp; }<br />
    

    ```
    class Store(osv.osv):
        _name = "spa.store"

        def name_get(self, cr, uid, ids, context=None):
            res = []
            display_widget = None
            if context:
                display_widget = context.get("display_widget", None)
            for r in self.read(cr, uid, ids, ['name', 'storenum']):
                if display_widget == "dropdownlist":
                    res.append((r['id'], '(%s)%s' % (r['storenum'], r['name'])))
                else:
                    res.append((r['id'], r['name']))
            return res

        def name_search(self, cr, uid, name="", args=None, operator="ilike", context=None, limit=100):
            if not args:
                args = []
            if not context:
                context = {}
            ids = []
            if name:
                ids = self.search(cr, uid, [('storenum', operator, name)] + args, limit=limit, context=context)
            if not ids:
                ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context)
            return self.name_get(cr, uid, ids, context=context)

        _columns = {
            "name":fields.char(string="Store Name", required=True, size=200),
            "storenum":fields.char(string="Store num", required=True, size=100),
            "country_id":fields.many2one("res.country", string="Country", store=True, required=True),
            "province_id":fields.many2one("res.country.state", string="Province", store=True, required=True, domain=[('country_id', '=', 49)]),
            "address":fields.char(string="Address", size=200),
            "contactperson":fields.char(string="Contact Person", size=100),
            "telephone":fields.char(string="Telephone", size=50),
            "mobile":fields.char(string="Mobile", size=50),
            "email":fields.char(string="Email", size=200),
            "xCoordinate":fields.char(string="X", size=200),
            "yCoordinate":fields.char(string="Y", size=200),
            "rooms" : fields.one2many("spa.room", "store_id", string="Rooms"),
            "remark":fields.text(string="Remark")
        }
        _sql_constraints = [('storenum_uniq', 'unique(storenum)', 'Storenum must be unique!')]

    Store()

    class Room(osv.osv):
        """
        房间
        """
        _name = "spa.room"

        _columns = {
            "name": fields.char(string="Room Name", required=True, size=200),
            "roomnum":fields.char(string="Room Number", required=False, size=100),
            "store_id": fields.many2one("spa.store", string="Store", required=True),
            "description": fields.text(string="Description", required=False),
            "remark" : fields.text(string="Remark"),
        }
    Room()
    ```

    ```
    <record model="ir.ui.view" id="view_reservation_form">
    <field name="name">view.reservation.form</field>
    <field name="model">spa.reservation</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
    <form string="Customer Reservation" version="7.0">
    <header>
    <button name="reservation_complete" states="draft" type="object" string="Convert To Order" class="oe_hightlight"/>
    <button name="reservation_cancel" states="draft" type="object" string="Cancel" class="oe_hightlight"/>
    <field name="state" widget="statusbar" statusbar_visible="draft,cancel" statusbar_colors='{"cancel":"red","draft":"blue"}'/>
    </header>
    <sheet>
    <group col="4">
    <field name="partner_id"/>
    <field name="store_id"/>
    <field name="emp_id"/>
    <field name="reservationdate"/>
    </group>
    <group>
    <field name="remark"/>
    </group>
    <notebook>
    <page string="Reservation Lines">
    <field name="reservationlines">
    <tree version="7.0" editable="bottom">
    <field name="product_id" on_change="product_id_change(product_id,count)"/>
    <field name="room_id" />
    <field name="emp_id"/>
    <field name="count" on_change="product_count_change(count,price)"/>
    <field name="price"/>
    <field name="amount"/>
    </tree>
    </field>
    </page>
    </notebook>
    </sheet>
    </form>
    </field>
    </record>
    ```

    我希望的是FORM的Store改变后,在Tree中选择的房间只能是选中的Store下的房间。
    尝试了几种方式都不行,第一种是在ReservationLine的room_id添加了一个Domain [('store_id','=','reservation_id.store_id')],
    第二种方式是尝试在view中添加domain也不可以,还请高手赐教,谢谢

  • 求问为什么插入一段代码就会出错
    T tedi3231

    这个应该是不行的,以前刚学的时候我也这么做过。你需要在Code中定义这样的字段。具体原因等大牛来补充。你可以尝试在DEBUG模式下向视图中添加字段试试


  • 求问为什么插入一段代码就会出错
    T tedi3231

    这个字段是不是你通过DEBUG模式直接添加的啊?


  • Php 使用 xmlrpc 操作OE问题
    T tedi3231

    先到分类表中找到值,直接给就好了


  • 如何根据用户组隐藏FORM页面中的编辑和创建按钮
    T tedi3231

    [quote author=Joshua link=topic=9920.msg19950#msg19950 date=1377354089]
    我觉得你可以尝试通过配置view的groups来实现你的需求,你可以参考下这里: http://cn.openerp.cn/view_groups/
    [/quote]

    Joshua,非常感谢。最终我还是用了这种方式,针对特定的组将表单中的所有字段设置为只读。


  • 如何根据用户组隐藏FORM页面中的编辑和创建按钮
    T tedi3231

    Hi 大家好,
        如何根据用户组隐藏FORM页面中的编辑和创建按钮?我找了几天了没有找到正确的处理方式,希望大家能够帮忙,下面是我试过的方式:
        1) 在要设置的组下将对象设为只读,编辑按钮是不显示了,但同时我还需要通过其他按钮编辑某个字段,此时会提示没有写权限
        2) 在FORM中设置edit="false" create="false" ,然后再另外添加按钮,并在按钮中使用groups限定其显示。可以创建,但修改不知道如何设置,而且在视图中会点击创建,如果在弹出的页面中再点击创建则会报异常。

        我还是希望能够使用原先的修改和创建功能,请各位大侠帮忙,谢谢


  • 动作绑定如何设置做安全设定?
    T tedi3231

    Hi 大家好,开发中遇到个麻烦的事情,对动作绑定如何做安全设置?
    我通过动作绑定在Tree视图的More中增加了两个菜单,希望不同组的用户使用不同的菜单,但是在没有找到设置组的地方。各位大侠有没有好的解决办法?谢谢先。

    <br />		&lt;!-- 导出对账 --&gt;<br />		&lt;record id=&quot;action_tms_export_fee_to_account&quot; model=&quot;ir.actions.server&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;Export To Account&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;type&quot;&gt;ir.actions.server&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model_id&quot; ref=&quot;model_tms_feebase&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;state&quot;&gt;code&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;code&quot;&gt;self.export_to_account(cr, uid,context.get(&#039;active_ids&#039;), context=context)&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;val_action_tms_export_fee_to_account&quot; model=&quot;ir.values&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;Export to Account&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;action_id&quot; ref=&quot;action_tms_export_fee_to_account&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;value&quot; eval=&quot;&#039;ir.actions.server,&#039; + str(ref(&#039;action_tms_export_fee_to_account&#039;))&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;key&quot;&gt;action&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model_id&quot; ref=&quot;model_tms_feebase&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;model&quot;&gt;tms.feebase&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;key2&quot;&gt;client_action_multi&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!--&lt;field name=&quot;groups&quot;&gt;tms.group_tms_fee_finance&lt;/field&gt;--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />
    

  • 继承时如果使用了不同的名称能否使用视图继承
    T tedi3231

    [quote author=ccdos link=topic=9144.msg18882#msg18882 date=1375200370]
    _inherit 后就不要改名字了,用同一个model
    加个 类别字段来区别不同的数据
    [/quote]

    Hi ccos,谢谢你的答复。如果不改名字我在使用的过程中遇到的问题是视图继承后会导致父类视图也发生变化。我希望在添加不同费用时显示不同的FORM。


  • 继承时如果使用了不同的名称能否使用视图继承
    T tedi3231

    有哪位大牛知道不?


  • 继承时如果使用了不同的名称能否使用视图继承
    T tedi3231

    我有一个需求是这样的。一个朋友为一家连锁店装了很多摄像头,这些设备经常出问题,所以会有很多报修之类的东西处理,修好后也有一堆费用需要处理。因为各种不同的费用在填写的时候有许多字段都是一样的,我就想用继承了来实现,代码如下:

    <br />class FeeBase(osv.osv):<br />&nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; 费用基本类型,作为维护费用来使用<br />&nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; _name=&quot;tms.feebase&quot;<br /><br />&nbsp; &nbsp; _columns={<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;processid&quot;:fields.char(string=&quot;ProcessId&quot;,size=100,required=False),&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;feedate&quot;:fields.date(string=&quot;Fee Date&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;store_id&quot;:fields.many2one(&quot;tms.store&quot;,string=&quot;Store&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;storenum&quot;:fields.related(&quot;store_id&quot;,&quot;name&quot;,type=&quot;char&quot;,string=&quot;Store Num&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;province&quot;:fields.function(get_province_name,type=&quot;char&quot;,string=&quot;Province&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;feetype_id&quot;:fields.many2one(&quot;tms.feetype&quot;,&quot;Fee Type&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;payman&quot;:fields.many2one(&quot;res.users&quot;,&quot;Pay Man&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;amount&quot;:fields.float(string=&quot;Amount&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;accountamount&quot;:fields.float(string=&quot;Account Amount&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;accountperiod&quot;:fields.char(string=&quot;Account Period&quot;, size=20,required=False),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;oanum&quot;:fields.char(string=&quot;OA Num&quot;,size=100),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;remark&quot;:fields.text(string=&quot;Remark&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;state&quot;:fields.selection([(&quot;draft&quot;,&quot;Draft&quot;),(&quot;hasexported&quot;,&quot;Has Exported&quot;),(&quot;hasoa&quot;,&quot;Has Input OANum&quot;),(&quot;hasback&quot;,&quot;Has Back&quot;)],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  string=&quot;States&quot;),<br />&nbsp; &nbsp; }<br />
    

    ```
    class FeeForSend(osv.osv):
        _inherit="tms.feebase"
        _name = "tms.feeforsend"

        _columns={
            "sendcompany":fields.many2one("tms.sendcompany","Send Company"),
            "sendordernum":fields.char(string="Send Order num",size=100,required=True),
            "sendproduct":fields.char(string="Send Product", size=200,required=True),
        }
    ```
    ```
    class FeeForProductIt(osv.osv):
        _inherit="tms.feebase"
        _name = "tms.feeforproductit"

        _columns={
            "productname":fields.char(string="Product Name",size=200),
            "productprice":fields.float(string="Product Price"),
            "productcount":fields.integer(string="Product Count"),
            "accountproductprice":fields.integer(string="Account Product Price"),
            "accountproductcount":fields.integer(string="Account Product Count")
        }

    FeeForProductIt()

    class FeeForItService(osv.osv):
        _inherit="tms.feebase"
        _name = "tms.feeforitservice"

    FeeForItService()
    ```
    ```
    <record model="ir.ui.view" id="view_tms_feebase_tree">
                <field name="name">tms.feebase.tree</field>
                <field name="model">tms.feebase</field>
                <field name="type">tree</field>
                <field name="arch" type="xml">
                    <tree string="维护费登记">
                        <field name="processid"/>
                        <field name="store_id" />
                        <field name="province"/>
                        <field name="storenum"/>
                        <field name="accountperiod"/>
                        <field name="feetype_id"/>
                        <field name="feedate"/>
                        <field name="payman"/>
                        <field name="amount" sum="Account" />
                        <field name="accountamount" sum="Account Amount"/>
    <field name="state"/>
    <field name="oanum"/>
                    </tree>
                </field>
            </record>
    ```
    从代码中可以看出每个子类与父类相差很小,在视图中只需要多添加几个字段或者完全不用添加。但当我使用视图的继承的机制时发现如果对象在继承时_name与父类不一样,视图是不能继承的。
    有没有什么办法可以让我能够共用父类的视图?

  • 点击save按钮,mrp的工单号才自动增长
    T tedi3231

    如果default_get中处理了自增长的字段,这个要去掉;可以重写一下save方法,在保存按钮点击的时候调用


  • 如何在tree视图的More中添加按钮并调用方法
    T tedi3231

    [quote author=ccdos link=topic=8098.msg17801#msg17801 date=1374846339]
    EO中处理用户提交excel,返回结果<br / [检测到链接无效,已移除] br />


    另外,详细代码 可以参考 翻译的导出
    [/quote]

    Hi ccdos,谢谢你的回答。我的功能和你描述的差不多,用户在tree页面选择多条数据对比后产生对比文档,类型为EXCEL。是不是说在OPENERP中要是想做下载的话必须做成导出翻译的模式,就是说导出后还是需要一个VIEW让用户点击后下载,有没有可能说我在比较结束后直接就给出文件下载框?


  • 如何在tree视图的More中添加按钮并调用方法
    T tedi3231

    另外想问下,我如何在一个action里面直接把文件下载下来?即点击菜单后直接出现保存文件对话框?


  • 如何在tree视图的More中添加按钮并调用方法
    T tedi3231

    呵呵,找到方法了,贴上来供大家参考,是openerp question上面的答案,地址:http://help.openerp.com/question/7468/why-cant-i-make-a-button-in-tree/


  • 如何在tree视图的More中添加按钮并调用方法
    T tedi3231

    我的需求是这样的,我需要在一个Tree中选择多条记录,通过点击“More”中的一个菜单,执行一个方法的调用,需要能够处理选中的多条记录。打个比方,我希望能够选择多条产品记录后,能够将它们的状态设置为“已设置”,这里不需要wizard,只是一个状态的变化。 查了几天了,没有头绪,还希望大牛们赐教。另一个同样的问题是,选择多条记录后根据我自己的方法产生一个文档,希望能够直接。

  • 登录

  • 没有帐号? 注册

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组