2016-05-04 7 views
0

商品の価格を相殺するために使用される負の金額の「クーポン」と呼ばれる商品があります。しかし、それは負の金額の計算がprice_subtotalすることはできませんOdoo 8のように思える(これは0.00となります):私は負の符号を削除するとOdoo 8マイナス請求書明細を許可する

Coupon ... ... 1 Each -40.0000 0.0000 

は、それが会計上の観点から

Coupon ... ... 1 Each 40.0000 40.0000 

を計算します合計請求書はマイナスであってはいけません。それは本当だ。ただし、請求書明細のマイナス計算を許可する必要があります。どこを変更する必要がありますか?私はaccount/account.pyを探してみましたが、これまでのところ役に立たなかったのです。それはちょうど "税"に関連しています。

ありがとうございます!予想通りラインの金額欄の

詳細は総 Details of the Amount column for the line total

enter image description here

class account_invoice(models.Model) 
    .... 

    @api.one 
    @api.depends('invoice_line.price_subtotal', 'tax_line.amount') 
    def _compute_amount(self): 
     self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line) 
     self.amount_tax = sum(line.amount for line in self.tax_line) 
     self.amount_total = self.amount_untaxed + self.amount_tax 

    .... 

class account_invoice_line(models.Model): 
    _name = "account.invoice.line" 
    _description = "Invoice Line" 
    _order = "invoice_id,sequence,id" 

    @api.one 
    @api.depends('price_unit', 'discount', 'invoice_line_tax_id', 'quantity', 
     'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id') 
    def _compute_price(self): 
     price = self.price_unit * (1 - (self.discount or 0.0)/100.0) 
     taxes = self.invoice_line_tax_id.compute_all(price, self.quantity, product=self.product_id, partner=self.invoice_id.partner_id) 
     self.price_subtotal = taxes['total'] 
     if self.invoice_id: 
      self.price_subtotal = self.invoice_id.currency_id.round(self.price_subtotal) 

    @api.model 
    def _default_price_unit(self): 
     if not self._context.get('check_total'): 
      return 0 
     total = self._context['check_total'] 
     for l in self._context.get('invoice_line', []): 
      if isinstance(l, (list, tuple)) and len(l) >= 3 and l[2]: 
       vals = l[2] 
       price = vals.get('price_unit', 0) * (1 - vals.get('discount', 0)/100.0) 
       total = total - (price * vals.get('quantity')) 
       taxes = vals.get('invoice_line_tax_id') 
       if taxes and len(taxes[0]) >= 3 and taxes[0][2]: 
        taxes = self.env['account.tax'].browse(taxes[0][2]) 
        tax_res = taxes.compute_all(price, vals.get('quantity'), 
         product=vals.get('product_id'), partner=self._context.get('partner_id')) 
        for tax in tax_res['taxes']: 
         total = total - tax['amount'] 
     return total 
+0

account_invoice.pyを調べてみましたか? – SDBot

+0

ありがとう@SDBotはトレースしようとしていますが、price_unitが負の値であれば、量を0に制限するものは見つけられないようです。 – jeszy

+0

開発者モードを起動する(右上のodooをクリックしてください)、そのフィールドがどのモデルに属しているかを調べ、計算フィールドである可能性が高いです。何も見つからない場合は計算フィールドのメソッドを調べ、メソッドを投稿してみてくださいここに。 – SDBot

答えて

0

Odooのデフォルトの動作は、それを処理しています。問題はカスタムコードです。 (詳細は質問のコメントを読む)

関連する問題