2016-12-30 86 views
1

我創建了一個自動操作,並且如果When to Run設置爲On Creation,它會正常工作。如果我將其更改爲Based on Timed Condition將不會觸發。自動操作不起作用 - odoo 8

自動操作 enter image description here

服務器操作

enter image description here

計劃操作 enter image description here

我怎樣才能做到這一點?

+0

你確定運行的操作是滿足的條件? – danidee

+0

觸發日期值是今天的日期。例如:30-12-2016 – KbiR

回答

0

你必須通過python代碼來做到這一點。你有沒有試過?

我有一個例子:性伴通知電子郵件發送:通過行動:

<record id="action_send_mail_on_partner_creation" model="ir.actions.server"> 
      <field name="name">Partner Creation action</field> 
      <field name="model_id" ref="base.model_res_partner"/> 
      <field name="type">ir.actions.server</field> 
      <field name="state">code</field> 
      <field name="code">self.parnter_create_notification(cr, uid, object, context=context)</field> 
     </record> 

     <record id="rule_sent_mail_partner_creation" model="base.action.rule"> 
      <field name="name">Partner Creation Action Rule</field> 
      <field name="kind">on_create_or_write</field> 
      <field name="model_id" ref="base.model_res_partner"/> 
      <field name="sequence">1</field> 
      <field name="filter_id" ref="filter_customer"/> 
      <field name="active">True</field> 
      <field name="server_action_ids" eval="[(6, 0, [ref('action_send_mail_on_partner_creation')])]"/> 
     </record> 

,你必須在PY文件中定義的方法是:

def parnter_create_notification(self, cr, uid, obj, context=None): 
    if context.get('from_create',False): 
     group_obj = self.pool.get('res.groups') 
     user_obj = self.pool.get('res.users') 
     if obj.customer or obj.supplier: 
      manager_ids = group_obj.search(cr, uid, [('name','=', 'Financial Manager')]) 
      user_ids = group_obj.browse(cr, uid, manager_ids, context=context)[0].users 
      email = [] 
      for id in user_ids: 
       email.append(id.email) 
      email_to = ','.join(str(e) for e in email) 
      tmpl_obj = self.pool.get('email.template') 
      tmpl_ids = tmpl_obj.search(cr, uid, [('name','=','Partner E-mail Template')]) 
      if tmpl_ids: 
       tmpl_obj.write(cr, uid, tmpl_ids[0], {'email_to':email_to}, context=context) 
       self.pool.get('email.template').send_mail(cr, uid, tmpl_ids[0], obj.id) 
    return {} 

在繼承類資源的。夥伴。

你可以爲你的問題採取這個例子。

希望這會幫助你。

感謝, 月光