Add General Journal
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
|
||||
from trytond.osv import fields, OSV, ExceptORM
|
||||
from trytond.wizard import Wizard, WizardOSV
|
||||
from trytond.report import Report
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
from trytond.netsvc import LocalService
|
||||
@@ -1527,3 +1528,97 @@ class Partner(OSV):
|
||||
return [('id', 'in', [x[0] for x in cursor.fetchall()])]
|
||||
|
||||
Partner()
|
||||
|
||||
|
||||
class PrintGeneralJournalInit(WizardOSV):
|
||||
_name = 'account.move.print_general_journal.init'
|
||||
from_date = fields.Date('From Date', required=True)
|
||||
to_date = fields.Date('To Date', required=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
posted = fields.Boolean('Posted Move', help='Only posted move')
|
||||
|
||||
def default_from_date(self, cursor, user, context=None):
|
||||
return datetime.datetime(datetime.datetime.today().year, 1, 1)
|
||||
|
||||
def default_to_date(self, cursor, user, context=None):
|
||||
return datetime.datetime.today()
|
||||
|
||||
def default_company(self, cursor, user, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
company_obj = self.pool.get('company.company')
|
||||
if context.get('company'):
|
||||
return company_obj.name_get(cursor, user, context['company'],
|
||||
context=context)[0]
|
||||
return False
|
||||
|
||||
def default_posted(self, cursor, user, context=None):
|
||||
return False
|
||||
|
||||
PrintGeneralJournalInit()
|
||||
|
||||
|
||||
class PrintGeneralJournal(Wizard):
|
||||
'Print General Journal'
|
||||
_name = 'account.move.print_general_journal'
|
||||
states = {
|
||||
'init': {
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'object': 'account.move.print_general_journal.init',
|
||||
'state': [
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('print', 'Print', 'gtk-print', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'print': {
|
||||
'result': {
|
||||
'type': 'print',
|
||||
'report': 'account.move.general_journal',
|
||||
'state': 'end',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
PrintGeneralJournal()
|
||||
|
||||
|
||||
class GeneralJournal(Report):
|
||||
_name = 'account.move.general_journal'
|
||||
|
||||
def _get_objects(self, cursor, user, ids, model, datas, context):
|
||||
move_obj = self.pool.get('account.move')
|
||||
|
||||
if datas['form']['posted']:
|
||||
move_ids = move_obj.search(cursor, user, [
|
||||
('post_date', '>=', datas['form']['from_date']),
|
||||
('post_date', '<=', datas['form']['to_date']),
|
||||
('state', '=', 'posted'),
|
||||
], order='post_date, reference, id', context=context)
|
||||
else:
|
||||
move_ids = move_obj.search(cursor, user, [
|
||||
('date', '>=', datas['form']['from_date']),
|
||||
('date', '<=', datas['form']['to_date']),
|
||||
], order='COALESCE(post_date, date), reference, id',
|
||||
context=context)
|
||||
return move_obj.browse(cursor, user, move_ids, context=context)
|
||||
|
||||
def parse(self, cursor, user, content, objects, datas, context):
|
||||
if context is None:
|
||||
context = {}
|
||||
company_obj = self.pool.get('company.company')
|
||||
context = context.copy()
|
||||
|
||||
company = company_obj.browse(cursor, user,
|
||||
datas['form']['company'], context=context)
|
||||
|
||||
context['company'] = company
|
||||
context['digits'] = company.currency.digits
|
||||
context['from_date'] = datas['form']['from_date']
|
||||
context['to_date'] = datas['form']['to_date']
|
||||
|
||||
return super(GeneralJournal, self).parse(cursor, user, content,
|
||||
objects, datas, context)
|
||||
|
||||
GeneralJournal()
|
||||
|
||||
@@ -375,5 +375,38 @@
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="print_general_journal_init_view_form">
|
||||
<field name="model">account.move.print_general_journal.init</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Print General Journal">
|
||||
<label name="from_date"/>
|
||||
<field name="from_date"/>
|
||||
<label name="to_date"/>
|
||||
<field name="to_date"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="posted"/>
|
||||
<field name="posted"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_print_general_journal">
|
||||
<field name="name">Print General Journal</field>
|
||||
<field name="wiz_name">account.move.print_general_journal</field>
|
||||
</record>
|
||||
<menuitem parent="menu_reporting" action="wizard_print_general_journal"
|
||||
id="menu_print_general_journal" icon="STOCK_PRINT"/>
|
||||
|
||||
<record model="ir.action.report" id="report_general_journal">
|
||||
<field name="name">General Journal</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="report_name">account.move.general_journal</field>
|
||||
<field name="report">account/general_journal.odt</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
Reference in New Issue
Block a user