为什么我在发票行中的计算结果与销售订单行中的计算结果不同?
当我确认销售订单时,它会在发票行中为我提供正确的计算结果,但是当我从发票行单独创建它时,它会给我一个不同的计算结果。以下是我的代码。
我还可以在account_invoice_line.py文件中做些什么?
class account_invoice_line(models.Model):
_inherit = 'account.invoice.line'
def _make_invoice(self, cr, uid, order, lines, context=None):
inv_id = super(sale_order_line, self)._make_invoice(cr, uid, order, lines, context)
inv_obj = self.pool.get('account.invoice.line')
if order.name_of_your_field:
inv_obj.write(cr, uid, [inv_id], {'order_line': order_line.id}, context=context)
return inv_id
# _columns = {
qty_char = fields.Float('Qty in M. Sqr')
def on_change_qty_squ(self, cr, uid, ids, qty_char, product , price_unit=0 , quantity=0 ,price_after_discount=0 , context=None):
qty_char = qty_char
product_obj = self.pool.get('product.product')
product_obj = product_obj.browse(cr, uid, product, context=context)
prod_type = product_obj.supp_ref
# prod_price = product_obj.lst_price
squ_meter = product_obj.squ_meter
price = price_unit
value = {}
if prod_type == 'T':
if qty_char:
typ = float(qty_char)
qty = typ / squ_meter
round = math.ceil(qty)
new_qty = round * squ_meter
value['quantity'] = round
subtotal = (quantity) * (price_after_discount)
value['price_subtotal'] = subtotal
else:
if qty_char:
typ = float(qty_char)
qty = typ / squ_meter
round = math.ceil(qty)
new_qty = round * squ_meter
value['quantity'] = round
subtotal = (quantity) * (price_after_discount)
value['price_subtotal'] = subtotal
return {'value': value}
@api.depends('price_after', 'price_unit', 'discount', 'invoice_line_tax_id', 'quantity',
'qty_char','product_id', 'invoice_id.partner_id', 'invoice_id.discount', 'invoice_id.currency_id', 'invoice_id.company_id')
def _compute_price_after(self):
self.price_after = self.price_unit * (1 - (self.invoice_id.discount or 0.0) / 100.0)
price_after = fields.Float(string='Price After Discount', digits= dp.get_precision('Account'),
store=True, readonly=True, compute='_compute_price_after')