mirror of
https://github.com/NaN-tic/trytond-analytic_line_state.git
synced 2023-12-14 03:33:02 +01:00
In case the invoice line has analytic accounts and customer invoice, copy analytic lines to move lines
issue5909 #039256
This commit is contained in:
parent
efbe83eb9e
commit
81ebb003a1
3 changed files with 38 additions and 2 deletions
|
@ -1,10 +1,9 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import account
|
||||
from . import analytic
|
||||
|
||||
from . import invoice
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
|
@ -19,6 +18,10 @@ def register():
|
|||
account.MoveLine,
|
||||
analytic.OpenChartAccountStart,
|
||||
module='analytic_line_state', type_='model')
|
||||
Pool.register(
|
||||
invoice.InvoiceLine,
|
||||
depends=['account_invoice'],
|
||||
module='analytic_line_state', type_='model')
|
||||
Pool.register(
|
||||
analytic.OpenChartAccount,
|
||||
module='analytic_line_state', type_='wizard')
|
||||
|
|
31
invoice.py
Normal file
31
invoice.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval, If
|
||||
|
||||
__all__ = ['InvoiceLine']
|
||||
|
||||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
def get_move_lines(self):
|
||||
lines = super(InvoiceLine, self).get_move_lines()
|
||||
if self.invoice and self.invoice.type:
|
||||
type_ = self.invoice.type
|
||||
else:
|
||||
type_ = self.invoice_type
|
||||
# analytic_invoice add analytic accounts when is supplier invoice (in)
|
||||
# See issue5909
|
||||
# In case the invoice line has analytic accounts and customer invoice,
|
||||
# copy analytic lines to move lines.
|
||||
if type_ == 'out' and self.analytic_accounts:
|
||||
date = self.invoice.accounting_date or self.invoice.invoice_date
|
||||
for line in lines:
|
||||
analytic_lines = []
|
||||
for entry in self.analytic_accounts:
|
||||
analytic_lines.extend(
|
||||
entry.get_analytic_lines(line, date))
|
||||
line.analytic_lines = analytic_lines
|
||||
return lines
|
|
@ -4,6 +4,8 @@ depends:
|
|||
account
|
||||
analytic_account
|
||||
company
|
||||
extras_depend:
|
||||
account_invoice
|
||||
xml:
|
||||
account.xml
|
||||
analytic.xml
|
||||
|
|
Loading…
Reference in a new issue