[ADD] stock: Task id :596 Postgres view of stock moves with filters & groups
bzr revid: mso@mso-20100423053435-vxut3668xvwn75pz
This commit is contained in:
@@ -70,6 +70,8 @@ module named account_voucherss
|
||||
'wizard/account_pay_invoice_view.xml',
|
||||
'wizard/account_unreconcile_view.xml',
|
||||
'wizard/account_invoice_state_view.xml',
|
||||
'wizard/account_use_model_view.xml',
|
||||
'wizard/account_partner_balance_report_view.xml',
|
||||
'project/wizard/project_account_analytic_line_view.xml',
|
||||
'account_view.xml',
|
||||
'account_end_fy.xml',
|
||||
|
||||
@@ -1176,7 +1176,7 @@
|
||||
<separator string="Legend" colspan="4"/>
|
||||
<field name="legend" colspan="4" nolabel="1"/>
|
||||
<group col="1" colspan="4">
|
||||
<button name="%(wizard_account_use_model)d" string="Create entries" type="action" icon="gtk-execute"/>
|
||||
<button name="%(action_account_use_model_create_entry)d" string="Create entries" type="action" icon="gtk-execute"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_aged_trial_balance" id="menu_aged_trial_balance" parent="next_id_22" type="wizard"/>
|
||||
|
||||
<!-- report-related wizards -->
|
||||
<wizard id="wizard_partner_balance_report" menu="False" model="res.partner" name="account.partner.balance.report" string="Partner Balance"/>
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_partner_balance_report" id="menu_partner_balance" parent="account.next_id_22" type="wizard"/>
|
||||
<!-- <wizard id="wizard_partner_balance_report" menu="False" model="res.partner" name="account.partner.balance.report" string="Partner Balance"/>
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_partner_balance_report" id="menu_partner_balance" parent="account.next_id_22" type="wizard"/> -->
|
||||
|
||||
<wizard id="wizard_third_party_ledger" menu="False" model="res.partner" name="account.third_party_ledger.report" string="Partner Ledger"/>
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_third_party_ledger" id="menu_third_party_ledger" parent="account.next_id_22" type="wizard"/>
|
||||
@@ -96,10 +96,10 @@
|
||||
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Ledger Postings"/>-->
|
||||
|
||||
<!-- Use Models -->
|
||||
<wizard string="Create Entries From Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
|
||||
<menuitem action="wizard_account_use_model" type="wizard" parent="account.menu_finance_recurrent_entries" id="menu_account_use_model"/>
|
||||
<!-- <wizard string="Create Entries From Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>-->
|
||||
<!-- <menuitem action="wizard_account_use_model" type="wizard" parent="account.menu_finance_recurrent_entries" id="menu_account_use_model"/>-->
|
||||
|
||||
<wizard string="Create Entries From Models" model="account.move.line" name="account_use_models" menu="True" id="wizard_line_account_use_model"/>
|
||||
<!-- <wizard string="Create Entries From Models" model="account.move.line" name="account_use_models" menu="True" id="wizard_line_account_use_model"/>-->
|
||||
|
||||
<!-- account.invoice -->
|
||||
<!-- <wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open" groups="base.group_user"/> -->
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.0\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-08-28 16:01+0000\n"
|
||||
"PO-Revision-Date: 2010-03-24 14:33+0000\n"
|
||||
"Last-Translator: Anders Eriksson (Mobila System) <ae@mobilasystem.se>\n"
|
||||
"PO-Revision-Date: 2010-04-21 15:12+0000\n"
|
||||
"Last-Translator: djn (XCLUDE) <Unknown>\n"
|
||||
"Language-Team: <> <>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-04-17 04:08+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-04-22 03:43+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: account
|
||||
@@ -26,12 +26,6 @@ msgstr "Internt namn"
|
||||
msgid "Account Tax Code"
|
||||
msgstr "Konto, skattekod"
|
||||
|
||||
#. module: account
|
||||
#: model:ir.actions.act_window,name:account.action_invoice_tree9
|
||||
#: model:ir.ui.menu,name:account.menu_action_invoice_tree9
|
||||
msgid "Unpaid Supplier Invoices"
|
||||
msgstr "Obetalda leverantörsfakturor"
|
||||
|
||||
#. module: account
|
||||
#: model:ir.ui.menu,name:account.menu_finance_entries
|
||||
msgid "Entries Encoding"
|
||||
@@ -1593,7 +1587,7 @@ msgstr "Moms"
|
||||
#. module: account
|
||||
#: rml:account.analytic.account.journal:0
|
||||
msgid "Account n°"
|
||||
msgstr ""
|
||||
msgstr "Konto Nr"
|
||||
|
||||
#. module: account
|
||||
#: view:account.tax:0
|
||||
|
||||
@@ -67,10 +67,10 @@ class partner_balance(report_sxw.rml_parse):
|
||||
## Get All Period Date
|
||||
#
|
||||
# If we have no period we will take all perdio in the FiscalYear.
|
||||
if not data['form']['periods'][0][2] :
|
||||
if not data['form']['periods']:
|
||||
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
else:
|
||||
periods_id = data['form']['periods'][0][2]
|
||||
periods_id = data['form']['periods']
|
||||
date_array = []
|
||||
for period_id in periods_id:
|
||||
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
|
||||
@@ -85,35 +85,38 @@ class partner_balance(report_sxw.rml_parse):
|
||||
self.date_lst.sort()
|
||||
|
||||
def transform_both_into_date_array(self,data):
|
||||
if not data['form']['periods'][0][2] :
|
||||
final_date_array = []
|
||||
date_start_date = data['form']['date1']
|
||||
date_stop_date = data['form']['date2']
|
||||
if not data['form']['periods']:
|
||||
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
else:
|
||||
periods_id = data['form']['periods'][0][2]
|
||||
periods_id = data['form']['periods']
|
||||
date_array = []
|
||||
for period_id in periods_id:
|
||||
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
|
||||
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
|
||||
if periods_id:
|
||||
for period_id in periods_id:
|
||||
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
|
||||
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
|
||||
period_start_date = date_array[0]
|
||||
period_stop_date = date_array[-1]
|
||||
|
||||
period_start_date = date_array[0]
|
||||
date_start_date = data['form']['date1']
|
||||
period_stop_date = date_array[-1]
|
||||
date_stop_date = data['form']['date2']
|
||||
if period_start_date<date_start_date:
|
||||
start_date = period_start_date
|
||||
else :
|
||||
start_date = date_start_date
|
||||
|
||||
if period_start_date<date_start_date:
|
||||
start_date = period_start_date
|
||||
if date_stop_date<period_stop_date:
|
||||
stop_date = period_stop_date
|
||||
else :
|
||||
stop_date = date_stop_date
|
||||
|
||||
final_date_array = final_date_array + self.date_range(start_date,stop_date)
|
||||
self.date_lst = final_date_array
|
||||
self.date_lst.sort()
|
||||
else :
|
||||
start_date = date_start_date
|
||||
|
||||
if date_stop_date<period_stop_date:
|
||||
stop_date = period_stop_date
|
||||
else :
|
||||
stop_date = date_stop_date
|
||||
|
||||
|
||||
final_date_array = []
|
||||
final_date_array = final_date_array + self.date_range(start_date,stop_date)
|
||||
self.date_lst = final_date_array
|
||||
self.date_lst.sort()
|
||||
final_date_array = final_date_array + self.date_range(date_start_date,date_stop_date)
|
||||
self.date_lst = final_date_array
|
||||
self.date_lst.sort()
|
||||
|
||||
def transform_none_into_date_array(self,data):
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ import account_subscription_generate
|
||||
import wizard_aged_trial_balance
|
||||
import wizard_general_ledger_report
|
||||
import wizard_third_party_ledger
|
||||
import wizard_account_balance_report
|
||||
import wizard_partner_balance_report
|
||||
import account_partner_balance_report
|
||||
import account_period_close
|
||||
import account_fiscalyear_close
|
||||
import account_fiscalyear_close_state
|
||||
@@ -48,7 +47,7 @@ import account_chart
|
||||
import wizard_move_line_select
|
||||
|
||||
import account_validate_account_move
|
||||
import wizard_use_model
|
||||
import account_use_model
|
||||
|
||||
import account_state_open
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from tools.translate import _
|
||||
from osv import fields, osv
|
||||
|
||||
class account_partner_balance(osv.osv_memory):
|
||||
"""
|
||||
This wizard will provide the partner balance report by periods, between any two dates.
|
||||
"""
|
||||
_name = 'account.partner.balance'
|
||||
_description = 'Account Partner Balance'
|
||||
_columns = {
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'state': fields.selection([('bydate','By Date'),
|
||||
('byperiod','By Period'),
|
||||
('all','By Date and Period'),
|
||||
('none','No Filter')
|
||||
],'Date/Period Filter'),
|
||||
'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'),
|
||||
'periods': fields.many2many('account.period', 'period_report_rel', 'report_id', 'period_id', 'Periods', help='All periods if empty'),
|
||||
'result_selection': fields.selection([('customer','Receivable Accounts'),
|
||||
('supplier','Payable Accounts'),
|
||||
('all','Receivable and Payable Accounts')],
|
||||
'Partner', required=True),
|
||||
'soldeinit': fields.boolean('Include initial balances'),
|
||||
'date1': fields.date('Start date', required=True),
|
||||
'date2': fields.date('End date', required=True),
|
||||
}
|
||||
|
||||
def _get_company(self, cr, uid, ids, context=None):
|
||||
user_obj = self.pool.get('res.users')
|
||||
company_obj = self.pool.get('res.company')
|
||||
user = user_obj.browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
return user.company_id.id
|
||||
else:
|
||||
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults={
|
||||
'state' : 'none',
|
||||
'date1' : lambda *a: time.strftime('%Y-01-01'),
|
||||
'date2' : lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'result_selection' : lambda *a: 'all',
|
||||
'soldeinit' : True,
|
||||
'company_id' : _get_company,
|
||||
'fiscalyear' : False,
|
||||
}
|
||||
|
||||
def check_state(self, cr, uid, ids, context=None):
|
||||
data = {
|
||||
'ids':[],
|
||||
'model': 'res.partner',
|
||||
'form': self.read(cr, uid, ids, [])[0],
|
||||
}
|
||||
|
||||
if data['form']['state'] == 'bydate' :
|
||||
return self._check_date(cr, uid, data, context)
|
||||
if data['form']['state'] == 'byperiod':
|
||||
if not data['form']['periods']:
|
||||
raise osv.except_osv(_('Warning'),_('Please Enter Periods ! '))
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.partner.balance',
|
||||
'datas': data,
|
||||
}
|
||||
|
||||
def _check_date(self, cr, uid, data, context):
|
||||
sql = """
|
||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||
cr.execute(sql,(data['form']['date1'],))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||
raise osv.except_osv(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop'])))
|
||||
else:
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.partner.balance',
|
||||
'datas': data,
|
||||
}
|
||||
else:
|
||||
raise osv.except_osv(_('UserError'),_('Date not in a defined fiscal year'))
|
||||
|
||||
account_partner_balance()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_partner_balance_view" model="ir.ui.view">
|
||||
<field name="name">Select period</field>
|
||||
<field name="model">account.partner.balance</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Date-Period">
|
||||
<field name="company_id"/>
|
||||
<field name="result_selection" required = "True"/>
|
||||
<newline/>
|
||||
<field name="fiscalyear"/>
|
||||
<label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
|
||||
<newline/>
|
||||
<separator string="Filters" colspan="4"/>
|
||||
<field name="state" required="True"/>
|
||||
<newline/>
|
||||
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
|
||||
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
|
||||
<separator string="Date Filter" colspan="4"/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
|
||||
<separator string="Filter on Periods" colspan="4"/>
|
||||
<field name="periods" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<newline/>
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="check_state" string="Print" type="object" icon="gtk-print"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_partner_balance" model="ir.actions.act_window">
|
||||
<field name="name">Select Period</field>
|
||||
<field name="res_model">account.partner.balance</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="account_partner_balance_view"/>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem icon="STOCK_PRINT"
|
||||
name="Partner Balance"
|
||||
action="action_account_partner_balance"
|
||||
id="menu_account_partner_balance_report"
|
||||
parent="account.next_id_22"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,116 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class account_use_model(osv.osv_memory):
|
||||
|
||||
_name = 'account.use.model'
|
||||
_description = 'Use model'
|
||||
_columns = {
|
||||
'model': fields.many2many('account.model', 'account_use_model_relation','account_id','model_id','Account Model'),
|
||||
}
|
||||
|
||||
def create_entries(self, cr, uid, ids, context=None):
|
||||
account_model_obj = self.pool.get('account.model')
|
||||
account_period_obj = self.pool.get('account.period')
|
||||
account_move_obj = self.pool.get('account.move')
|
||||
account_move_line_obj = self.pool.get('account.move.line')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
data = self.read(cr, uid, ids,context=context)[0]
|
||||
record_id = context and context.get('model_line', False) or False
|
||||
if record_id:
|
||||
data_model = account_model_obj.browse(cr,uid,data['model'])
|
||||
else:
|
||||
data_model = account_model_obj.browse(cr,uid,context['active_ids'])
|
||||
move_ids = []
|
||||
for model in data_model:
|
||||
period_id = account_period_obj.find(cr, uid, context=context)
|
||||
if not period_id:
|
||||
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
|
||||
period_id = period_id[0]
|
||||
move_id = account_move_obj.create(cr, uid, {
|
||||
'ref': model.ref,
|
||||
'period_id': period_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
})
|
||||
move_ids.append(move_id)
|
||||
for line in model.lines_id:
|
||||
val = {
|
||||
'move_id': move_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
'period_id': period_id
|
||||
}
|
||||
val.update({
|
||||
'name': line.name,
|
||||
'quantity': line.quantity,
|
||||
'debit': line.debit,
|
||||
'credit': line.credit,
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'ref': line.ref,
|
||||
'partner_id': line.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'date_maturity': time.strftime('%Y-%m-%d')
|
||||
})
|
||||
c = context.copy()
|
||||
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
||||
id_line = account_move_line_obj.create(cr, uid, val, context=c)
|
||||
context.update({'move_ids':move_ids})
|
||||
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_use_model_open_entry')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
return {
|
||||
'name': _('Use Model'),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'account.use.model',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def open_moves(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
if context is None:
|
||||
context = {}
|
||||
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_move_form')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str,context['move_ids']))+"])]",
|
||||
'name': 'Entries',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move',
|
||||
'views': [(False,'tree'),(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
|
||||
account_use_model()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_use_model" model="ir.ui.view">
|
||||
<field name="name">account.use.model.form</field>
|
||||
<field name="model">account.use.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Entries From Models">
|
||||
<group colspan="4" >
|
||||
<field name="model"/>
|
||||
</group>
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-execute" string="Create Entries" name="create_entries" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_account_use_model" model="ir.actions.act_window">
|
||||
<field name="name">Create Entries From Models</field>
|
||||
<field name="res_model">account.use.model</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_account_use_model"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'model_line':'model_line'}</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_use_model_values">
|
||||
<field name="model_id" ref="account.model_account_move_line" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Create Entries From Models</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' +str(ref('action_view_account_use_model'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.move.line</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_view_account_use_model" name="Create Entries From Models"
|
||||
parent="account.menu_finance_recurrent_entries" id="menu_account_use_model"/>
|
||||
|
||||
<record id="view_account_use_model_open_entry" model="ir.ui.view">
|
||||
<field name="name">account.use.model.open.entry.form</field>
|
||||
<field name="model">account.use.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Use Model">
|
||||
<group colspan="4" col="6">
|
||||
<label string = "Entry Lines Created." colspan="2"/>
|
||||
<newline/>
|
||||
<button icon="gtk-ok" special="cancel" string="Ok"/>
|
||||
<button icon="gtk-execute" string="Open" name="open_moves" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_use_model_create_entry" model="ir.ui.view">
|
||||
<field name="name">account.use.model.create.entry.form</field>
|
||||
<field name="model">account.use.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Use Model">
|
||||
<group colspan="4" col="6">
|
||||
<label string = "Are you sure you want to create entries?" colspan="2"/>
|
||||
<newline/>
|
||||
<button icon="gtk-ok" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-execute" string="Ok" name="create_entries" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_use_model_create_entry" model="ir.actions.act_window">
|
||||
<field name="name">Create Entries From Models</field>
|
||||
<field name="res_model">account.use.model</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_account_use_model_create_entry"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,127 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
import wizard
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
period_form = '''<?xml version="1.0"?>
|
||||
<form string="Select Date-Period">
|
||||
<field name="company_id"/>
|
||||
<field name="result_selection"/>
|
||||
<newline/>
|
||||
<field name="fiscalyear"/>
|
||||
<label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
|
||||
<newline/>
|
||||
<separator string="Filters" colspan="4"/>
|
||||
<field name="state" required="True"/>
|
||||
<newline/>
|
||||
<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
|
||||
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
|
||||
<separator string="Date Filter" colspan="4"/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
|
||||
<separator string="Filter on Periods" colspan="4"/>
|
||||
<field name="periods" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>'''
|
||||
|
||||
period_fields = {
|
||||
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
||||
'state':{
|
||||
'string':"Date/Period Filter",
|
||||
'type':'selection',
|
||||
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
|
||||
'default': lambda *a:'none'
|
||||
},
|
||||
'fiscalyear': {
|
||||
'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
||||
'default': lambda *a:False,
|
||||
'help': 'Keep empty for all open fiscal year'
|
||||
},
|
||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
|
||||
'result_selection':{
|
||||
'string':"Partner",
|
||||
'type':'selection',
|
||||
'selection':[('customer','Receivable Accounts'),('supplier','Payable Accounts'),('all','Receivable and Payable Accounts')],
|
||||
'required':True
|
||||
},
|
||||
'soldeinit':{'string':"Include initial balances",'type':'boolean'},
|
||||
'date1': {'string':' Start date', 'type':'date', 'required':True,'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
'date2': {'string':'End date', 'type':'date', 'required':True,'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
||||
def _get_defaults(self,cr,uid,data,context):
|
||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
company_id = user.company_id.id
|
||||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
data['form']['company_id'] = company_id
|
||||
data['form']['soldeinit'] = True
|
||||
data['form']['fiscalyear'] = False
|
||||
data['form']['result_selection'] = 'all'
|
||||
return data['form']
|
||||
|
||||
def _check_state(self, cr, uid, data, context):
|
||||
|
||||
if data['form']['state'] == 'bydate' :
|
||||
self._check_date(cr, uid, data, context)
|
||||
return data['form']
|
||||
|
||||
def _check_date(self, cr, uid, data, context):
|
||||
sql = """
|
||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||
cr.execute(sql,(data['form']['date1'],))
|
||||
res = cr.dictfetchall()
|
||||
if res:
|
||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||
raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop'])))
|
||||
else:
|
||||
return 'report'
|
||||
|
||||
else:
|
||||
raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_defaults],
|
||||
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
|
||||
},
|
||||
|
||||
'report': {
|
||||
'actions': [_check_state],
|
||||
'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_report('account.partner.balance.report')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,131 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import time
|
||||
import datetime
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
model_form = """<?xml version="1.0"?>
|
||||
<form string="Create entries from models">
|
||||
<field name="model"/>
|
||||
</form>"""
|
||||
|
||||
model_fields = {
|
||||
'model': {'string': 'Account Model', 'type': 'many2many', 'relation': 'account.model', 'required': True},
|
||||
}
|
||||
|
||||
form = """<?xml version="1.0"?>
|
||||
<form string="Use Model">
|
||||
<label string="Entry Lines Created."/>
|
||||
</form>
|
||||
"""
|
||||
fields = {
|
||||
}
|
||||
def _create_entries(self, cr, uid, data, context):
|
||||
pool_obj = pooler.get_pool(cr.dbname)
|
||||
if data['model']=='ir.ui.menu' or data['model']=='account.move.line':
|
||||
model_ids = data['form']['model'][0][2]
|
||||
data_model = pool_obj.get('account.model').browse(cr,uid,model_ids)
|
||||
else:
|
||||
data_model = pool_obj.get('account.model').browse(cr,uid,data['ids'])
|
||||
move_ids = []
|
||||
for model in data_model:
|
||||
|
||||
period_id = pool_obj.get('account.period').find(cr,uid, context=context)
|
||||
if not period_id:
|
||||
raise wizard.except_wizard(_('No period found !'), _('Unable to find a valid period !'))
|
||||
period_id = period_id[0]
|
||||
move_id = pool_obj.get('account.move').create(cr, uid, {
|
||||
'ref': model.ref,
|
||||
'period_id': period_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
})
|
||||
move_ids.append(move_id)
|
||||
for line in model.lines_id:
|
||||
val = {
|
||||
'move_id': move_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
'period_id': period_id
|
||||
}
|
||||
val.update({
|
||||
'name': line.name,
|
||||
'quantity': line.quantity,
|
||||
'debit': line.debit,
|
||||
'credit': line.credit,
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'ref': line.ref,
|
||||
'partner_id': line.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'date_maturity': time.strftime('%Y-%m-%d')
|
||||
})
|
||||
c = context.copy()
|
||||
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
||||
id_line = pool_obj.get('account.move.line').create(cr, uid, val, context=c)
|
||||
data['form']['move_ids']=move_ids
|
||||
return data['form']
|
||||
|
||||
class use_model(wizard.interface):
|
||||
|
||||
def _open_moves(self, cr, uid, data, context):
|
||||
pool_obj = pooler.get_pool(cr.dbname)
|
||||
model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_move_form')])
|
||||
resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str,data['form']['move_ids']))+"])]",
|
||||
'name': 'Entries',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move',
|
||||
'views': [(False,'tree'),(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
def _check(self, cr, uid, data, context):
|
||||
if data['model']=='ir.ui.menu' or data['model']=='account.move.line':
|
||||
return 'init_form'
|
||||
return 'create'
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'choice','next_state':_check}
|
||||
},
|
||||
'init_form': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':model_form, 'fields':model_fields, 'state':[('end','Cancel', 'gtk-cancel'),('create','Create', 'gtk-ok')]},
|
||||
},
|
||||
'create': {
|
||||
'actions': [_create_entries],
|
||||
'result': {'type': 'form','arch':form, 'fields':fields, 'state':[('end','Ok'),('open_move','Open')]},
|
||||
},
|
||||
'open_move': {
|
||||
'actions': [],
|
||||
'result': {'type':'action', 'action':_open_moves, 'state':'end'}
|
||||
}
|
||||
}
|
||||
|
||||
use_model("account_use_models")# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<act_window name="Delivery Costs"
|
||||
res_model="delivery.sale.order"
|
||||
src_model="sale.order"
|
||||
@@ -30,7 +30,7 @@
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="act_delivery_cost"/>
|
||||
|
||||
-->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -7,13 +7,13 @@ msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.0\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-08-28 16:01+0000\n"
|
||||
"PO-Revision-Date: 2010-03-09 21:10+0000\n"
|
||||
"Last-Translator: Anders Eriksson (Mobila System) <ae@mobilasystem.se>\n"
|
||||
"PO-Revision-Date: 2010-04-21 15:10+0000\n"
|
||||
"Last-Translator: djn (XCLUDE) <Unknown>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2010-04-17 04:16+0000\n"
|
||||
"X-Launchpad-Export-Date: 2010-04-22 03:43+0000\n"
|
||||
"X-Generator: Launchpad (build Unknown)\n"
|
||||
|
||||
#. module: hr
|
||||
@@ -189,7 +189,7 @@ msgstr "Medlemmar"
|
||||
#. module: hr
|
||||
#: field:hr.employee,ssnid:0
|
||||
msgid "SSN No"
|
||||
msgstr ""
|
||||
msgstr "Personnummer"
|
||||
|
||||
#. module: hr
|
||||
#: model:process.transition,note:hr.process_transition_contactofemployee0
|
||||
@@ -315,7 +315,7 @@ msgstr "Aktiv"
|
||||
#. module: hr
|
||||
#: constraint:hr.employee:0
|
||||
msgid "Error ! You cannot create recursive Hierarchy of Employees."
|
||||
msgstr ""
|
||||
msgstr "Fel! Du kan inte skapa omvänd rangordning av anställda."
|
||||
|
||||
#. module: hr
|
||||
#: model:process.process,name:hr.process_process_employeecontractprocess0
|
||||
|
||||
@@ -46,7 +46,8 @@ to set up a management by affair.
|
||||
'hr_timesheet_wizard.xml',
|
||||
'process/hr_timesheet_process.xml',
|
||||
'wizard/hr_timesheet_print_employee_view.xml',
|
||||
'wizard/hr_timesheet_print_users_view.xml'
|
||||
'wizard/hr_timesheet_print_users_view.xml',
|
||||
'wizard/hr_timesheet_sign_in_out_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_timesheet_demo.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data><!--
|
||||
<wizard id="si_so" name="hr_timesheet.si_so" string="Sign in / Sign out by project"/>
|
||||
<menuitem action="si_so" id="menu_si_so" parent="hr_attendance.menu_hr_time_tracking" type="wizard"/>
|
||||
|
||||
-->
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import sign_in_out
|
||||
import hr_timesheet_sign_in_out
|
||||
import hr_timesheet_print_employee
|
||||
import hr_timesheet_print_users
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class hr_so_project(osv.osv_memory):
|
||||
_name = 'hr.sign.out.project'
|
||||
_description = 'Sign Out By Project'
|
||||
_columns = {
|
||||
'account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True, domain=[('type','=','normal')]),
|
||||
'info': fields.char('Work Description', size=256, required=True),
|
||||
'date_start': fields.datetime('Starting Date', readonly=True),
|
||||
'date': fields.datetime('Closing Date'),
|
||||
'analytic_amount': fields.float('Minimum Analytic Amount'),
|
||||
'name': fields.char('Employees name', size=32, required=True, readonly=True),
|
||||
'state': fields.char('Current state', size=32, required=True, readonly=True),
|
||||
'server_date': fields.datetime('Current Date', required=True, readonly=True),
|
||||
'emp_id': fields.char('Employee ID', size=256, required=False),
|
||||
}
|
||||
|
||||
def _get_empid(self, cr, uid, context=None):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)])
|
||||
if emp_id:
|
||||
employee = emp_obj.read(cr, uid, emp_id)[0]
|
||||
return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0], 'server_date':time.strftime('%Y-%m-%d %H:%M:%S')}
|
||||
raise osv.except_osv(_('UserError'), _('No employee defined for your user !'))
|
||||
|
||||
def _get_empid2(self, cr, uid, context):
|
||||
res = self._get_empid(cr, uid, context)
|
||||
cr.execute('select name,action from hr_attendance where employee_id=%s order by name desc limit 1', (res['emp_id'],))
|
||||
res['server_date'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
res['date_start'] = cr.fetchone()[0]
|
||||
return res
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
res = super(hr_so_project, self).default_get(cr, uid, fields_list, context=context)
|
||||
res.update(self._get_empid2(cr, uid, context=context))
|
||||
return res
|
||||
|
||||
def _write(self, cr, uid, data, emp_id, context=None):
|
||||
timesheet_obj = self.pool.get('hr.analytic.timesheet')
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
hour = (time.mktime(time.strptime(data['date'] or time.strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')) -
|
||||
time.mktime(time.strptime(data['date_start'], '%Y-%m-%d %H:%M:%S'))) / 3600.0
|
||||
minimum = data['analytic_amount']
|
||||
if minimum:
|
||||
hour = round(round((hour + minimum / 2) / minimum) * minimum, 2)
|
||||
res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id'])
|
||||
if not res['product_uom_id']:
|
||||
raise osv.except_osv(_('UserError'), _('No cost unit defined for this employee !'))
|
||||
up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, res['product_uom_id'])['value']
|
||||
res['name'] = data['info']
|
||||
res['account_id'] = data['account_id']
|
||||
res['unit_amount'] = hour
|
||||
emp_journal = emp_obj.browse(cr, uid, emp_id, context).journal_id
|
||||
res['journal_id'] = emp_journal and emp_journal.id or False
|
||||
res.update(up)
|
||||
up = timesheet_obj.on_change_account_id(cr, uid, [], res['account_id']).get('value', {})
|
||||
res.update(up)
|
||||
return timesheet_obj.create(cr, uid, res, context=context)
|
||||
|
||||
def sign_out_result_end(self, cr, uid, ids, context=None):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
emp_id = data['emp_id']
|
||||
emp_obj.attendance_action_change(cr, uid, [emp_id], type='sign_out',dt=data['date'])
|
||||
self._write(cr, uid, data, emp_id, context=context)
|
||||
return {}
|
||||
|
||||
def sign_out_result(self, cr, uid, ids, context=None):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
emp_id = data['emp_id']
|
||||
emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data['date'])
|
||||
self._write(cr, uid, data, emp_id, context=context)
|
||||
return {}
|
||||
|
||||
hr_so_project()
|
||||
|
||||
class hr_si_project(osv.osv_memory):
|
||||
_name = 'hr.sign.in.project'
|
||||
_description = 'Sign In By Project'
|
||||
_columns = {
|
||||
'name': fields.char('Employees name', size=32, required=True, readonly=True),
|
||||
'state': fields.char('Current state', size=32, required=True, readonly=True),
|
||||
'date': fields.datetime('Starting Date'),
|
||||
'server_date': fields.datetime('Current Date', required=True, readonly=True),
|
||||
'emp_id': fields.char('Employee ID', size=512, required=False),
|
||||
}
|
||||
|
||||
def check_state(self, cr, uid, ids, context=None):
|
||||
obj_model = self.pool.get('ir.model.data')
|
||||
emp_id = self._get_empid(cr, uid, context)['emp_id']
|
||||
# get the latest action (sign_in or out) for this employee
|
||||
cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,))
|
||||
res = (cr.fetchone() or ('sign_out',))[0]
|
||||
#TODO: invert sign_in et sign_out
|
||||
if res == 'sign_out':
|
||||
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_timesheet_sign_in')])
|
||||
resource_id = obj_model.read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
|
||||
return {
|
||||
'name': 'Sign in / Sign out',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'hr.sign.in.project',
|
||||
'views': [(False,'tree'), (resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new'
|
||||
}
|
||||
else:
|
||||
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_timesheet_sign_out')])
|
||||
resource_id = obj_model.read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
|
||||
return {
|
||||
'name': 'Sign in / Sign out',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'hr.sign.out.project',
|
||||
'views': [(False,'tree'), (resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new'
|
||||
}
|
||||
|
||||
def _get_empid(self, cr, uid, context=None):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)])
|
||||
if emp_id:
|
||||
employee = emp_obj.read(cr, uid, emp_id)[0]
|
||||
return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0], 'server_date':time.strftime('%Y-%m-%d %H:%M:%S')}
|
||||
raise osv.except_osv(_('UserError'), _('No employee defined for your user !'))
|
||||
|
||||
def sign_in_result(self, cr, uid, ids, context):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
data = self.read(cr, uid, ids, [], context)[0]
|
||||
emp_id = data['emp_id']
|
||||
try:
|
||||
success = emp_obj.attendance_action_change(cr, uid, [emp_id], type = 'sign_in' ,dt=data['date'] or False)
|
||||
except except_osv, e:
|
||||
raise osv.except_osv(e.name, e.value)
|
||||
return {}
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
res = super(hr_si_project, self).default_get(cr, uid, fields_list, context=context)
|
||||
res.update(self._get_empid(cr, uid, context=context))
|
||||
return res
|
||||
|
||||
hr_si_project()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_hr_timesheet_sign_in_message" model="ir.ui.view">
|
||||
<field name="name">hr.sign.in.project.message.form</field>
|
||||
<field name="model">hr.sign.in.project</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sign In/Out By Project">
|
||||
<group colspan="4" >
|
||||
<separator string="This Wizard will make Sign In/Out By Project" colspan="4"/>
|
||||
</group>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" string="Sign in / Sign out" name="check_state" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_hr_timesheet_sign_in" model="ir.ui.view">
|
||||
<field name="name">hr.sign.in.project.form</field>
|
||||
<field name="model">hr.sign.in.project</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sign In/Out By Project">
|
||||
<group colspan="4" >
|
||||
<separator string="Sign in" colspan="4"/>
|
||||
<field name="name" readonly="True" />
|
||||
<field name="state" readonly="True" />
|
||||
<field name="server_date"/>
|
||||
<label string="(local time on the server side)" colspan="2"/>
|
||||
<field name="date"/>
|
||||
<label string="(Keep empty for current time)" colspan="2"/>
|
||||
</group>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" string="Start Working" name="sign_in_result" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_timesheet_sign_in" model="ir.actions.act_window">
|
||||
<field name="name">Sign in / Sign out by project</field>
|
||||
<field name="res_model">hr.sign.in.project</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_hr_timesheet_sign_in_message"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_hr_timesheet_sign_in"
|
||||
id="menu_hr_timesheet_sign_in"
|
||||
parent="hr_attendance.menu_hr_time_tracking"
|
||||
/>
|
||||
|
||||
<record id="view_hr_timesheet_sign_out" model="ir.ui.view">
|
||||
<field name="name">hr.sign.out.project.form</field>
|
||||
<field name="model">hr.sign.out.project</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sign In/Out By Project">
|
||||
<group colspan="4" >
|
||||
<separator string="General Information" colspan="4" />
|
||||
<field name="name" readonly="True" />
|
||||
<field name="state" readonly="True" />
|
||||
<field name="date_start"/>
|
||||
<field name="server_date"/>
|
||||
<separator string="Work done in the last period" colspan="4" />
|
||||
<field name="account_id" colspan="3"/>
|
||||
<field name="info" colspan="3"/>
|
||||
<field name="date"/>
|
||||
<label string="(Keep empty for current_time)" colspan="2"/>
|
||||
<field name="analytic_amount"/> </group>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" string="Change Work" name="sign_out_result" type="object"/>
|
||||
<button icon="gtk-ok" string="Stop Working" name="sign_out_result_end" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_timesheet_sign_out" model="ir.actions.act_window">
|
||||
<field name="name">Sign in / Sign out by project</field>
|
||||
<field name="res_model">hr.sign.out.project</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_hr_timesheet_sign_out"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,174 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
import wizard
|
||||
import time
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
si_form ='''<?xml version="1.0"?>
|
||||
<form string="Sign in / Sign out">
|
||||
<separator string="Sign in" colspan="4"/>
|
||||
<field name="name" readonly="True" />
|
||||
<field name="state" readonly="True" />
|
||||
<field name="server_date"/>
|
||||
<label string="(local time on the server side)" colspan="2"/>
|
||||
<field name="date"/>
|
||||
<label string="(Keep empty for current time)" colspan="2"/>
|
||||
</form>'''
|
||||
|
||||
si_fields = {
|
||||
'name': {'string': "Employee's name", 'type':'char', 'required':True, 'readonly':True},
|
||||
'state': {'string': "Current state", 'type' : 'char', 'required' : True, 'readonly': True},
|
||||
'date': {'string':"Starting Date", 'type':'datetime'},
|
||||
'server_date': {'string':"Current Date", 'type':'datetime', 'readonly':True},
|
||||
}
|
||||
|
||||
so_form = '''<?xml version="1.0" ?>
|
||||
<form string="Sign in status">
|
||||
<separator string="General Information" colspan="4" />
|
||||
<field name="name" readonly="True" />
|
||||
<field name="state" readonly="True" />
|
||||
<field name="date_start"/>
|
||||
<field name="server_date"/>
|
||||
<separator string="Work done in the last period" colspan="4" />
|
||||
<field name="account_id" colspan="3"/>
|
||||
<field name="info" colspan="3"/>
|
||||
<field name="date"/>
|
||||
<label string="(Keep empty for current_time)" colspan="2"/>
|
||||
<field name="analytic_amount"/>
|
||||
</form>'''
|
||||
|
||||
so_fields = {
|
||||
'name': {'string':"Employee's name", 'type':'char', 'required':True, 'readonly':True},
|
||||
'state': {'string':"Current state", 'type':'char', 'required':True, 'readonly':True},
|
||||
'account_id': {'string':"Analytic Account", 'type':'many2one', 'relation':'account.analytic.account', 'required':True, 'domain':"[('type','=','normal')]"},
|
||||
'info': {'string':"Work Description", 'type':'char', 'size':256, 'required':True},
|
||||
'date': {'string':"Closing Date", 'type':'datetime'},
|
||||
'date_start': {'string':"Starting Date", 'type':'datetime', 'readonly':True},
|
||||
'server_date': {'string':"Current Server Date", 'type':'datetime', 'readonly':True},
|
||||
'analytic_amount': {'string':"Minimum Analytic Amount", 'type':'float'},
|
||||
}
|
||||
|
||||
def _get_empid(self, cr, uid, data, context):
|
||||
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)])
|
||||
if emp_id:
|
||||
employee = emp_obj.read(cr, uid, emp_id)[0]
|
||||
return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0], 'date':False, 'server_date':time.strftime('%Y-%m-%d %H:%M:%S')}
|
||||
raise wizard.except_wizard(_('UserError'), _('No employee defined for your user !'))
|
||||
|
||||
def _get_empid2(self, cr, uid, data, context):
|
||||
res = _get_empid(self,cr, uid, data, context)
|
||||
cr.execute('select name,action from hr_attendance where employee_id=%s order by name desc limit 1', (res['emp_id'],))
|
||||
res['server_date'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
res['date_start'] = cr.fetchone()[0]
|
||||
res['info'] = ''
|
||||
res['account_id'] = False
|
||||
return res
|
||||
|
||||
def _sign_in_result(self, cr, uid, data, context):
|
||||
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
emp_id = data['form']['emp_id']
|
||||
from osv.osv import except_osv
|
||||
try:
|
||||
success = emp_obj.attendance_action_change(cr, uid, [emp_id], type = 'sign_in' ,dt=data['form']['date'] or False)
|
||||
except except_osv, e:
|
||||
raise wizard.except_wizard(e.name, e.value)
|
||||
return {}
|
||||
|
||||
def _write(self, cr, uid, data, emp_id, context):
|
||||
timesheet_obj = pooler.get_pool(cr.dbname).get('hr.analytic.timesheet')
|
||||
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
hour = (time.mktime(time.strptime(data['form']['date'] or time.strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')) -
|
||||
time.mktime(time.strptime(data['form']['date_start'], '%Y-%m-%d %H:%M:%S'))) / 3600.0
|
||||
minimum = data['form']['analytic_amount']
|
||||
if minimum:
|
||||
hour = round(round((hour + minimum / 2) / minimum) * minimum, 2)
|
||||
res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id'])
|
||||
if not res['product_uom_id']:
|
||||
raise wizard.except_wizard(_('UserError'), _('No cost unit defined for this employee !'))
|
||||
up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, res['product_uom_id'])['value']
|
||||
res['name'] = data['form']['info']
|
||||
res['account_id'] = data['form']['account_id']
|
||||
res['unit_amount'] = hour
|
||||
emp_journal = emp_obj.browse(cr, uid, emp_id, context).journal_id
|
||||
res['journal_id'] = emp_journal and emp_journal.id or False
|
||||
res.update(up)
|
||||
up = timesheet_obj.on_change_account_id(cr, uid, [], res['account_id']).get('value', {})
|
||||
res.update(up)
|
||||
return timesheet_obj.create(cr, uid, res, context)
|
||||
|
||||
def _sign_out_result_end(self, cr, uid, data, context):
|
||||
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
emp_id = data['form']['emp_id']
|
||||
emp_obj.attendance_action_change(cr, uid, [emp_id], type='sign_out',dt=data['form']['date'])
|
||||
_write(self, cr, uid, data, emp_id, context)
|
||||
return {}
|
||||
|
||||
def _sign_out_result(self, cr, uid, data, context):
|
||||
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
emp_id = data['form']['emp_id']
|
||||
emp_obj.attendance_action_change(cr, uid, [emp_id], type='action',dt=data['form']['date'])
|
||||
_write(self, cr, uid, data, emp_id, context)
|
||||
return {}
|
||||
|
||||
def _state_check(self, cr, uid, data, context):
|
||||
emp_id = _get_empid(self, cr, uid, data, context)['emp_id']
|
||||
# get the latest action (sign_in or out) for this employee
|
||||
cr.execute('select action from hr_attendance where employee_id=%s and action in (\'sign_in\',\'sign_out\') order by name desc limit 1', (emp_id,))
|
||||
res = (cr.fetchone() or ('sign_out',))[0]
|
||||
#TODO: invert sign_in et sign_out
|
||||
return res
|
||||
|
||||
class wiz_si_so(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [_get_empid],
|
||||
'result' : {'type' : 'choice', 'next_state': _state_check}
|
||||
},
|
||||
'sign_out' : { # this means sign_in...
|
||||
'actions' : [_get_empid],
|
||||
'result' : {'type':'form', 'arch':si_form, 'fields' : si_fields, 'state':[('end', 'Cancel'),('si_result', 'Start Working') ] }
|
||||
},
|
||||
'si_result' : {
|
||||
'actions' : [_sign_in_result],
|
||||
'result' : {'type':'state', 'state':'end'}
|
||||
},
|
||||
'sign_in' : { # this means sign_out...
|
||||
'actions' : [_get_empid2],
|
||||
'result' : {'type':'form', 'arch':so_form, 'fields':so_fields, 'state':[('end', 'Cancel'),('so_result', 'Change Work'),('so_result_end', 'Stop Working') ] }
|
||||
},
|
||||
'so_result' : {
|
||||
'actions' : [_sign_out_result],
|
||||
'result' : {'type':'state', 'state':'end'}
|
||||
},
|
||||
'so_result_end' : {
|
||||
'actions' : [_sign_out_result_end],
|
||||
'result' : {'type':'state', 'state':'end'}
|
||||
},
|
||||
}
|
||||
wiz_si_so('hr_timesheet.si_so')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -39,6 +39,7 @@ reports, eso.""",
|
||||
'hr_timesheet_invoice_report.xml',
|
||||
'report/report_analytic_view.xml',
|
||||
'report/hr_timesheet_invoice_report_view.xml',
|
||||
'wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_timesheet_invoice_demo.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
sequence="2" />
|
||||
<report auto="False" id="account_analytic_account_cost_ledger" menu="False" model="account.analytic.account" name="hr.timesheet.invoice.account.analytic.account.cost_ledger" rml="account/project/report/cost_ledger.rml" string="Cost Ledger"/>
|
||||
|
||||
<wizard id="account_analytic_account_cost_ledger_report" keyword="client_print_multi" model="account.analytic.account" name="hr.timesheet.invoice.account.analytic.account.cost_ledger.report" string="Cost Ledger"/>
|
||||
<!--<wizard id="account_analytic_account_cost_ledger_report" keyword="client_print_multi" model="account.analytic.account" name="hr.timesheet.invoice.account.analytic.account.cost_ledger.report" string="Cost Ledger"/>-->
|
||||
|
||||
<report
|
||||
auto="False"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,14 +15,14 @@
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import hr_timesheet_invoice_create
|
||||
import account_analytic_profit
|
||||
import hr_timesheet_final_invoice_create
|
||||
import wizard_account_analytic_cost_ledger_report
|
||||
import hr_timesheet_analytic_cost_ledger_report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
class hr_timesheet_analytic_cost_ledger(osv.osv_memory):
|
||||
_name = 'hr.timesheet.analytic.cost.ledger'
|
||||
_description = 'hr.timesheet.analytic.cost.ledger'
|
||||
_columns = {
|
||||
'date1': fields.date('Start of period', required=True),
|
||||
'date2': fields.date('End of period', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'date1': lambda *a: time.strftime('%Y-01-01'),
|
||||
'date2': lambda *a: time.strftime('%Y-%m-%d')
|
||||
}
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {
|
||||
'ids': 'active_ids' in context and context['active_ids'] or [],
|
||||
'model': 'account.analytic.account',
|
||||
'form': self.read(cr, uid, ids)[0]
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'hr.timesheet.invoice.account.analytic.account.cost_ledger',
|
||||
'datas': datas,
|
||||
}
|
||||
|
||||
hr_timesheet_analytic_cost_ledger()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_hr_timesheet_invoice_cost_ledger" model="ir.ui.view">
|
||||
<field name="name">Cost Ledger</field>
|
||||
<field name="model">hr.timesheet.analytic.cost.ledger</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Period">
|
||||
<group col="4" colspan="6">
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_timesheet_invoice_cost_ledger" model="ir.actions.act_window">
|
||||
<field name="name">Cost Ledger</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.timesheet.analytic.cost.ledger</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="hr_timesheet_invoice_cost_ledger_values">
|
||||
<field name="model_id" ref="model_account_analytic_account" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Cost Ledger</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_timesheet_invoice_cost_ledger'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,52 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
import wizard
|
||||
|
||||
dates_form = '''<?xml version="1.0"?>
|
||||
<form string="Select period">
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
||||
},
|
||||
'report': {
|
||||
'actions': [],
|
||||
'result': {'type':'print', 'report':'hr.timesheet.invoice.account.analytic.account.cost_ledger', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_report('hr.timesheet.invoice.account.analytic.account.cost_ledger.report')
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
-->
|
||||
|
||||
<record id="purchase_line_form_action2" model="ir.actions.act_window">
|
||||
<field name="name">Uninvoiced Purchase Order Lines</field>
|
||||
<field name="name">Lines To Invoices</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.order.line</field>
|
||||
<field name="domain">[('state','in',('confirmed','done')), ('invoiced','=',False)]</field>
|
||||
|
||||
@@ -62,6 +62,7 @@ Thanks to the double entry management, the inventory controlling is powerful and
|
||||
"product_data.xml",
|
||||
"product_view.xml",
|
||||
"partner_view.xml",
|
||||
"report/report_stock_move_view.xml",
|
||||
"report/report_stock_view.xml",
|
||||
"report/report_stock_picking_view.xml",
|
||||
"security/stock_security.xml",
|
||||
|
||||
@@ -28,6 +28,7 @@ import lot_overview
|
||||
import lot_overview_all
|
||||
import report_stock
|
||||
import report_stock_picking
|
||||
import report_stock_move
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
|
||||
|
||||
class report_stock_move(osv.osv):
|
||||
_name = "report.stock.move"
|
||||
_description = "Stock Statistics"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.date('Date', readonly=True),
|
||||
'year': fields.char('Year', size=4, readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
|
||||
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
|
||||
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
|
||||
'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
||||
'location_id':fields.many2one('stock.location', 'Location', readonly=True),
|
||||
'product_qty':fields.integer('Qty',readonly=True),
|
||||
'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
|
||||
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
|
||||
\nThe state is \'Waiting\' if the move is waiting for another one.'),
|
||||
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'report_stock_move')
|
||||
cr.execute("""
|
||||
create or replace view report_stock_move as (
|
||||
select min(m.id) as id,
|
||||
m.date as date,
|
||||
to_char(date_trunc('day',m.date), 'YYYY') as year,
|
||||
to_char(date_trunc('day',m.date), 'MM') as month,
|
||||
to_char(date_trunc('day',m.date), 'YYYY-MM-DD') as day,
|
||||
m.location_id as location_id,
|
||||
m.product_id as product_id,
|
||||
m.state as state,
|
||||
sum(m.product_qty) as product_qty
|
||||
from stock_move as m group by m.product_id, m.location_id, m.id, m.date, m.state
|
||||
)
|
||||
""")
|
||||
report_stock_move()
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_stock_tree" model="ir.ui.view">
|
||||
<field name="name">report.stock.move.tree</field>
|
||||
<field name="model">report.stock.move</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock Orders Statistics">
|
||||
<field name="date"/>
|
||||
<field name="year" invisible="1" />
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="location_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_graph" model="ir.ui.view">
|
||||
<field name="name">report.stock.move.graph</field>
|
||||
<field name="model">report.stock.move</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Stock Moves Statistics" type="bar">
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_search" model="ir.ui.view">
|
||||
<field name="name">report.stock.move.search</field>
|
||||
<field name="model">report.stock.move</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Stock Move">
|
||||
<group>
|
||||
<filter icon="terp-stock"
|
||||
string="This Year"
|
||||
domain="[('year','=',time.strftime('%%Y'))]"
|
||||
help="Stock Moves of the year"/>
|
||||
<filter icon="terp-stock"
|
||||
string="This Month"
|
||||
domain="[('month','=',time.strftime('%%m'))]"
|
||||
help="Stock Moves of this month"/>
|
||||
<filter icon="terp-stock"
|
||||
string="Current Stock"
|
||||
separator="1"
|
||||
domain="[('date', '=', time.strftime('%%Y-%%m-%%d')]"
|
||||
help="Stock Moves of today"/>
|
||||
<separator orientation="vertical"/>
|
||||
|
||||
<filter string="Waiting"
|
||||
icon="terp-stock"
|
||||
domain="[('state','=','waiting')]"
|
||||
help = "Confirmed Stock-Moves"/>
|
||||
|
||||
<filter string="Available"
|
||||
icon="terp-stock"
|
||||
domain="[('state','=','assigned')]"
|
||||
help = "Available Stock-Moves"/>
|
||||
|
||||
<filter string="Done"
|
||||
icon="terp-stock"
|
||||
domain="[('state','=','done')]"
|
||||
help = "Completed Stock-Moves"/>
|
||||
|
||||
<separator orientation="vertical"/>
|
||||
<field name="product_id" select="1" widget="selection"/>
|
||||
<field name="location_id" select="1" widget="selection"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." >
|
||||
<filter string="Product" icon="terp-stock" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Location" icon="terp-stock" context="{'group_by':'location_id'}"/>
|
||||
<filter string="State" icon="terp-stock" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Day" icon="terp-stock" context="{'group_by':'day'}"/>
|
||||
<filter string="Month" icon="terp-stock" context="{'group_by':'date'}"/>
|
||||
<filter string="Year" icon="terp-stock" context="{'group_by':'year'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_stock_move_report" model="ir.actions.act_window">
|
||||
<field name="name">Stock Moves</field>
|
||||
<field name="res_model">report.stock.move</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_stock_search"/>
|
||||
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="stock.next_id_61"
|
||||
name="Reporting"
|
||||
parent="stock.menu_stock_root" groups="base.group_user"/>
|
||||
|
||||
<menuitem action="action_stock_move_report" id="menu_action_stock_move_report" parent="next_id_61" sequence="5"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
# Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) All Rights Reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -19,54 +19,27 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) All Rights Reserved.
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
"name" : "Thunderbird Interface",
|
||||
"version" : "1.0",
|
||||
"author" : "Axelor",
|
||||
"website" : "http://www.axelor.com/",
|
||||
"depends" : ["base","crm"],
|
||||
"category" : "Generic Modules/Thunderbird interface",
|
||||
"description": '''
|
||||
This module is required for the thuderbird plug-in to work
|
||||
properly.
|
||||
"name" : "Thunderbird Interface",
|
||||
"version" : "1.0",
|
||||
"author" : "Axelor",
|
||||
"website" : "http://www.axelor.com/",
|
||||
"depends" : ["base","crm"],
|
||||
"category" : "Generic Modules/Thunderbird interface",
|
||||
"description": '''
|
||||
This module is required for the thuderbird plug-in to work
|
||||
properly.
|
||||
|
||||
This allows you to select an object that you’d like to add
|
||||
to your email and its attachments. You can select a partner, a task,
|
||||
a project, an analytical account, or any other object and attach selected
|
||||
mail as .eml file in attachment of selected record.
|
||||
This allows you to select an object that you’d like to add
|
||||
to your email and its attachments. You can select a partner, a task,
|
||||
a project, an analytical account, or any other object and attach selected
|
||||
mail as .eml file in attachment of selected record.
|
||||
|
||||
You can create new case in crm using Create Case button.
|
||||
Select a section for which you want to create case.''',
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ['security/ir.model.access.csv'],
|
||||
"active": False,
|
||||
"installable": True
|
||||
You can create new case in crm using Create Case button.
|
||||
Select a section for which you want to create case.''',
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ['security/ir.model.access.csv'],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class tinythunderbird_partner(osv.osv):
|
||||
header_name = email.Header.decode_header(dictcreate['name'])
|
||||
dictcreate['name'] = header_name and header_name[0] and header_name[0][0]
|
||||
add_obj=self.pool.get('res.partner.address')
|
||||
case_pool=self.pool.get('crm.case')
|
||||
case_pool=self.pool.get(dictcreate.get('object','crm.case'))
|
||||
partner_ids=add_obj.search(cr,user,[('email','=',dictcreate['email_from'])])
|
||||
partner=add_obj.read(cr,user,partner_ids,['partner_id'])
|
||||
if partner:
|
||||
@@ -95,7 +95,7 @@ class tinythunderbird_partner(osv.osv):
|
||||
search_id = self.pool.get('res.request.link').search(cr,user,[('object','=',dictcreate['ref'].split(',')[0])])
|
||||
if not search_id:
|
||||
create_link_id = self.pool.get('res.request.link').create(cr,user,{'name':dictcreate['ref'].split(',')[0],'object':dictcreate['ref'].split(',')[0]})
|
||||
create_id = self.pool.get('crm.case').create(cr, user, dictcreate)
|
||||
create_id = self.pool.get(dictcreate.get('object','crm.case')).create(cr, user, dictcreate)
|
||||
cases=case_pool.browse(cr,user,[create_id])
|
||||
case_pool._history(cr, user, cases, _('Archive'), history=True, email=False)
|
||||
return create_id
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user