Python 如何在store=False Odoo的功能字段上使用默认顺序?
我使用旧的API使用Odoo9,我发现自己处于一个棘手的境地 我试图在函数字段上使用默认的_顺序(store=False,因为每次新用户登录时我都需要重新计算该字段) 这是我的田地Python 如何在store=False Odoo的功能字段上使用默认顺序?,python,xml,openerp,odoo-9,Python,Xml,Openerp,Odoo 9,我使用旧的API使用Odoo9,我发现自己处于一个棘手的境地 我试图在函数字段上使用默认的_顺序(store=False,因为每次新用户登录时我都需要重新计算该字段) 这是我的田地 'my_last_explanation_date': fields.function(_get_my_last_explanation_info, string='تاريخ وتوقيت الإحالة', type='
'my_last_explanation_date': fields.function(_get_my_last_explanation_info, string='تاريخ وتوقيت الإحالة',
type='datetime',fnct_search=_my_outgoing_search),
'my_last_stored_date':fields.datetime(string='تاريخ وتوقيت الإحالة'),
用于计算两个字段的函数:
def _get_my_last_explanation_info(self, cr, uid, ids, fieldnames, args, context=None):
res={}
active_ids = []
mail_obj = self.pool.get('mail.message')
current_partner = self.pool.get('res.users').browse(cr,uid,uid).partner_id
cr.execute('''select * from mail_message mess
inner join messgae_sl_sender_rel rel on mess.id = rel.message_id
and rel.sender_id = %s
and mess.sl_status not in ('draft','canceled','archived')
and mess.sl_create = 't'
and mess.type in ('internal','external','export')
order by mess.id'''%(uid))
active_ids = [elem[0] for elem in cr.fetchall()]
if len(ids) == 1:
active_ids = ids
for id in active_ids:
cr.execute('''select forw.create_date from slnee_mail_message_forward forw
inner join mail_message mess on forw.sl_mail_message_id = mess.id
where mess.id = %s
and forw.sl_sender_id = %s
order by forw.create_date DESC '''%(id,current_partner.id))
res_query = cr.fetchone() or False
res[id] = res_query[0] if res_query else False
mail_obj.write(cr,uid,[id],{'my_last_stored_date':res[id]})
return res
还有XML
<record id="out_going_tree_view" model="ir.ui.view">
<field name="name">out_going.tree</field>
<field name="model">mail.message</field>
<field name="priority">20</field>
<field name="arch" type="xml">
<tree string="Messages" edit="false" create="false" duplicate="false" delete="false" class="oe_tree_view" default_order="my_last_stored_date"
row_classes="new-msg:to_read==True; new-signed:speech_state=='unsigned'; users-copie:is_copie_users==True ; secret-mail:sl_secret==True ; generalisation-mail:sl_generalization==True " >
<field name="type" string="الصنف" width="5%"/>
<field name="name" string="رقم المعاملة" width="5%"/>
<field name="my_last_stored_date" invisible="1"/>
<field name="my_last_explanation_date" width="20%"/>
<field name="subject" string="الموضوع" width="55%" widget="tag"
first_text=" سري " second_text=" عاجل "
first_class="tags secret-tag" second_class="tags urgent-tag"
attrs="{'first_condition': [('sl_secret','=',True)],'second_condition': [('sl_periority_haut','=',True)]}"/>
<field name="instruction_reciever_id" />
<field name="reciever_id" width="5%"/>
<field name="sl_status" width="5%" />
<field name="sl_periority_haut" invisible="1" />
<field name="to_read" invisible="1" />
<field name="sl_secret" invisible="1" />
<field name="instruction_name" invisible="1" />
<field name="sl_generalization" invisible="1" />
<field name="speech_state" invisible="1" />
<field name="is_copie_users" invisible="1"/>
</tree>
</field>
</record>
外出树
邮件
20
我使用一个字段的函数在另一个字段上写入,我尝试使用第二个字段进行排序,问题是用户只有在刷新后才能看到更新
任何帮助都将不胜感激。请编辑您的问题并添加:1。你的代码/你的尝试2。您的输入、当前输出和预期输出请编辑您的问题并添加:1。你的代码/你的尝试2。您的输入、当前输出和预期输出