Allow to set default category and product accounts on configuration wizard

issue6497
review34951004
This commit is contained in:
Xavier Codinas
2017-09-20 17:54:28 +02:00
parent a9bb2c677c
commit a3b8760657
6 changed files with 98 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Allow to set default category and product accounts on configuration wizard
* Replace MissingFunction with properties
Version 4.4.0 - 2017-05-01
+5
View File
@@ -4,6 +4,7 @@
from trytond.pool import Pool
from .product import *
from .configuration import *
from . import account
def register():
@@ -13,6 +14,7 @@ def register():
CategoryAccount,
CategoryCustomerTax,
CategorySupplierTax,
account.CreateChartProperties,
Template,
TemplateAccount,
TemplateCustomerTax,
@@ -21,3 +23,6 @@ def register():
Configuration,
ConfigurationDefaultAccount,
module='account_product', type_='model')
Pool.register(
account.CreateChart,
module='account_product', type_='wizard')
+61
View File
@@ -0,0 +1,61 @@
# 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.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.model import fields
from trytond.transaction import Transaction
__all__ = ['CreateChart', 'CreateChartProperties']
class CreateChartProperties:
__metaclass__ = PoolMeta
__name__ = 'account.create_chart.properties'
product_account_expense = fields.Many2One(
'account.account', 'Default Expense Account',
domain=[
('kind', '=', 'expense'),
('company', '=', Eval('company')),
],
depends=['company'])
product_account_revenue = fields.Many2One(
'account.account', 'Default Revenue Account',
domain=[
('kind', '=', 'revenue'),
('company', '=', Eval('company')),
],
depends=['company'])
category_account_expense = fields.Many2One(
'account.account', 'Default Expense Account',
domain=[
('kind', '=', 'expense'),
('company', '=', Eval('company')),
],
depends=['company'])
category_account_revenue = fields.Many2One(
'account.account', 'Default Revenue Account',
domain=[
('kind', '=', 'revenue'),
('company', '=', Eval('company')),
],
depends=['company'])
class CreateChart:
__metaclass__ = PoolMeta
__name__ = 'account.create_chart'
def transition_create_properties(self):
pool = Pool()
Configuration = pool.get('account.configuration')
state = super(CreateChart, self).transition_create_properties()
with Transaction().set_context(company=self.properties.company.id):
config = Configuration(1)
for name in ['product_account_expense', 'product_account_revenue',
'category_account_expense', 'category_account_revenue']:
setattr(config, 'default_%s' % name,
getattr(self.properties, name))
config.save()
return state
+13
View File
@@ -0,0 +1,13 @@
<?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="create_chart_properties_view_form">
<field name="model">account.create_chart.properties</field>
<field name="inherit"
ref="account.create_chart_properties_view_form"/>
<field name="name">create_chart_properties_form</field>
</record>
</data>
</tryton>
+1
View File
@@ -8,3 +8,4 @@ depends:
xml:
product.xml
configuration.xml
account.xml
+17
View File
@@ -0,0 +1,17 @@
<?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/field[@name='account_payable']" position="after">
<separator id="product" string="Product" colspan="4"/>
<label name="product_account_revenue"/>
<field name="product_account_revenue"/>
<label name="product_account_expense"/>
<field name="product_account_expense"/>
<separator id="category" string="Category" colspan="4"/>
<label name="category_account_revenue"/>
<field name="category_account_revenue"/>
<label name="category_account_expense"/>
<field name="category_account_expense"/>
</xpath>
</data>