first commit
This commit is contained in:
2
modules/analytic_invoice/__init__.py
Normal file
2
modules/analytic_invoice/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/analytic_invoice/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/analytic_invoice/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/analytic_invoice/__pycache__/asset.cpython-311.pyc
Normal file
BIN
modules/analytic_invoice/__pycache__/asset.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/analytic_invoice/__pycache__/invoice.cpython-311.pyc
Normal file
BIN
modules/analytic_invoice/__pycache__/invoice.cpython-311.pyc
Normal file
Binary file not shown.
75
modules/analytic_invoice/asset.py
Normal file
75
modules/analytic_invoice/asset.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# 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.modules.analytic_account import AnalyticMixin
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Asset(AnalyticMixin, metaclass=PoolMeta):
|
||||
__name__ = 'account.asset'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.analytic_accounts.domain = [
|
||||
('company', '=', Eval('company', -1)),
|
||||
]
|
||||
|
||||
@fields.depends('supplier_invoice_line', 'analytic_accounts')
|
||||
def on_change_supplier_invoice_line(self):
|
||||
pool = Pool()
|
||||
Entry = pool.get('analytic.account.entry')
|
||||
|
||||
super().on_change_supplier_invoice_line()
|
||||
if self.supplier_invoice_line:
|
||||
entries = []
|
||||
for entry in self.supplier_invoice_line.analytic_accounts:
|
||||
new_entry = Entry()
|
||||
for field in Entry._fields:
|
||||
if field in {'origin', 'id'}:
|
||||
continue
|
||||
setattr(new_entry, field, getattr(entry, field))
|
||||
entries.append(new_entry)
|
||||
self.analytic_accounts = entries
|
||||
|
||||
def get_move(self, line):
|
||||
move = super().get_move(line)
|
||||
self.set_analytic_lines(move, self.product.account_expense_used)
|
||||
return move
|
||||
|
||||
def get_closing_move(self, account, date=None):
|
||||
move = super().get_closing_move(account, date=date)
|
||||
if not account:
|
||||
accounts = [
|
||||
self.product.account_revenue_used,
|
||||
self.product.account_expense_used,
|
||||
]
|
||||
else:
|
||||
accounts = [account]
|
||||
for account in accounts:
|
||||
self.set_analytic_lines(move, account)
|
||||
return move
|
||||
|
||||
def set_analytic_lines(self, move, account):
|
||||
"Fill analytic lines on lines with given account"
|
||||
if self.analytic_accounts:
|
||||
with Transaction().set_context(date=move.date):
|
||||
for line in move.lines:
|
||||
if line.account != account:
|
||||
continue
|
||||
analytic_lines = []
|
||||
for entry in self.analytic_accounts:
|
||||
analytic_lines.extend(
|
||||
entry.get_analytic_lines(line, move.date))
|
||||
line.analytic_lines = analytic_lines
|
||||
|
||||
|
||||
class UpdateAsset(metaclass=PoolMeta):
|
||||
__name__ = 'account.asset.update'
|
||||
|
||||
def get_move(self, asset):
|
||||
move = super().get_move(asset)
|
||||
asset.set_analytic_lines(move, self.show_move.counterpart_account)
|
||||
return move
|
||||
12
modules/analytic_invoice/asset.xml
Normal file
12
modules/analytic_invoice/asset.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data depends="account_asset">
|
||||
<record model="ir.ui.view" id="asset_view_form">
|
||||
<field name="model">account.asset</field>
|
||||
<field name="inherit" ref="account_asset.asset_view_form"/>
|
||||
<field name="name">asset_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
137
modules/analytic_invoice/invoice.py
Normal file
137
modules/analytic_invoice/invoice.py
Normal file
@@ -0,0 +1,137 @@
|
||||
# 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.modules.analytic_account import AnalyticMixin
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
|
||||
class InvoiceLine(AnalyticMixin, metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.analytic_accounts.domain = [
|
||||
('company', '=', Eval('company', -1)),
|
||||
]
|
||||
cls.analytic_accounts.states = {
|
||||
'invisible': Eval('type') != 'line',
|
||||
'readonly': Eval('invoice_state') != 'draft',
|
||||
}
|
||||
|
||||
def _credit(self):
|
||||
pool = Pool()
|
||||
AnalyticAccountEntry = pool.get('analytic.account.entry')
|
||||
|
||||
line = super()._credit()
|
||||
if self.analytic_accounts:
|
||||
new_entries = AnalyticAccountEntry.copy(self.analytic_accounts,
|
||||
default={
|
||||
'origin': None,
|
||||
})
|
||||
line.analytic_accounts = new_entries
|
||||
return line
|
||||
|
||||
def get_move_lines(self):
|
||||
lines = super().get_move_lines()
|
||||
if self.invoice and self.invoice.type:
|
||||
type_ = self.invoice.type
|
||||
else:
|
||||
type_ = self.invoice_type
|
||||
asset_depreciable = (self.product and type_ == 'in'
|
||||
and self.product.type == 'assets'
|
||||
and getattr(self.product, 'depreciable', False))
|
||||
if self.analytic_accounts and not asset_depreciable:
|
||||
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
|
||||
|
||||
|
||||
class InvoiceDeferred(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.deferred'
|
||||
|
||||
def get_move(self, period=None):
|
||||
move = super().get_move(period=period)
|
||||
if self.invoice_line.analytic_accounts:
|
||||
for line in move.lines:
|
||||
if line.account.type.statement != 'income':
|
||||
continue
|
||||
analytic_lines = []
|
||||
for entry in self.invoice_line.analytic_accounts:
|
||||
analytic_lines.extend(
|
||||
entry.get_analytic_lines(line, move.date))
|
||||
line.analytic_lines = analytic_lines
|
||||
return move
|
||||
|
||||
|
||||
class AnalyticAccountEntry(metaclass=PoolMeta):
|
||||
__name__ = 'analytic.account.entry'
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
pool = Pool()
|
||||
origins = super()._get_origin()
|
||||
origins.append('account.invoice.line')
|
||||
try:
|
||||
pool.get('account.asset')
|
||||
origins.append('account.asset')
|
||||
except KeyError:
|
||||
pass
|
||||
return origins
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_company(self, name=None):
|
||||
pool = Pool()
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
try:
|
||||
Asset = pool.get('account.asset')
|
||||
except KeyError:
|
||||
Asset = None
|
||||
company = super().on_change_with_company(name=name)
|
||||
if (isinstance(self.origin, InvoiceLine)
|
||||
or (Asset and isinstance(self.origin, Asset))):
|
||||
company = self.origin.company
|
||||
return company
|
||||
|
||||
@classmethod
|
||||
def search_company(cls, name, clause):
|
||||
pool = Pool()
|
||||
domain = super().search_company(name, clause),
|
||||
domain = ['OR',
|
||||
domain,
|
||||
(('origin.' + clause[0],) + tuple(clause[1:3])
|
||||
+ ('account.invoice.line',) + tuple(clause[3:])),
|
||||
]
|
||||
try:
|
||||
pool.get('account.asset')
|
||||
domain.append(
|
||||
(('origin.' + clause[0],) + tuple(clause[1:3])
|
||||
+ ('account.asset',) + tuple(clause[3:])))
|
||||
except KeyError:
|
||||
pass
|
||||
return domain
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_editable(self, name=None):
|
||||
pool = Pool()
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
try:
|
||||
Asset = pool.get('account.asset')
|
||||
except KeyError:
|
||||
Asset = None
|
||||
|
||||
editable = super().on_change_with_editable(name=name)
|
||||
|
||||
if isinstance(self.origin, InvoiceLine):
|
||||
if self.origin.invoice_state != 'draft':
|
||||
editable = False
|
||||
elif Asset and isinstance(self.origin, Asset):
|
||||
if self.origin.state != 'draft':
|
||||
editable = False
|
||||
return editable
|
||||
12
modules/analytic_invoice/invoice.xml
Normal file
12
modules/analytic_invoice/invoice.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="invoice_line_view_form">
|
||||
<field name="model">account.invoice.line</field>
|
||||
<field name="inherit" ref="account_invoice.invoice_line_view_form"/>
|
||||
<field name="name">invoice_line_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
26
modules/analytic_invoice/locale/bg.po
Normal file
26
modules/analytic_invoice/locale/bg.po
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/ca.po
Normal file
23
modules/analytic_invoice/locale/ca.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analítics"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mida dels comptes analítics"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analítics"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mida dels comptes analítics"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
23
modules/analytic_invoice/locale/cs.po
Normal file
23
modules/analytic_invoice/locale/cs.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/de.po
Normal file
23
modules/analytic_invoice/locale/de.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Kostenstellen"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Kostenstellengröße"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Kostenstellen"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Kostenstellengröße"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Kostenstelle"
|
||||
23
modules/analytic_invoice/locale/es.po
Normal file
23
modules/analytic_invoice/locale/es.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
23
modules/analytic_invoice/locale/es_419.po
Normal file
23
modules/analytic_invoice/locale/es_419.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
23
modules/analytic_invoice/locale/et.po
Normal file
23
modules/analytic_invoice/locale/et.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analüütilised kontod"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Analüütiliste kontode mõõt"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analüütilised kontod"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Analüütiliste kontode mõõt"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analüütiline"
|
||||
23
modules/analytic_invoice/locale/fa.po
Normal file
23
modules/analytic_invoice/locale/fa.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "اندازه تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "اندازه تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "تحلیلی"
|
||||
23
modules/analytic_invoice/locale/fi.po
Normal file
23
modules/analytic_invoice/locale/fi.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/fr.po
Normal file
23
modules/analytic_invoice/locale/fr.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analytiques"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Taille des comptes analytiques"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analytiques"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Taille des comptes analytiques"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analytique"
|
||||
23
modules/analytic_invoice/locale/hu.po
Normal file
23
modules/analytic_invoice/locale/hu.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/id.po
Normal file
23
modules/analytic_invoice/locale/id.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/it.po
Normal file
23
modules/analytic_invoice/locale/it.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "conti analitici"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "dimensione conti analitici"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "conti analitici"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "dimensione conti analitici"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitico"
|
||||
23
modules/analytic_invoice/locale/lo.po
Normal file
23
modules/analytic_invoice/locale/lo.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "ບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "ຂະໜາດບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "ບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "ຂະໜາດບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/lt.po
Normal file
23
modules/analytic_invoice/locale/lt.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/nl.po
Normal file
23
modules/analytic_invoice/locale/nl.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analytische rekeningen"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Grootte analyserekeningen"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analytische rekeningen"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Grootte analyserekeningen"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "analytisch"
|
||||
23
modules/analytic_invoice/locale/pl.po
Normal file
23
modules/analytic_invoice/locale/pl.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/pt.po
Normal file
23
modules/analytic_invoice/locale/pt.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Contas Analíticas"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamanho da Conta Analítica"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Contas Analíticas"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamanho da Conta Analítica"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/ro.po
Normal file
23
modules/analytic_invoice/locale/ro.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Conturi Analitice"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Conturi Analitice Mărime"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Conturi Analitice"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mărimea Conturilor Analitice"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitic"
|
||||
26
modules/analytic_invoice/locale/ru.po
Normal file
26
modules/analytic_invoice/locale/ru.po
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/sl.po
Normal file
23
modules/analytic_invoice/locale/sl.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Stroškovna mesta"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Velikost stroškovnih mest"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Stroškovna mesta"
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Velikost stroškovnih mest"
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Stroškovno mesto"
|
||||
23
modules/analytic_invoice/locale/tr.po
Normal file
23
modules/analytic_invoice/locale/tr.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/uk.po
Normal file
23
modules/analytic_invoice/locale/uk.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
23
modules/analytic_invoice/locale/zh_CN.po
Normal file
23
modules/analytic_invoice/locale/zh_CN.po
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.asset,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:account.invoice.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:account.invoice.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
2
modules/analytic_invoice/tests/__init__.py
Normal file
2
modules/analytic_invoice/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
125
modules/analytic_invoice/tests/scenario_analytic_invoice.rst
Normal file
125
modules/analytic_invoice/tests/scenario_analytic_invoice.rst
Normal file
@@ -0,0 +1,125 @@
|
||||
=========================
|
||||
Analytic Invoice Scenario
|
||||
=========================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... create_payment_term, set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('analytic_invoice', create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
|
||||
Create analytic accounts::
|
||||
|
||||
>>> AnalyticAccount = Model.get('analytic_account.account')
|
||||
>>> root = AnalyticAccount(type='root', name='Root')
|
||||
>>> root.save()
|
||||
>>> analytic_account = AnalyticAccount(root=root, parent=root,
|
||||
... name='Analytic')
|
||||
>>> analytic_account.save()
|
||||
|
||||
Create party::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> party = Party(name='Party')
|
||||
>>> party.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('40')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Create invoice with analytic accounts::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
>>> entry, = line.analytic_accounts
|
||||
>>> assertEqual(entry.root, root)
|
||||
>>> entry.account = analytic_account
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 5
|
||||
>>> line.unit_price = Decimal('40')
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.credit
|
||||
Decimal('200.00')
|
||||
>>> analytic_account.debit
|
||||
Decimal('0.00')
|
||||
|
||||
|
||||
Create invoice with an empty analytic account::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
>>> entry, = line.analytic_accounts
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('40')
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.credit
|
||||
Decimal('200.00')
|
||||
>>> analytic_account.debit
|
||||
Decimal('0.00')
|
||||
|
||||
Credit invoice with refund::
|
||||
|
||||
>>> credit = Wizard('account.invoice.credit', [invoice])
|
||||
>>> credit.form.with_refund = True
|
||||
>>> credit.execute('credit')
|
||||
>>> invoice.reload()
|
||||
>>> invoice.state
|
||||
'cancelled'
|
||||
@@ -0,0 +1,150 @@
|
||||
=====================================
|
||||
Analytic Invoice with Assets Scenario
|
||||
=====================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_asset.tests.tools import add_asset_accounts
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> next_month = today + relativedelta(day=1, month=1)
|
||||
>>> next_next_month = next_month + relativedelta(months=1)
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['analytic_invoice', 'account_asset'],
|
||||
... create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=(today, next_next_month)))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_asset_accounts(get_accounts())
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> asset_account = accounts['asset']
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create analytic accounts::
|
||||
|
||||
>>> AnalyticAccount = Model.get('analytic_account.account')
|
||||
>>> root = AnalyticAccount(type='root', name='Root')
|
||||
>>> root.save()
|
||||
>>> analytic_account = AnalyticAccount(root=root, parent=root,
|
||||
... name='Analytic')
|
||||
>>> analytic_account.save()
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create an asset::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> asset_template = ProductTemplate()
|
||||
>>> asset_template.name = 'Asset'
|
||||
>>> asset_template.type = 'assets'
|
||||
>>> asset_template.default_uom = unit
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.depreciation_duration = 10
|
||||
>>> asset_template.save()
|
||||
>>> asset_product, = asset_template.products
|
||||
|
||||
Buy an asset::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> InvoiceLine = Model.get('account.invoice.line')
|
||||
>>> supplier_invoice = Invoice(type='in')
|
||||
>>> supplier_invoice.party = supplier
|
||||
>>> invoice_line = supplier_invoice.lines.new()
|
||||
>>> invoice_line.product = asset_product
|
||||
>>> invoice_line.quantity = 1
|
||||
>>> invoice_line.unit_price = Decimal('1000')
|
||||
>>> entry, = invoice_line.analytic_accounts
|
||||
>>> entry.account = analytic_account
|
||||
>>> supplier_invoice.invoice_date = next_month
|
||||
>>> supplier_invoice.click('post')
|
||||
>>> supplier_invoice.state
|
||||
'posted'
|
||||
>>> invoice_line, = supplier_invoice.lines
|
||||
>>> analytic_account.debit
|
||||
Decimal('0.00')
|
||||
>>> analytic_account.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Depreciate the asset::
|
||||
|
||||
>>> Asset = Model.get('account.asset')
|
||||
>>> asset = Asset()
|
||||
>>> asset.product = asset_product
|
||||
>>> asset.supplier_invoice_line = invoice_line
|
||||
>>> asset.residual_value = Decimal(0)
|
||||
>>> asset.click('create_lines')
|
||||
>>> asset.click('run')
|
||||
|
||||
Create Moves for 1 month::
|
||||
|
||||
>>> create_moves = Wizard('account.asset.create_moves')
|
||||
>>> create_moves.form.date = next_next_month
|
||||
>>> create_moves.execute('create_moves')
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.debit
|
||||
Decimal('100.00')
|
||||
>>> analytic_account.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Update the asset::
|
||||
|
||||
>>> update = Wizard('account.asset.update', [asset])
|
||||
>>> update.form.value = Decimal('950.00')
|
||||
>>> update.execute('update_asset')
|
||||
>>> update.form.date = update.form.next_depreciation_date
|
||||
>>> update.execute('create_move')
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.debit
|
||||
Decimal('150.00')
|
||||
>>> analytic_account.credit
|
||||
Decimal('0.00')
|
||||
|
||||
Close the asset::
|
||||
|
||||
>>> asset.click('close')
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.debit
|
||||
Decimal('1000.00')
|
||||
>>> analytic_account.credit
|
||||
Decimal('0.00')
|
||||
@@ -0,0 +1,120 @@
|
||||
===============================
|
||||
Analytic Invoice Defer Scenario
|
||||
===============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.account_invoice_defer.tests.tools import (
|
||||
... add_deferred_accounts)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['analytic_invoice', 'account_invoice_defer'],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> AnalyticAccount = Model.get('analytic_account.account')
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> InvoiceDeferred = Model.get('account.invoice.deferred')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period = fiscalyear.periods[0]
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_deferred_accounts(get_accounts())
|
||||
|
||||
Create analytic accounts::
|
||||
|
||||
>>> root = AnalyticAccount(type='root', name='Root')
|
||||
>>> root.save()
|
||||
>>> analytic_account = AnalyticAccount(
|
||||
... root=root, parent=root, name="Analytic")
|
||||
>>> analytic_account.save()
|
||||
|
||||
Create party::
|
||||
|
||||
>>> party = Party(name="Insurer")
|
||||
>>> party.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = accounts['expense']
|
||||
>>> account_category.account_revenue = accounts['revenue']
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Insurance"
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('1000')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> invoice = Invoice(type='in')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('1000')
|
||||
>>> line.defer_from = period.start_date
|
||||
>>> line.defer_to = line.defer_from + dt.timedelta(days=499)
|
||||
>>> entry, = line.analytic_accounts
|
||||
>>> entry.account = analytic_account
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
>>> invoice_line, = invoice.lines
|
||||
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.debit, analytic_account.credit
|
||||
(Decimal('1000.00'), Decimal('0.00'))
|
||||
|
||||
Check invoice deferred and run it::
|
||||
|
||||
>>> deferral, = InvoiceDeferred.find([])
|
||||
>>> assertEqual(deferral.invoice_line, invoice_line)
|
||||
>>> deferral.amount
|
||||
Decimal('1000.00')
|
||||
>>> assertEqual(deferral.start_date, invoice_line.defer_from)
|
||||
>>> assertEqual(deferral.end_date, invoice_line.defer_to)
|
||||
>>> deferral.click('run')
|
||||
>>> deferral.state
|
||||
'running'
|
||||
>>> len(deferral.moves)
|
||||
13
|
||||
|
||||
>>> analytic_account.reload()
|
||||
>>> analytic_account.debit in {Decimal('1730'), Decimal('1732')}
|
||||
True
|
||||
>>> analytic_account.credit
|
||||
Decimal('1000.00')
|
||||
13
modules/analytic_invoice/tests/test_module.py
Normal file
13
modules/analytic_invoice/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class AnalyticInvoiceTestCase(ModuleTestCase):
|
||||
'Test AnalyticInvoice module'
|
||||
module = 'analytic_invoice'
|
||||
extras = ['account_asset', 'account_invoice_defer']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/analytic_invoice/tests/test_scenario.py
Normal file
8
modules/analytic_invoice/tests/test_scenario.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# 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.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
27
modules/analytic_invoice/tryton.cfg
Normal file
27
modules/analytic_invoice/tryton.cfg
Normal file
@@ -0,0 +1,27 @@
|
||||
[tryton]
|
||||
version=7.8.0
|
||||
depends:
|
||||
account_invoice
|
||||
analytic_account
|
||||
extras_depend:
|
||||
account_asset
|
||||
account_invoice_defer
|
||||
xml:
|
||||
invoice.xml
|
||||
asset.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
invoice.InvoiceLine
|
||||
invoice.AnalyticAccountEntry
|
||||
|
||||
[register account_asset]
|
||||
model:
|
||||
asset.Asset
|
||||
wizard:
|
||||
asset.UpdateAsset
|
||||
|
||||
[register account_invoice_defer]
|
||||
model:
|
||||
invoice.InvoiceDeferred
|
||||
|
||||
10
modules/analytic_invoice/view/asset_form.xml
Normal file
10
modules/analytic_invoice/view/asset_form.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/notebook/page[@id='lines']" position="after">
|
||||
<page name="analytic_accounts" col="1">
|
||||
<field name="analytic_accounts"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
10
modules/analytic_invoice/view/invoice_line_form.xml
Normal file
10
modules/analytic_invoice/view/invoice_line_form.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/notebook" position="inside">
|
||||
<page string="Analytic" id="analytic_accounts">
|
||||
<field name="analytic_accounts" colspan="4"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in New Issue
Block a user