main #7
@@ -1286,9 +1286,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin):
|
|||||||
remainder = sum(l.debit - l.credit for l in move_lines)
|
remainder = sum(l.debit - l.credit for l in move_lines)
|
||||||
if self.payment_term:
|
if self.payment_term:
|
||||||
payment_date = self.payment_term_date or self.invoice_date or today
|
payment_date = self.payment_term_date or self.invoice_date or today
|
||||||
purchase_line = int(str(self.lines[0].origin).split(",")[1]) if self.lines[0].origin else None
|
model = str(self.lines[0].origin).split(",")[0] if self.lines[0].origin else None
|
||||||
|
if model:
|
||||||
|
Line = Pool().get(model)
|
||||||
|
line = Line(int(str(self.lines[0].origin).split(",")[1]))
|
||||||
term_lines = self.payment_term.compute(
|
term_lines = self.payment_term.compute(
|
||||||
self.total_amount, self.currency, payment_date, purchase_line)
|
self.total_amount, self.currency, payment_date, line)
|
||||||
else:
|
else:
|
||||||
term_lines = [(self.payment_term_date or today, self.total_amount)]
|
term_lines = [(self.payment_term_date or today, self.total_amount)]
|
||||||
past_payment_term_dates = []
|
past_payment_term_dates = []
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class PaymentTerm(DeactivableMixin, ModelSQL, ModelView):
|
|||||||
'.msg_payment_term_missing_last_remainder',
|
'.msg_payment_term_missing_last_remainder',
|
||||||
payment_term=term.rec_name))
|
payment_term=term.rec_name))
|
||||||
|
|
||||||
def compute(self, amount, currency, date, purchase_line = None):
|
def compute(self, amount, currency, date, line = None):
|
||||||
"""Calculate payment terms and return a list of tuples
|
"""Calculate payment terms and return a list of tuples
|
||||||
with (date, amount) for each payment term line.
|
with (date, amount) for each payment term line.
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class PaymentTerm(DeactivableMixin, ModelSQL, ModelView):
|
|||||||
remainder = amount
|
remainder = amount
|
||||||
for line in self.lines:
|
for line in self.lines:
|
||||||
value = line.get_value(remainder, amount, currency)
|
value = line.get_value(remainder, amount, currency)
|
||||||
value_date = line.get_date(date, purchase_line)
|
value_date = line.get_date(date, line)
|
||||||
if value is None or not value_date:
|
if value is None or not value_date:
|
||||||
continue
|
continue
|
||||||
if ((remainder - value) * sign) < Decimal(0):
|
if ((remainder - value) * sign) < Decimal(0):
|
||||||
|
|||||||
Reference in New Issue
Block a user