我是 Odoo 会计的新手。我在计算供应商账单的借方和贷方金额时遇到问题。我在采购订单行中添加了两个新字段,discount_type 和 discount_amt。小计值必须是 (price_unit * quantity) - 折扣。我可以计算小计金额。但是当我检查日记帐项目时,借方和贷方金额没有改变。我的意思是没有减去折扣金额。但是当我保存表格时,我得到了一个错误,说借方和贷方不平衡。我怎样才能做到这一点?
def compute_price_subtotal(self):
for line in self:
line.discount_type = line.purchase_line_id.discount_type
line.discount_amt = line.purchase_line_id.discount_amt
qty = line.quantity or 0
price_unit = line.price_unit or 0
subtotal = price_unit * qty
discount_type = line.discount_type
discount_amount = line.discount_amt
if discount_type == 'fixed':
discount = discount_amount * qty
line.price_subtotal = subtotal - discount
elif discount_type == 'percentage':
discount = subtotal * (discount_amount / 100)
line.price_subtotal = subtotal - discount
else:
line.price_subtotal = subtotal
if line.move_id.type in line.move_id.get_outbound_types():
sign = 1
elif line.move_id.type in line.move_id.get_inbound_types():
sign = -1
else:
sign = 1
price_subtotal = sign * line.price_subtotal
line.update({
'debit': price_subtotal > 0.0 and price_subtotal or 0.0,
'credit': price_subtotal < 0.0 and -price_subtotal or 0.0,
})
上述方法是计算price_subtotal、借方和贷方。
图中未税金额为13800,税金为690。所以总金额为13800 + 690 = 14490。但在Journal items中显示为15000,小计值不同。