Support EC sales list and add VAT customer

issue6735
review39641002
This commit is contained in:
Cédric Krier
2017-09-28 09:17:26 +02:00
parent fc0ad65926
commit 21e5339e1d
12 changed files with 191 additions and 3 deletions
+3
View File
@@ -1,3 +1,6 @@
* Add VAT customer list
* Add support for EC Sales List
Version 4.4.0 - 2017-05-01
* Bug fixes (see mercurial logs for details)
+1
View File
@@ -5,4 +5,5 @@ include CHANGELOG
include LICENSE
include tryton.cfg
include *.xml
include view/*.xml
include locale/*.po
+4 -2
View File
@@ -2,10 +2,12 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .account import *
from . import account
def register():
Pool.register(
AccountTemplate,
account.AccountTemplate,
account.BEVATCustomer,
account.BEVATCustomerContext,
module='account_be', type_='model')
+122
View File
@@ -1,9 +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 sql import Literal
from sql.aggregate import Max, Min, Sum
from sql.operators import Concat
from sql.functions import Position
from trytond.model import ModelSQL, ModelView, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['AccountTemplate']
@@ -32,3 +36,121 @@ class AccountTemplate:
& (model_data.module == 'account_be'))))
super(AccountTemplate, cls).__register__(module_name)
class BEVATCustomer(ModelSQL, ModelView):
"Belgium VAT Customer"
__name__ = 'account.be.vat_customer'
company_tax_identifier = fields.Many2One(
'party.identifier', "Company Tax Identifier")
party_tax_identifier = fields.Many2One(
'party.identifier', "Party Tax Identifier")
turnover = fields.Numeric(
"Turnover", digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'])
vat = fields.Numeric(
"VAT", digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'])
currency = fields.Many2One('currency.currency', "Currency")
currency_digits = fields.Function(
fields.Integer("Currency Digits"), 'get_currency_digits')
def get_currency_digits(self, name):
return self.currency.digits
@classmethod
def tax_groups(cls):
for group in ['group_tva_vente_biens', 'group_tva_vente_services',
'tva_vente_biens_coco', 'tva_vente_services_coco']:
for lang in ['fr', 'nl']:
yield 'account_be', '%s_%s' % (group, lang)
@classmethod
def table_query(cls):
pool = Pool()
Identifier = pool.get('party.identifier')
Invoice = pool.get('account.invoice')
InvoiceTax = pool.get('account.invoice.tax')
ModelData = pool.get('ir.model.data')
Move = pool.get('account.move')
Period = pool.get('account.period')
Tax = pool.get('account.tax')
context = Transaction().context
company_identifier = Identifier.__table__()
party_identifier = Identifier.__table__()
invoice = Invoice.__table__()
invoice_tax = InvoiceTax.__table__()
move = Move.__table__()
period = Period.__table__()
tax = Tax.__table__()
groups = []
for module, fs_id in cls.tax_groups():
try:
groups.append(ModelData.get_id(module, fs_id))
except KeyError:
# table_query can be called before the XML is loaded
continue
where = ((invoice.company == context.get('company'))
& (period.fiscalyear == context.get('fiscalyear')))
where &= invoice.type == 'out'
where &= (company_identifier.code.ilike('BE%')
& (company_identifier.type == 'eu_vat'))
where &= (party_identifier.code.ilike('BE%')
& (party_identifier.type == 'eu_vat'))
where &= tax.group.in_(groups)
return (invoice_tax
.join(invoice,
condition=invoice_tax.invoice == invoice.id)
.join(tax, condition=invoice_tax.tax == tax.id)
.join(move, condition=invoice.move == move.id)
.join(period, condition=move.period == period.id)
.join(company_identifier,
condition=invoice.tax_identifier == company_identifier.id)
.join(party_identifier,
condition=invoice.party_tax_identifier == party_identifier.id)
.select(
Max(invoice_tax.id).as_('id'),
Literal(0).as_('create_uid'),
Min(invoice_tax.create_date).as_('create_date'),
Literal(0).as_('write_uid'),
Max(invoice_tax.write_date).as_('write_date'),
invoice.tax_identifier.as_('company_tax_identifier'),
invoice.party_tax_identifier.as_('party_tax_identifier'),
Sum(invoice_tax.base).as_('turnover'),
Sum(invoice_tax.amount).as_('vat'),
invoice.currency.as_('currency'),
where=where,
group_by=[
invoice.tax_identifier,
invoice.party_tax_identifier,
invoice.currency,
]))
class BEVATCustomerContext(ModelView):
"Belgium VAT Customer Context"
__name__ = 'account.be.vat_customer.context'
company = fields.Many2One('company.company', "Company", required=True)
fiscalyear = fields.Many2One(
'account.fiscalyear', "Fiscal Year", required=True,
domain=[
('company', '=', Eval('company')),
],
depends=['company'])
@classmethod
def default_company(cls):
return Transaction().context.get('company')
@classmethod
def default_fiscalyear(cls):
pool = Pool()
FiscalYear = pool.get('account.fiscalyear')
context = Transaction().context
return context.get(
'fiscalyear',
FiscalYear.find(context.get('company'), exception=False))
+33
View File
@@ -0,0 +1,33 @@
<?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="vat_customer_view_list">
<field name="model">account.be.vat_customer</field>
<field name="type">tree</field>
<field name="name">vat_customer_list</field>
</record>
<record model="ir.action.act_window" id="act_vat_customer_form">
<field name="name">Belgium VAT Customer</field>
<field name="res_model">account.be.vat_customer</field>
<field name="context_model">account.be.vat_customer.context</field>
</record>
<record model="ir.action.act_window.view"
id="act_vat_customer_form_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="vat_customer_view_list"/>
<field name="act_window" ref="act_vat_customer_form"/>
</record>
<menuitem parent="account.menu_reporting"
action="act_vat_customer_form" id="menu_vat_customer"/>
<record model="ir.ui.view" id="vat_customer_context_view_form">
<field name="model">account.be.vat_customer.context</field>
<field name="type">form</field>
<field name="name">vat_customer_context_form</field>
</record>
</data>
</tryton>
+1 -1
View File
@@ -69,7 +69,7 @@ setup(name=name,
],
package_data={
'trytond.modules.account_be': (info.get('xml', [])
+ ['tryton.cfg']),
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po']),
},
classifiers=[
'Development Status :: 5 - Production/Stable',
+2
View File
@@ -363,6 +363,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451"/>
<field name="invoice_base_code" ref="tax_code_II_D_46"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48"/>
<field name="ec_sales_list_code">L</field>
<field name="account" ref="root"/>
</record>
@@ -467,6 +468,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451"/>
<field name="invoice_base_code" ref="tax_code_II_44"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48"/>
<field name="ec_sales_list_code">S</field>
<field name="account" ref="root"/>
</record>
+2
View File
@@ -363,6 +363,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451_fr"/>
<field name="invoice_base_code" ref="tax_code_II_D_46_fr"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48_fr"/>
<field name="ec_sales_list_code">L</field>
<field name="account" ref="root_fr"/>
</record>
@@ -467,6 +468,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451_fr"/>
<field name="invoice_base_code" ref="tax_code_II_44_fr"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48_fr"/>
<field name="ec_sales_list_code">S</field>
<field name="account" ref="root_fr"/>
</record>
+2
View File
@@ -363,6 +363,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451_nl"/>
<field name="invoice_base_code" ref="tax_code_II_D_46_nl"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48_nl"/>
<field name="ec_sales_list_code">L</field>
<field name="account" ref="root_nl"/>
</record>
@@ -467,6 +468,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="credit_note_account" ref="451_nl"/>
<field name="invoice_base_code" ref="tax_code_II_44_nl"/>
<field name="credit_note_base_code" ref="tax_code_II_F_48_nl"/>
<field name="ec_sales_list_code">S</field>
<field name="account" ref="root_nl"/>
</record>
+2
View File
@@ -2,7 +2,9 @@
version=4.5.0
depends:
account
account_eu
xml:
account.xml
account_be_fr.xml
tax_be_fr.xml
account_be_nl.xml
+9
View File
@@ -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. -->
<form>
<label name="company"/>
<field name="company"/>
<label name="fiscalyear"/>
<field name="fiscalyear"/>
</form>
+10
View 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. -->
<tree>
<field name="company_tax_identifier" tree_invisible="1"/>
<field name="party_tax_identifier"/>
<field name="turnover"/>
<field name="vat"/>
<field name="currency"/>
</tree>