0

在 date_due 过去后,谁能帮我自动向未结发票添加费用?例如,我在 res.company 中设置了管理费,当发票超过到期日时会调用该管理费。

问候,乔

4

1 回答 1

1

如果你想要它自动添加一个scheduler. 调度程序功能应在到期日之后搜索所有未清发票,并添加新的发票行和管理费或将管理费添加到现有的发票行。例如,下面是一个可用于创建调度程序的数据 xml。XML 部分

<record forcecreate="True" id="ir_cron_auto_invoice_scheduler_action" model="ir.cron">
    <field name="name">Run Automatic Invoice scheduler</field>
    <field eval="True" name="active"/>
    <field name="user_id" ref="base.user_root"/>
    <field name="interval_number">1</field>
    <field name="interval_type">days</field>
    <field name="numbercall">-1</field>
    <field eval="True" name="doall"/>
    <field eval="'your.model.name'" name="model"/><!--here it is account.invoice-->
    <field eval="'automatic_invoice_scheduler'" name="function"/>
    <!--its a new function in account.invoice model-->
    <!-- from which you can search all the invoices and what you need-->
    <field eval="'(False,)'" name="args"/>
</record>

Python部分

#Its just a example function.make necessary changes
#Inherit the account_invoice and add the function
import time
def automatic_invoice_scheduler(self, cr, uid, ids,context=None):
    ids = self.search(cr, uid,[('date_invoice','<=',time.strftime('%Y-%m-%d %H:%M:%S'),('state','open'),('due_added','=',False)], context=context)
    #due added is a new field you have to add so that once the due
    # is added then its invoice id is not added in the scheduler
    ###########################
    #Add your code here.add the due_fees to the invoice lines
    #write the due_added boolean field to true
    ###########################
    return True
于 2012-10-03T06:45:48.710 回答