码迷,mamicode.com
首页 > 其他好文 > 详细

odoo自动更新表中数据

时间:2017-06-20 23:27:16      阅读:348      评论:0      收藏:0      [点我收藏+]

标签:mod   dict   pre   partner   too   判断   exist   pool   语句   


这是追踪信息用的查询语句,__init__方法初始化作用

_order ="hpartner_id desc"
def init(self,cr):
tools.sql.drop_view_if_exists(cr, ‘cust_product_info_report‘)
cr.execute("""
create or replace view cust_product_info_report as (
select t0.id,t0.hpartner_id as hpartner_id, t0.khwl_code as khwl_code,t1.product_tmpl_id as productn, t3.cust_spec as cust_spec,t3.material as material ,
t4.id as name_uom, t0.custo_price as custo_price,t0.product_meno as product_meno ,t0.meno as meno
from product_custo_info t0
LEFT JOIN product_product t1 on t0.product_tmpl_id=t1.product_tmpl_id
LEFT JOIN product_template t3 on t3.id=t1.product_tmpl_id
LEFT JOIN res_partner t2 on t2.id=t0.hpartner_id
LEFT JOIN product_uom t4 on t3.uom_id=t4.id
)
""")



判断是否有重复数据

def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
code= vals.get(‘code‘,‘‘)
cr.execute("select id from res_partner where code=‘%s‘" %(code))
if cr.rowcount>0:
raise osv.except_osv(u‘提示‘,u"[客户/供应商]此简称已经存在!")
xh=1
requirement_ids=vals.get(‘requirement_ids‘)
if requirement_ids:
for rline in requirement_ids:
rline[2][‘sequence‘]=xh
xh=xh+1
ctx = dict(context or {}, mail_create_nolog=True)
new_id = super(product_template, self).create(cr, uid, vals, context=ctx)
return new_id

 

# 新加地方,执行动作找到对应页面
def action_custorm_state(self, cr, uid, ids, context=None):
name=self.browse(cr,uid,ids[0],context=context).name
act_obj = self.pool.get(‘ir.actions.act_window‘)
mod_obj = self.pool.get(‘ir.model.data‘)
result = mod_obj.xmlid_to_res_id(cr, uid, ‘ks_sale.action_view_cust_product_info_tree‘,raise_if_not_found=True)
result = act_obj.read(cr, uid, [result], context=context)[0]
result[‘domain‘] = "[(‘hpartner_id‘,‘=‘,"+ str(ids[0]) +")]"
return result


odoo自动更新表中数据

标签:mod   dict   pre   partner   too   判断   exist   pool   语句   

原文地址:http://www.cnblogs.com/1314520xh/p/7056755.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!