first commit
This commit is contained in:
2
modules/analytic_purchase/__init__.py
Normal file
2
modules/analytic_purchase/__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_purchase/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/analytic_purchase/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/analytic_purchase/__pycache__/purchase.cpython-311.pyc
Normal file
BIN
modules/analytic_purchase/__pycache__/purchase.cpython-311.pyc
Normal file
Binary file not shown.
16
modules/analytic_purchase/locale/bg.po
Normal file
16
modules/analytic_purchase/locale/bg.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/ca.po
Normal file
15
modules/analytic_purchase/locale/ca.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analítics"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mida dels comptes analítics"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
15
modules/analytic_purchase/locale/cs.po
Normal file
15
modules/analytic_purchase/locale/cs.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/de.po
Normal file
15
modules/analytic_purchase/locale/de.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Kostenstellen"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Kostenstellengröße"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Kostenstelle"
|
||||
15
modules/analytic_purchase/locale/es.po
Normal file
15
modules/analytic_purchase/locale/es.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
15
modules/analytic_purchase/locale/es_419.po
Normal file
15
modules/analytic_purchase/locale/es_419.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/et.po
Normal file
15
modules/analytic_purchase/locale/et.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analüütilised kontod"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Analüütilisete kontode suurus"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analüütiline"
|
||||
15
modules/analytic_purchase/locale/fa.po
Normal file
15
modules/analytic_purchase/locale/fa.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "اندازه تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "تحلیلی"
|
||||
15
modules/analytic_purchase/locale/fi.po
Normal file
15
modules/analytic_purchase/locale/fi.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/fr.po
Normal file
15
modules/analytic_purchase/locale/fr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analytiques"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Taille des comptes analytiques"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analytique"
|
||||
15
modules/analytic_purchase/locale/hu.po
Normal file
15
modules/analytic_purchase/locale/hu.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/id.po
Normal file
15
modules/analytic_purchase/locale/id.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Akun Analitik"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Ukuran Akun Analitik"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitik"
|
||||
15
modules/analytic_purchase/locale/it.po
Normal file
15
modules/analytic_purchase/locale/it.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "conti analitici"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "dimensione conti analitici"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitico"
|
||||
15
modules/analytic_purchase/locale/lo.po
Normal file
15
modules/analytic_purchase/locale/lo.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "ບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "ຂະໜາດບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/lt.po
Normal file
15
modules/analytic_purchase/locale/lt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/nl.po
Normal file
15
modules/analytic_purchase/locale/nl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analytische rekeningen"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Grootte analyserekeningen"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "analytisch"
|
||||
15
modules/analytic_purchase/locale/pl.po
Normal file
15
modules/analytic_purchase/locale/pl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/pt.po
Normal file
15
modules/analytic_purchase/locale/pt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Contas analíticas"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamanho das contas analíticas"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/ro.po
Normal file
15
modules/analytic_purchase/locale/ro.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Conturi Analitice"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mărimea Conturilor Analitice"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitic"
|
||||
16
modules/analytic_purchase/locale/ru.po
Normal file
16
modules/analytic_purchase/locale/ru.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/sl.po
Normal file
15
modules/analytic_purchase/locale/sl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Stroškovna mesta"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Velikost stroškovnih mest"
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Stroškovno mesto"
|
||||
15
modules/analytic_purchase/locale/tr.po
Normal file
15
modules/analytic_purchase/locale/tr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/uk.po
Normal file
15
modules/analytic_purchase/locale/uk.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_purchase/locale/zh_CN.po
Normal file
15
modules/analytic_purchase/locale/zh_CN.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:purchase.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:purchase.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
72
modules/analytic_purchase/purchase.py
Normal file
72
modules/analytic_purchase/purchase.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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 PurchaseLine(AnalyticMixin, metaclass=PoolMeta):
|
||||
__name__ = 'purchase.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('purchase_state') != 'draft',
|
||||
}
|
||||
|
||||
def get_invoice_line(self):
|
||||
pool = Pool()
|
||||
AnalyticAccountEntry = pool.get('analytic.account.entry')
|
||||
|
||||
invoice_lines = super().get_invoice_line()
|
||||
for invoice_line in invoice_lines:
|
||||
new_entries = AnalyticAccountEntry.copy(self.analytic_accounts,
|
||||
default={
|
||||
'origin': None,
|
||||
})
|
||||
invoice_line.analytic_accounts = new_entries
|
||||
return invoice_lines
|
||||
|
||||
|
||||
class AnalyticAccountEntry(metaclass=PoolMeta):
|
||||
__name__ = 'analytic.account.entry'
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
origins = super()._get_origin()
|
||||
return origins + ['purchase.line']
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_company(self, name=None):
|
||||
pool = Pool()
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
company = super().on_change_with_company(name)
|
||||
if isinstance(self.origin, PurchaseLine) and self.origin.purchase:
|
||||
company = self.origin.purchase.company
|
||||
return company
|
||||
|
||||
@classmethod
|
||||
def search_company(cls, name, clause):
|
||||
domain = super().search_company(name, clause)
|
||||
if domain:
|
||||
domain = ['OR', domain]
|
||||
domain.append(
|
||||
('origin.purchase.' + clause[0],
|
||||
*clause[1:3], 'purchase.line', *clause[3:]))
|
||||
return domain
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_editable(self, name=None):
|
||||
pool = Pool()
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
editable = super().on_change_with_editable(name=name)
|
||||
if isinstance(self.origin, PurchaseLine):
|
||||
if self.origin.purchase_state != 'draft':
|
||||
editable = False
|
||||
return editable
|
||||
12
modules/analytic_purchase/purchase.xml
Normal file
12
modules/analytic_purchase/purchase.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="purchase_line_view_form">
|
||||
<field name="model">purchase.line</field>
|
||||
<field name="inherit" ref="purchase.purchase_line_view_form"/>
|
||||
<field name="name">purchase_line_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
2
modules/analytic_purchase/tests/__init__.py
Normal file
2
modules/analytic_purchase/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.
127
modules/analytic_purchase/tests/scenario_analytic_purchase.rst
Normal file
127
modules/analytic_purchase/tests/scenario_analytic_purchase.rst
Normal file
@@ -0,0 +1,127 @@
|
||||
==========================
|
||||
Analytic Purchase Scenario
|
||||
==========================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> 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 (
|
||||
... 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_purchase', 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 parties::
|
||||
|
||||
>>> 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.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 = 'goods'
|
||||
>>> template.purchasable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Purchase with analytic accounts::
|
||||
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = supplier
|
||||
>>> purchase.payment_term = payment_term
|
||||
>>> purchase.invoice_method = 'order'
|
||||
>>> purchase_line = purchase.lines.new()
|
||||
>>> entry, = purchase_line.analytic_accounts
|
||||
>>> assertEqual(entry.root, root)
|
||||
>>> entry.account = analytic_account
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 5
|
||||
>>> purchase_line.unit_price = Decimal('5.0000')
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.state
|
||||
'processing'
|
||||
|
||||
Check invoice analytic accounts::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(purchase.invoices[0].id)
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> entry, = invoice_line.analytic_accounts
|
||||
>>> assertEqual(entry.account, analytic_account)
|
||||
|
||||
Purchase with an empty analytic account::
|
||||
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = supplier
|
||||
>>> purchase.payment_term = payment_term
|
||||
>>> purchase.invoice_method = 'order'
|
||||
>>> purchase_line = purchase.lines.new()
|
||||
>>> entry, = purchase_line.analytic_accounts
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 5
|
||||
>>> purchase_line.unit_price = Decimal('5.0000')
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.state
|
||||
'processing'
|
||||
|
||||
Check invoice analytic accounts::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(purchase.invoices[0].id)
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> entry, = invoice_line.analytic_accounts
|
||||
>>> entry.account
|
||||
12
modules/analytic_purchase/tests/test_module.py
Normal file
12
modules/analytic_purchase/tests/test_module.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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 AnalyticPurchaseTestCase(ModuleTestCase):
|
||||
'Test AnalyticPurchase module'
|
||||
module = 'analytic_purchase'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/analytic_purchase/tests/test_scenario.py
Normal file
8
modules/analytic_purchase/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)
|
||||
13
modules/analytic_purchase/tryton.cfg
Normal file
13
modules/analytic_purchase/tryton.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[tryton]
|
||||
version=7.8.0
|
||||
depends:
|
||||
analytic_account
|
||||
analytic_invoice
|
||||
purchase
|
||||
xml:
|
||||
purchase.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
purchase.PurchaseLine
|
||||
purchase.AnalyticAccountEntry
|
||||
10
modules/analytic_purchase/view/purchase_line_form.xml
Normal file
10
modules/analytic_purchase/view/purchase_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