2016-05-04 11 views
0

Ich habe ein Produkt namens "Coupon" mit negativer Menge, die verwendet wird, um den Produktpreis auszugleichen. Es ist jedoch wie Odoo 8 scheint Berechnung negativer Betrag nicht zulässt, price_subtotal (es wird 0,00):Odoo 8 Negative Rechnung erlauben Artikelposition

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

Wenn ich das negative Vorzeichen zu entfernen, es berechnet

Coupon ... ... 1 Each 40.0000 40.0000 

Aus bilanzieller Sicht , die Gesamtrechnung sollte nicht negativ sein. Das bleibt wahr. Allerdings muss ich eine negative Berechnung der Rechnungspositionen zulassen. Wo und was muss ich ändern? Ich habe versucht, in Konto/account.py zu suchen, aber bis jetzt vergeblich - es ist alles nur "Steuern" verwandt.

Vielen Dank im Voraus!

Einzelheiten der Menge Spalte für die Zeile Gesamt 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

Haben Sie versucht, in account_invoice.py zu suchen? – SDBot

+0

Dank @SDBot versucht zu verfolgen, aber kann nicht scheinen, etwas zu finden, das den Betrag auf 0 beschränkt, wenn price_unit von negativem Wert noch ist .... Hilfe? – jeszy

+0

Aktiviere den Entwicklermodus (oben rechts, klicke auf odoo), finde heraus, zu welchem ​​Modell dieses Feld gehört, es ist höchstwahrscheinlich ein berechnetes Feld, schau in die Methode des berechneten Feldes, wenn du dort nichts finden kannst, probiere die Methode Hier. – SDBot

Antwort

0

Odoo Standardverhalten es wie erwartet verarbeitet. Das Problem ist benutzerdefinierter Code. (Für weitere Informationen lesen Sie die Fragen Kommentare)

Verwandte Themen