首页 > 代码库 > odoo自动更新表中数据
odoo自动更新表中数据
这是追踪信息用的查询语句,__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自动更新表中数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。