我试图在支付发票时禁用之前的日期,但它对我不起作用。
这是我的模特:
numX = Σ_i (pi_A.x^2 - pi_A.x * pi_B.x - pi_A.x * pi_C.x + pi_B.x * pi_C.x)
numY = Σ_i (pi_A.y^2 - pi_A.y * pi_B.y - pi_A.y * pi_C.y + pi_B.y * pi_C.y)
denX = Σ_i (pi_A.x^2 - 2 * pi_A.x * pi_B.x + pi_B.x^2)
denY = Σ_i (pi_A.y^2 - 2 * pi_A.y * pi_B.y + pi_B.y^2)
t = (numX + numY) / (denX + denY)
这是我的xml文件:
@Override
public void onBackPressed(){
FragmentManager fm = getFragmentManager();
if (fm.getBackStackEntryCount() > 0) {
Log.i("MainActivity", "popping backstack");
fm.popBackStack();
} else {
Log.i("MainActivity", "nothing on backstack, calling super");
super.onBackPressed();
}
}
错误:
TypeError:onchange_date()至少需要5个参数(给定2个)
请有人帮助我。谢谢!
答案 0 :(得分:0)
我认为这可能有用, 你的模特:
@api.onchange('payment_date')
def onchange_date(self):
if datetime.strptime(self.payment_date, DEFAULT_SERVER_DATE_FORMAT).date() > datetime.now().date():
self.payment_date = ''
您的观点:
<odoo>
<data>
<record model="ir.ui.view" id="view_account_payment_invoice_form">
<field name="name">account.payment.invoice.form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_date']" position="replace">
<field name="payment_date"/>
</xpath>
</field>
</record>
</data>
</odoo>
答案 1 :(得分:0)
您收到错误的原因是因为您正在混合旧API和新API。如果你想使用旧式API(cr, uid, ids, ...
和XML on_change=...
),你必须在你的新API方法上添加一个装饰器(你的python是新的API,因为你的类继承了models.Model
)。
# This decorator provides cr, uid, ids, and context variables
# to your method by default (like the old API had)
@api.cr_uid_ids_context
def onchange_date(self, cr, uid, ids, payment_date, context=None):
...
您可以在this blog post
上阅读有关这些特殊装饰器(在9.0版中引入)的更多信息。