Merge account kind and account type
issue4990 review68401002
This commit is contained in:
1 parent
6fb340f7cc
commit
97828a5e6b
20 files changed
+529
-16
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Add unearned revenue on account type
|
||||
|
||||
Version 5.0.0 - 2018-10-01
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Remove support for Python 2.7
|
||||
|
||||
@@ -15,6 +15,8 @@ def register():
|
||||
sale.AdvancePaymentCondition,
|
||||
sale.Sale,
|
||||
sale.SaleLine,
|
||||
account.AccountTypeTemplate,
|
||||
account.AccountType,
|
||||
account.Invoice,
|
||||
account.InvoiceLine,
|
||||
stock.ShipmentOut,
|
||||
|
||||
+46
-1
@@ -1,9 +1,47 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import If, Eval, Bool
|
||||
|
||||
__all__ = ['Invoice', 'InvoiceLine']
|
||||
|
||||
def AccountTypeMixin(template=False):
|
||||
|
||||
class Mixin:
|
||||
unearned_revenue = fields.Boolean(
|
||||
"Unearned Revenue",
|
||||
domain=[
|
||||
If(Eval('statement') != 'balance',
|
||||
('unearned_revenue', '=', False), ()),
|
||||
],
|
||||
states={
|
||||
'invisible': ((Eval('statement') != 'balance')
|
||||
| Eval('assets', True)),
|
||||
},
|
||||
depends=['statement', 'assets'])
|
||||
if not template:
|
||||
for fname in dir(Mixin):
|
||||
field = getattr(Mixin, fname)
|
||||
if not isinstance(field, fields.Field):
|
||||
continue
|
||||
field.states['readonly'] = (
|
||||
Bool(Eval('template', -1)) & ~Eval('template_override', False))
|
||||
return Mixin
|
||||
|
||||
|
||||
class AccountTypeTemplate(AccountTypeMixin(template=True), metaclass=PoolMeta):
|
||||
__name__ = 'account.account.type.template'
|
||||
|
||||
def _get_type_value(self, type=None):
|
||||
values = super()._get_type_value(type=type)
|
||||
if not type or type.unearned_revenue != self.unearned_revenue:
|
||||
values['unearned_revenue'] = self.unearned_revenue
|
||||
return values
|
||||
|
||||
|
||||
class AccountType(AccountTypeMixin(), metaclass=PoolMeta):
|
||||
__name__ = 'account.account.type'
|
||||
|
||||
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
@@ -23,6 +61,13 @@ class Invoice(metaclass=PoolMeta):
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@classmethod
|
||||
def _account_domain(cls, type_):
|
||||
domain = super()._account_domain(type_)
|
||||
if type_ == 'out':
|
||||
domain.append(('type.unearned_revenue', '=', True))
|
||||
return domain
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return (super(InvoiceLine, cls)._get_origin()
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?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="account_type_template_view_form">
|
||||
<field name="model">account.account.type.template</field>
|
||||
<field name="inherit" ref="account.account_type_template_view_form"/>
|
||||
<field name="name">account_type_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="account_type_view_form">
|
||||
<field name="model">account.account.type</field>
|
||||
<field name="inherit" ref="account.account_type_view_form"/>
|
||||
<field name="name">account_type_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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="account.account.type.template" id="account_type_template_unearned_revenue">
|
||||
<field name="name" lang="en">Unearned Revenue</field>
|
||||
<field name="name" lang="bg">Неотработен доход</field>
|
||||
<field name="name" lang="ca">Ingressos no consumits</field>
|
||||
<field name="name" lang="de">Nicht verdiente Einnahmen</field>
|
||||
<field name="name" lang="es">Ingresos no ganados</field>
|
||||
<field name="name" lang="fr">Produits constatés d'avance</field>
|
||||
<field name="name" lang="nl">Onverdiende inkomsten</field>
|
||||
<field name="name" lang="pt">Receita não recebida</field>
|
||||
<field name="name" lang="ru">Нетрудовые доходы</field>
|
||||
<field name="name" lang="sl">Nezasluženi prihodki</field>
|
||||
<field name="parent" ref="account.account_type_template_liability_current"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record model="account.account.template" id="account_template_advance_payment">
|
||||
<field name="name" lang="en">Advance Payment</field>
|
||||
<field name="name" lang="bg">Авансово плащане</field>
|
||||
<field name="name" lang="ca">Pagament avançat</field>
|
||||
<field name="name" lang="de">Vorauszahlung</field>
|
||||
<field name="name" lang="es">Pago por adelantado</field>
|
||||
<field name="name" lang="fr">Acompte</field>
|
||||
<field name="name" lang="nl">Vooruitbetaling</field>
|
||||
<field name="name" lang="pt">Pagamento adiantado</field>
|
||||
<field name="name" lang="ru">Предоплата</field>
|
||||
<field name="name" lang="sl">Plačilo vnaprej</field>
|
||||
<field name="type" ref="account_type_template_unearned_revenue"/>
|
||||
<field name="parent" ref="account.account_template_root"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_bg" model="account.account.type.template">
|
||||
|
||||
<field name="name">Неотработен доход</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_bg"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_bg" model="account.account.template">
|
||||
|
||||
<field name="name">Авансово плащане</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_bg"/>
|
||||
<field name="parent" ref="account.account_template_root_bg"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_ca" model="account.account.type.template">
|
||||
|
||||
|
||||
<field name="name">Ingressos no consumits</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_ca"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_ca" model="account.account.template">
|
||||
|
||||
|
||||
<field name="name">Pagament avançat</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_ca"/>
|
||||
<field name="parent" ref="account.account_template_root_ca"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_de" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
<field name="name">Nicht verdiente Einnahmen</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_de"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_de" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
<field name="name">Vorauszahlung</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_de"/>
|
||||
<field name="parent" ref="account.account_template_root_de"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_en" model="account.account.type.template">
|
||||
<field name="name">Unearned Revenue</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_en"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_en" model="account.account.template">
|
||||
<field name="name">Advance Payment</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_en"/>
|
||||
<field name="parent" ref="account.account_template_root_en"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_es" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Ingresos no ganados</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_es"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_es" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Pago por adelantado</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_es"/>
|
||||
<field name="parent" ref="account.account_template_root_es"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_fr" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Produits constatés d'avance</field>
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_fr"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_fr" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Acompte</field>
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_fr"/>
|
||||
<field name="parent" ref="account.account_template_root_fr"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_nl" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Onverdiende inkomsten</field>
|
||||
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_nl"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_nl" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Vooruitbetaling</field>
|
||||
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_nl"/>
|
||||
<field name="parent" ref="account.account_template_root_nl"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_pt" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Receita não recebida</field>
|
||||
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_pt"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_pt" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Pagamento adiantado</field>
|
||||
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_pt"/>
|
||||
<field name="parent" ref="account.account_template_root_pt"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_ru" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Нетрудовые доходы</field>
|
||||
|
||||
<field name="parent" ref="account.account_type_template_liability_current_ru"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_ru" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Предоплата</field>
|
||||
|
||||
<field name="type" ref="account_type_template_unearned_revenue_ru"/>
|
||||
<field name="parent" ref="account.account_template_root_ru"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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 id="account_type_template_unearned_revenue_sl" model="account.account.type.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Nezasluženi prihodki</field>
|
||||
<field name="parent" ref="account.account_type_template_liability_current_sl"/>
|
||||
<field name="statement">balance</field>
|
||||
<field name="unearned_revenue" eval="True"/>
|
||||
<field name="sequence" eval="30"/>
|
||||
</record>
|
||||
|
||||
<record id="account_template_advance_payment_sl" model="account.account.template">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="name">Plačilo vnaprej</field>
|
||||
<field name="type" ref="account_type_template_unearned_revenue_sl"/>
|
||||
<field name="parent" ref="account.account_template_root_sl"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -61,7 +61,7 @@ class AdvancePaymentTermLine(ModelView, ModelSQL, CompanyMultiValueMixin):
|
||||
account = fields.MultiValue(
|
||||
fields.Many2One('account.account', "Account", required=True,
|
||||
domain=[
|
||||
('kind', '=', 'revenue'),
|
||||
('type.unearned_revenue', '=', True),
|
||||
],
|
||||
help="Used for the line of advance payment invoice."))
|
||||
accounts = fields.One2Many(
|
||||
@@ -132,6 +132,7 @@ class AdvancePaymentTermLineAccount(ModelSQL, CompanyValueMixin):
|
||||
account = fields.Many2One(
|
||||
'account.account', "Account", required=True,
|
||||
domain=[
|
||||
('type.unearned_revenue', '=', True),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
@@ -163,7 +164,7 @@ class AdvancePaymentCondition(ModelSQL, ModelView):
|
||||
account = fields.Many2One(
|
||||
'account.account', "Account", required=True,
|
||||
domain=[
|
||||
('kind', '=', 'revenue'),
|
||||
('type.unearned_revenue', '=', True),
|
||||
('company', '=', Eval('sale_company')),
|
||||
],
|
||||
states=_states,
|
||||
|
||||
@@ -16,7 +16,7 @@ Imports::
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences, create_payment_term
|
||||
>>> from trytond.modules.sale_advance_payment.tests.tools import \
|
||||
... create_advance_payment_term
|
||||
... create_advance_payment_term, add_advance_payment_accounts
|
||||
>>> today = datetime.date.today()
|
||||
|
||||
Activate sale_advance_payment::
|
||||
@@ -40,21 +40,11 @@ Create fiscal years::
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart(company)
|
||||
>>> accounts = get_accounts(company)
|
||||
>>> accounts = add_advance_payment_accounts(get_accounts(company))
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> payable = accounts['payable']
|
||||
>>> cash = accounts['cash']
|
||||
|
||||
>>> Account = Model.get('account.account')
|
||||
>>> advance_payment_account = Account(
|
||||
... name='Advance Payment',
|
||||
... type=payable.type,
|
||||
... kind='revenue',
|
||||
... company=company,
|
||||
... party_required=True,
|
||||
... reconcile=True,
|
||||
... )
|
||||
>>> advance_payment_account.save()
|
||||
>>> advance_payment_account = accounts['advance_payment']
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> PaymentMethod = Model.get('account.invoice.payment.method')
|
||||
|
||||
@@ -4,6 +4,8 @@ from datetime import timedelta
|
||||
|
||||
from proteus import Model
|
||||
|
||||
from trytond.modules.company.tests.tools import get_company
|
||||
|
||||
|
||||
def create_advance_payment_term(
|
||||
name, formula, account, block_supply=False, block_shipping=False,
|
||||
@@ -21,3 +23,17 @@ def create_advance_payment_term(
|
||||
line.formula = formula
|
||||
line.invoice_delay = timedelta(days=delay)
|
||||
return advance_payment_term
|
||||
|
||||
|
||||
def add_advance_payment_accounts(accounts, company=None, config=None):
|
||||
"Add advance payment to accounts"
|
||||
Account = Model.get('account.account', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company()
|
||||
|
||||
accounts['advance_payment'], = Account.find([
|
||||
('type.unearned_revenue', '=', True),
|
||||
('company', '=', company.id),
|
||||
], limit=1)
|
||||
return accounts
|
||||
+12
@@ -1,6 +1,7 @@
|
||||
[tryton]
|
||||
version=5.1.0
|
||||
depends:
|
||||
account
|
||||
account_invoice
|
||||
ir
|
||||
res
|
||||
@@ -9,4 +10,15 @@ extras_depend:
|
||||
sale_supply
|
||||
xml:
|
||||
sale.xml
|
||||
account.xml
|
||||
minimal_chart_bg.xml
|
||||
minimal_chart_ca.xml
|
||||
minimal_chart_de.xml
|
||||
minimal_chart_en.xml
|
||||
minimal_chart_es.xml
|
||||
minimal_chart_fr.xml
|
||||
minimal_chart_nl.xml
|
||||
minimal_chart_pt.xml
|
||||
minimal_chart_ru.xml
|
||||
minimal_chart_sl.xml
|
||||
message.xml
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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="//group[@id='checkboxes']" position="inside">
|
||||
<label name="unearned_revenue"/>
|
||||
<field name="unearned_revenue"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in new issue
Block a user