跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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 中文社区

G

ghotiv

@ghotiv
关于
帖子
12
主题
5
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • 整理及测试:Odoo11安装,Odoo11生产环境部署:在Ubuntu Server16.04下Odoo11安装并配置为服务
    G ghotiv

    odoo 要授予root权限么,数据库,一些文件夹权限都是odoo


  • 怎么让框架中的“创建”和“导入”这种自带的按钮不显示,
    G ghotiv

    @yeko tree里面属性没有 重写wiew form渲染函数


  • ondelete='restrict'
    G ghotiv

    数据库表的触发器 或者重写删除方法吧


  • view中怎么用domain筛选user的当前公司
    G ghotiv

    context里面default_*这样赋值


  • 隐藏 创建,复制,删除 按钮
    G ghotiv

    在tree里面将属性设置成false即可
    <tree delete="false" create="false" copy="false">

    创建,复制,删除 隐藏,生效

    export="false"  导出 没隐藏 不生效


  • Odoo 读写excel
    G ghotiv

    jeff 大虾转载啊,记得提出bug


  • Odoo 读写excel
    G ghotiv

    odoo经常要导入和导出数据,excel是比较常见的文档,读写excel,上代码

    <br /># -*- coding: utf-8 -*- <br /># author:ghoti<br />import xlrd<br />import xlwt<br />import base64<br />import cStringIO<br />class Read_Excel:<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 根据索引获取Excel表格中的数据&nbsp;  参数:file_name:Excel文件路径;file_contents:二进制文件/字符串<br />&nbsp; &nbsp; &nbsp;  col_n:表头列名所在行数 ;del_n:表的后几行不读入; by_index:表的索引(默认第一个sheet)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 返回表格中某一行作为key的字典列表,key为unicode类型<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 校验:不能有重复的项,不能有空项<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; def __init__(self,file_contents=None,file_name=None,col_n=1,del_n=0,by_index=0,):<br />&nbsp; &nbsp; &nbsp; &nbsp; self.file_name = file_name<br />&nbsp; &nbsp; &nbsp; &nbsp; self.file_contents = file_contents<br />&nbsp; &nbsp; &nbsp; &nbsp; self.col_n = col_n<br />&nbsp; &nbsp; &nbsp; &nbsp; self.del_n = del_n<br />&nbsp; &nbsp; &nbsp; &nbsp; self.by_index = by_index<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; def __call__(self):<br />&nbsp; &nbsp; &nbsp; &nbsp; try:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = xlrd.open_workbook(filename=self.file_name,file_contents=self.file_contents)<br />&nbsp; &nbsp; &nbsp; &nbsp; except Exception,e:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print str(e)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return None<br />&nbsp; &nbsp; &nbsp; &nbsp; col_n = self.col_n<br />&nbsp; &nbsp; &nbsp; &nbsp; del_n = self.del_n<br />&nbsp; &nbsp; &nbsp; &nbsp; by_index = self.by_index<br />&nbsp; &nbsp; &nbsp; &nbsp; table = data.sheets()[by_index]<br />&nbsp; &nbsp; &nbsp; &nbsp; nrows = table.nrows #行数<br />&nbsp; &nbsp; &nbsp; &nbsp; #ncols = table.ncols #列数<br />&nbsp; &nbsp; &nbsp; &nbsp; colnames =&nbsp; table.row_values(col_n-1) #某一行数据做字典的key<br />&nbsp; &nbsp; &nbsp; &nbsp; #validate<br />&nbsp; &nbsp; &nbsp; &nbsp; if colnames:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repeat_colnames = set([str(i) for i in colnames if colnames.count(i)!=1])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i in colnames:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not i:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise NameError(&#039;Null colname exist&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if repeat_colnames:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert_info = &#039;;&#039;.join(repeat_colnames)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise NameError(&#039;repeat colname exist : %s&#039;%alert_info)<br />&nbsp; &nbsp; &nbsp; &nbsp; rsp =&#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; for rownum in range(col_n,nrows-del_n):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; row = table.row_values(rownum)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if row:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i in range(len(colnames)):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app[colnames[i].strip()] = row[i]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsp.append(app)<br />&nbsp; &nbsp; &nbsp; &nbsp; return rsp<br /><br />class Export_Excel:&nbsp;  <br />&nbsp; &nbsp; &#039;&#039;&#039;返回导出excel二进制数据,sheet_name为sheet名,headings为第一行,data为第二行后,2个列表的内容一一对应&#039;&#039;&#039;<br />&nbsp; &nbsp; def __init__(self,headings,data,sheet_name=&#039;export_xls&#039;,file_name=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; self.sheet_name = sheet_name<br />&nbsp; &nbsp; &nbsp; &nbsp; self.headings = headings<br />&nbsp; &nbsp; &nbsp; &nbsp; self.data = data<br />&nbsp; &nbsp; &nbsp; &nbsp; self.file_name = file_name<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; def __call__(self):<br />&nbsp; &nbsp; &nbsp; &nbsp; book = xlwt.Workbook()<br />&nbsp; &nbsp; &nbsp; &nbsp; sheet = book.add_sheet(self.sheet_name)<br />&nbsp; &nbsp; &nbsp; &nbsp; rowx = 0<br />&nbsp; &nbsp; &nbsp; &nbsp; for colx, value in enumerate(self.headings):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sheet.write(rowx, colx, value)<br />&nbsp; &nbsp; &nbsp; &nbsp; sheet.set_panes_frozen(True) # frozen headings instead of split panes<br />&nbsp; &nbsp; &nbsp; &nbsp; sheet.set_horz_split_pos(rowx+1) # in general, freeze after last heading row<br />&nbsp; &nbsp; &nbsp; &nbsp; sheet.set_remove_splits(True) # if user does unfreeze, don&#039;t leave a split there<br />&nbsp; &nbsp; &nbsp; &nbsp; for row in self.data:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowx += 1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for colx, value in enumerate(row):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sheet.write(rowx, colx, value.encode(&#039;utf-8&#039;).decode(&#039;utf-8&#039;))<br />&nbsp; &nbsp; &nbsp; &nbsp; buf = cStringIO.StringIO()<br />&nbsp; &nbsp; &nbsp; &nbsp; if self.file_name:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; book.save(self.file_name)<br />&nbsp; &nbsp; &nbsp; &nbsp; book.save(buf)<br />&nbsp; &nbsp; &nbsp; &nbsp; out = base64.encodestring(buf.getvalue())<br />&nbsp; &nbsp; &nbsp; &nbsp; buf.close()<br />&nbsp; &nbsp; &nbsp; &nbsp; return out<br /><br />&#039;&#039;&#039;&nbsp;  <br />##test_for_use<br /><br />r = Read_Excel(file_contents=base64.decodestring(form&#91;&#039;import&#039;]),col_n=3,del_n=1)<br />trades = r()[:]<br />print trades[0][u&#039;收货人姓名&#039;]<br />print len(tables)<br />for row in tables:<br />&nbsp; &nbsp; print row<br />&nbsp; &nbsp; for i in row:<br />&nbsp; &nbsp; &nbsp; &nbsp; print i,row[i]<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />headings = [u&#039;订单号&#039;,u&#039;下单日期&#039;]<br />values = [&#91;&#039;12345&#039;,&#039;2012-12-12&#039;],&#91;&#039;12346&#039;,&#039;2012-12-12&#039;]]<br />out = Export_Excel(headings,values)()<br />_result_fields&#91;&#039;data&#039;]&#91;&#039;default&#039;] = out<br />&#039;&#039;&#039;<br />&#039;&#039;&#039;<br />from read_excel import Read_Excel<br />print Read_Excel(file_name=&#039;a.xls&#039;)()<br />[{&#039;c_1&#039;:&#039;a_1&#039;,&#039;c_2&#039;:&#039;b_1&#039;},{&#039;c_1&#039;:&#039;a_2&#039;,&#039;c_2&#039;:&#039;b_2&#039;}]<br />&#039;&#039;&#039;<br />
    

  • Python多线程(threading)
    G ghotiv

    恩恩,这个写的通用性强些,不仅在oe,其它地方也可以用


  • Python多线程(threading)
    G ghotiv
    <br /># -*- coding: utf-8 -*- <br />#author:ghoti<br />&#039;&#039;&#039;自定义多线程运行函数,可定义同时运行个数&#039;&#039;&#039;<br />import threading,time<br />from time import sleep,ctime<br />class My_Thead:<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 多线程运行函数,将all_list切片处理,num为进程数,all_list小于num,单线程运行,<br />&nbsp; &nbsp; sleep_time为单个进程(一个all_list切片)运行后停留时间(方便调试),<br />&nbsp; &nbsp; myfunc为处理每个切片的函数,对all_list切片,在处理<br />&nbsp; &nbsp; &#039;&#039;&#039;<br />&nbsp; &nbsp; def __init__ (self, all_list, num, sleep_time=0, myfunc=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; self.all_list = all_list<br />&nbsp; &nbsp; &nbsp; &nbsp; self.len_list = len(all_list)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.num = num&nbsp; &nbsp; #进程数,实际进程为可能为num+1<br />&nbsp; &nbsp; &nbsp; &nbsp; if len(all_list)&lt;num:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.num = 1<br />&nbsp; &nbsp; &nbsp; &nbsp; self.m = self.len_list/self.num<br />&nbsp; &nbsp; &nbsp; &nbsp; if not self.m:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.m = 1<br />&nbsp; &nbsp; &nbsp; &nbsp; self.loops=range(0 , self.len_list, self.m)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.sleep_time = sleep_time<br />&nbsp; &nbsp; &nbsp; &nbsp; self.myfunc = myfunc<br />&nbsp; &nbsp; def loop (self,nloop,n,m):<br />&nbsp; &nbsp; &nbsp; &nbsp; self.myfunc(n,m)<br />&nbsp; &nbsp; &nbsp; &nbsp; sleep(self.sleep_time)<br />&nbsp; &nbsp; def __call__ (self):<br />&nbsp; &nbsp; &nbsp; &nbsp; if not self.all_list:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return False<br />&nbsp; &nbsp; &nbsp; &nbsp; threads=&#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; nloops=range(len(self.loops))<br />&nbsp; &nbsp; &nbsp; &nbsp; for i in nloops:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=threading.Thread(target=self.loop,args=(i, self.loops[i], self.m))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; threads.append(t)<br />&nbsp; &nbsp; &nbsp; &nbsp; for i in nloops:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; threads[i].start()<br />&nbsp; &nbsp; &nbsp; &nbsp; for i in nloops:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; threads[i].join()<br /><br />&#039;&#039;&#039;<br />##how to use<br />#from my_thread import My_Thead<br />all_list = range(103)<br />def myfunc(n,m):<br />&nbsp; &nbsp; part_list = all_list[n:n+m]<br />&nbsp; &nbsp; for i in part_list:<br />&nbsp; &nbsp; &nbsp; &nbsp; print i,<br />My_Thead(range(103),5,myfunc=myfunc)()<br />&#039;&#039;&#039;<br /><br />&#039;&#039;&#039;&nbsp; &nbsp; &nbsp; &nbsp; <br />## use in oe<br />&nbsp; &nbsp; &nbsp; &nbsp; def myfunc(n,m):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; part_list = rsps[n:n+m]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for rsp in part_list:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.action_do_product(cr, uid, ids, rsp, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; from openerp.addons.basefunc.my_thread import My_Thead<br />&nbsp; &nbsp; &nbsp; &nbsp; My_Thead(rsps,10,myfunc=myfunc)()<br />&#039;&#039;&#039;<br />
    

  • Odoo 组合价格实现方法
    G ghotiv

    临时完成生产 要自己写方法的


  • Odoo 组合价格实现方法
    G ghotiv

    想在odoo中实现 组合价格 的功能,比如3A(优惠3)+ 2B(优惠2)= C 一起优惠 13
    方案一:
    请教了下gavin,gavin建议利用生产中产品bom的功能,订单中 临时完成生产,组合出C产品

    这样要安装生产模块

    方案二:
    如果不安装生产模块,自己bom仿照设计模型sale_bom
    sale.bom 里面存组合产品C的信息,有产品对象product_id,bom_line_ids
    sale.bom.line  里面存组成产品的i信息A和B,有product_id,bom_id (外键到sale_bom)

    这样订单里面每次要读sale_bom信息,然后生成C

    [attachimg=3]

    方案三:
    请教了严总,实现累似 multi image 的功能,就用 multi_image 一个字段,保存产品组合优惠的信息,类似json的格式存取组合信息
    这样虽然数据库简单了,但是要用到qweb和js,界面就复杂了

    方案四:
    发现product images这个模块,是product 一对多 image 的实现,image 保存tile,descrption字段,类似,image保存产品A和B的信息,
    那么怎么保存产品A和产品B的信息,字符字段保存A的id或者sku? 那么界面上又该怎么设计选择产品,然后保存id或者sku

    [attachimg=4]


  • Seeed Studio 【深圳】 招聘 pythoner
    G ghotiv

    岗位要求:
    1年以上python开发经验
    能用openerp二次开发
    会用Django等python框架建站(电商)

    工作时间,待遇:
    灵活的休假方式(双休)
    和大家一起分享每半年度50%的利润

    地址:深圳南山西丽同沙路32号矽递科技(环中线:留仙洞站B出口步行约10分钟路程)

    敬请电邮至: [email protected]

    公司简介:
    深圳矽递科技有限公司 ( Seeed Studio) 为小型创新者提供快速开发工具, 帮助硬件产品原型投入生产和市场推广。
    自2008年7月在深圳成立以来一直保持着高速增长, 形成了包括市场、研发、工程品质、生产、供应链、运营等完整架构的高效团队。 截止2012年, 为全世界的五万多创客和发明家提供了超过700种各类开放源代码的硬件模块, 将各种如NFC, Zigbee, BLE等新兴技术以极低的应用门槛提供给创新者。

    公司创始人、总经理潘昊先生是《福布斯》中文版/2013年3月刊推出的“中国30位30岁以下创业者”之一,并荣登《福布斯》封面 :http://www.forbeschina.com/review/201303/0024076.shtml

    在Seeed你都可以:
      寻找无尽的机会和挑战
      充分被授权
      拥有简单真诚的团队关系
      和大家一起分享每半年度50%的利润
      灵活的休假方式(双休)
      对公司任何方面提出建设性的意见

  • 登录

  • 没有帐号? 注册

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