first commit
This commit is contained in:
2
modules/analytic_sale/__init__.py
Normal file
2
modules/analytic_sale/__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_sale/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/analytic_sale/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/analytic_sale/__pycache__/sale.cpython-311.pyc
Normal file
BIN
modules/analytic_sale/__pycache__/sale.cpython-311.pyc
Normal file
Binary file not shown.
16
modules/analytic_sale/locale/bg.po
Normal file
16
modules/analytic_sale/locale/bg.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Аналитични сметки"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/ca.po
Normal file
15
modules/analytic_sale/locale/ca.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analítics"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mida dels comptes analítics"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
15
modules/analytic_sale/locale/cs.po
Normal file
15
modules/analytic_sale/locale/cs.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/de.po
Normal file
15
modules/analytic_sale/locale/de.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Kostenstellen"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Kostenstellengröße"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Kostenstelle"
|
||||
15
modules/analytic_sale/locale/es.po
Normal file
15
modules/analytic_sale/locale/es.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Cuentas analíticas"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamaño de cuentas analíticas"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítica"
|
||||
15
modules/analytic_sale/locale/es_419.po
Normal file
15
modules/analytic_sale/locale/es_419.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/et.po
Normal file
15
modules/analytic_sale/locale/et.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analüütilised kontod"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Analüütiliste kontode suurus"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analüütiline"
|
||||
15
modules/analytic_sale/locale/fa.po
Normal file
15
modules/analytic_sale/locale/fa.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "اندازه تجزیه و تحلیل حساب ها"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "تحلیلی"
|
||||
15
modules/analytic_sale/locale/fi.po
Normal file
15
modules/analytic_sale/locale/fi.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/fr.po
Normal file
15
modules/analytic_sale/locale/fr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Comptes analytiques"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Taille des comptes analytiques"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analytique"
|
||||
15
modules/analytic_sale/locale/hu.po
Normal file
15
modules/analytic_sale/locale/hu.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/id.po
Normal file
15
modules/analytic_sale/locale/id.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/it.po
Normal file
15
modules/analytic_sale/locale/it.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "conti analitici"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "dimensione conti analitici"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitico"
|
||||
15
modules/analytic_sale/locale/lo.po
Normal file
15
modules/analytic_sale/locale/lo.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "ບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "ຂະໜາດບັນຊີວິເຄາະ"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/lt.po
Normal file
15
modules/analytic_sale/locale/lt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/nl.po
Normal file
15
modules/analytic_sale/locale/nl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Analytische rekeningen"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Grootte analyserekeningen"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "analytisch"
|
||||
15
modules/analytic_sale/locale/pl.po
Normal file
15
modules/analytic_sale/locale/pl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/pt.po
Normal file
15
modules/analytic_sale/locale/pt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Contas Analíticas"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Tamanho da Conta Analítica"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analítico"
|
||||
15
modules/analytic_sale/locale/ro.po
Normal file
15
modules/analytic_sale/locale/ro.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Conturi Analitice"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Mărimea Conturilor Analitice"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Analitic"
|
||||
16
modules/analytic_sale/locale/ru.po
Normal file
16
modules/analytic_sale/locale/ru.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Счета аналитики"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/sl.po
Normal file
15
modules/analytic_sale/locale/sl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr "Stroškovna mesta"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr "Velikost stroškovnih mest"
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr "Stroškovno mesto"
|
||||
15
modules/analytic_sale/locale/tr.po
Normal file
15
modules/analytic_sale/locale/tr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/uk.po
Normal file
15
modules/analytic_sale/locale/uk.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
15
modules/analytic_sale/locale/zh_CN.po
Normal file
15
modules/analytic_sale/locale/zh_CN.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts:"
|
||||
msgid "Analytic Accounts"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:sale.line,analytic_accounts_size:"
|
||||
msgid "Analytic Accounts Size"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "view:sale.line:"
|
||||
msgid "Analytic"
|
||||
msgstr ""
|
||||
71
modules/analytic_sale/sale.py
Normal file
71
modules/analytic_sale/sale.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# 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 Line(AnalyticMixin, metaclass=PoolMeta):
|
||||
__name__ = 'sale.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('sale_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 + ['sale.line']
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_company(self, name=None):
|
||||
pool = Pool()
|
||||
SaleLine = pool.get('sale.line')
|
||||
company = super().on_change_with_company(name)
|
||||
if isinstance(self.origin, SaleLine) and self.origin.sale:
|
||||
company = self.origin.sale.company
|
||||
return company
|
||||
|
||||
@classmethod
|
||||
def search_company(cls, name, clause):
|
||||
domain = super().search_company(name, clause),
|
||||
if domain:
|
||||
domain = ['OR', domain]
|
||||
domain.append(('origin.sale.' + clause[0],
|
||||
*clause[1:3], 'sale.line', *clause[3:]))
|
||||
return domain
|
||||
|
||||
@fields.depends('origin')
|
||||
def on_change_with_editable(self, name=None):
|
||||
pool = Pool()
|
||||
SaleLine = pool.get('sale.line')
|
||||
editable = super().on_change_with_editable(name=name)
|
||||
if isinstance(self.origin, SaleLine):
|
||||
if self.origin.sale_state != 'draft':
|
||||
editable = False
|
||||
return editable
|
||||
12
modules/analytic_sale/sale.xml
Normal file
12
modules/analytic_sale/sale.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="sale_line_view_form">
|
||||
<field name="model">sale.line</field>
|
||||
<field name="inherit" ref="sale.sale_line_view_form"/>
|
||||
<field name="name">sale_line_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
2
modules/analytic_sale/tests/__init__.py
Normal file
2
modules/analytic_sale/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.
|
||||
BIN
modules/analytic_sale/tests/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/analytic_sale/tests/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
137
modules/analytic_sale/tests/scenario_analytic_sale.rst
Normal file
137
modules/analytic_sale/tests/scenario_analytic_sale.rst
Normal file
@@ -0,0 +1,137 @@
|
||||
======================
|
||||
Analytic Sale 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_sale', 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')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.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.salable = 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()
|
||||
|
||||
Sale with analytic accounts::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> SaleLine = Model.get('sale.line')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> entry, = sale_line.analytic_accounts
|
||||
>>> assertEqual(entry.root, root)
|
||||
>>> entry.account = analytic_account
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 5
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Check analytic accounts on invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(sale.invoices[0].id)
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> entry, = invoice_line.analytic_accounts
|
||||
>>> assertEqual(entry.account, analytic_account)
|
||||
|
||||
Sale with an empty analytic account::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> SaleLine = Model.get('sale.line')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> entry, = sale_line.analytic_accounts
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 5
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
>>> invoice, = sale.invoices
|
||||
|
||||
Check invoice analytic accounts::
|
||||
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> entry, = invoice_line.analytic_accounts
|
||||
>>> entry.account
|
||||
|
||||
Return sales using the wizard::
|
||||
|
||||
>>> return_sale = Wizard('sale.return_sale', [sale])
|
||||
>>> return_sale.execute('return_')
|
||||
>>> returned_sale, = Sale.find([
|
||||
... ('state', '=', 'draft'),
|
||||
... ])
|
||||
>>> sale_line, = returned_sale.lines
|
||||
>>> entry, = sale_line.analytic_accounts
|
||||
>>> entry.account
|
||||
12
modules/analytic_sale/tests/test_module.py
Normal file
12
modules/analytic_sale/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 AnalyticSaleTestCase(ModuleTestCase):
|
||||
'Test AnalyticSale module'
|
||||
module = 'analytic_sale'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/analytic_sale/tests/test_scenario.py
Normal file
8
modules/analytic_sale/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_sale/tryton.cfg
Normal file
13
modules/analytic_sale/tryton.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[tryton]
|
||||
version=7.8.0
|
||||
depends:
|
||||
analytic_account
|
||||
analytic_invoice
|
||||
sale
|
||||
xml:
|
||||
sale.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
sale.Line
|
||||
sale.AnalyticAccountEntry
|
||||
10
modules/analytic_sale/view/sale_line_form.xml
Normal file
10
modules/analytic_sale/view/sale_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