[MERGE] Branch from Christophe Chauvet (Sylëam)
bzr revid: stephane@tinyerp.com-20090319155444-nss09jtbjc5khdqc
This commit is contained in:
@@ -470,7 +470,7 @@ class account_journal(osv.osv):
|
||||
'user_id': lambda self,cr,uid,context: uid,
|
||||
}
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
journal_id = super(osv.osv, self).create(cr, uid, vals, context)
|
||||
journal_id = super(account_journal, self).create(cr, uid, vals, context)
|
||||
# journal_name = self.browse(cr, uid, [journal_id])[0].code
|
||||
# periods = self.pool.get('account.period')
|
||||
# ids = periods.search(cr, uid, [('date_stop','>=',time.strftime('%Y-%m-%d'))])
|
||||
@@ -481,6 +481,7 @@ class account_journal(osv.osv):
|
||||
# 'period_id': period.id
|
||||
# })
|
||||
return journal_id
|
||||
|
||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||
if not args:
|
||||
args=[]
|
||||
|
||||
@@ -40,16 +40,22 @@ class account_move_line(osv.osv):
|
||||
else:
|
||||
fiscalyear_clause = '%s' % context['fiscalyear']
|
||||
state=context.get('state',False)
|
||||
where_move_state=''
|
||||
where_move_state = ''
|
||||
where_move_lines_by_date = ''
|
||||
|
||||
if context.get('date_from', False) and context.get('date_to', False):
|
||||
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
|
||||
|
||||
if state:
|
||||
if state.lower() not in ['all']:
|
||||
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
|
||||
|
||||
|
||||
|
||||
if context.get('periods', False):
|
||||
ids = ','.join([str(x) for x in context['periods']])
|
||||
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
|
||||
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date)
|
||||
else:
|
||||
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
|
||||
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date)
|
||||
|
||||
def default_get(self, cr, uid, fields, context={}):
|
||||
data = self._default_get(cr, uid, fields, context)
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
<field name="period_id" select="2"/>
|
||||
<group colspan="2" col="3">
|
||||
<button name="%(wizard_populate_statement_from_inv)d"
|
||||
string="Import Invoice" type="action" />
|
||||
string="Import Invoice" type="action" attrs="{'invisible':[('state','=','confirm')]}"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="balance_start"/>
|
||||
|
||||
@@ -511,7 +511,6 @@ class account_invoice(osv.osv):
|
||||
company_currency = inv.company_id.currency_id.id
|
||||
# create the analytical lines
|
||||
line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line']
|
||||
ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
|
||||
# one move line per invoice line
|
||||
iml = self._get_analytic_lines(cr, uid, inv.id)
|
||||
# check if taxes are all computed
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
<td><para style="tbl_content"></para></td>
|
||||
<td><para style="tbl_content">[[ move.name ]]</para></td>
|
||||
<td><para style="tbl_content">[[ move.account_id.code ]] - [[ move.account_id.name ]]</para></td>
|
||||
<td><para style="tbl_content"></para></td>
|
||||
<td><para style="tbl_content_right">[[ formatLang(move.debit-move.credit) ]]</para></td>
|
||||
<td><para style="tbl_content"></para></td>
|
||||
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
@@ -127,6 +127,8 @@ class account_balance(report_sxw.rml_parse):
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
elif form['state']== 'bydate':
|
||||
ctx['date_from'] = form['date_from']
|
||||
ctx['date_to'] = form['date_to']
|
||||
self.transform_date_into_date_array(form)
|
||||
elif form['state'] == 'all' :
|
||||
self.transform_both_into_date_array(form)
|
||||
|
||||
@@ -178,7 +178,8 @@ def _data_save(self, cr, uid, data, context):
|
||||
'WHERE account_id = %s ' \
|
||||
'AND ' + query_line + ' ' \
|
||||
'ORDER BY id ' \
|
||||
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
|
||||
'LIMIT %s OFFSET %s', (account.id, limit, offset))
|
||||
|
||||
result = cr.dictfetchall()
|
||||
if not result:
|
||||
break
|
||||
|
||||
@@ -68,35 +68,31 @@ class wiz_refund(wizard.interface):
|
||||
if form['period'] :
|
||||
period = form['period']
|
||||
else:
|
||||
period = inv.period_id.id
|
||||
period = inv.period_id and inv.period_id.id or False
|
||||
|
||||
if form['date'] :
|
||||
date = form['date']
|
||||
if not form['period'] :
|
||||
try :
|
||||
#we try in multy company mode
|
||||
cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
|
||||
result_query = cr.fetchone()
|
||||
if result_query:
|
||||
#in multi company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop and company_id = %s limit 1 """%(
|
||||
form['date'],
|
||||
pool.get('res.users').browse(cr,uid,uid).company_id.id
|
||||
)
|
||||
|
||||
)
|
||||
except :
|
||||
#we try in mono company mode
|
||||
))
|
||||
else:
|
||||
#in mono company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop limit 1 """%(
|
||||
form['date'],
|
||||
)
|
||||
|
||||
)
|
||||
))
|
||||
res = cr.fetchone()
|
||||
if res:
|
||||
period = res[0]
|
||||
|
||||
|
||||
else:
|
||||
date = inv.date_invoice
|
||||
|
||||
@@ -104,6 +100,10 @@ class wiz_refund(wizard.interface):
|
||||
description = form['description']
|
||||
else:
|
||||
description = inv.name
|
||||
|
||||
if not period:
|
||||
raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
|
||||
|
||||
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
|
||||
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
|
||||
# we compute due date
|
||||
|
||||
+4
-1
@@ -58,6 +58,7 @@ class crm_case_section(osv.osv):
|
||||
'name': fields.char('Case Section',size=64, required=True, translate=True),
|
||||
'code': fields.char('Section Code',size=8),
|
||||
'active': fields.boolean('Active'),
|
||||
'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'user_id': fields.many2one('res.users', 'Responsible User'),
|
||||
'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by Open ERP about cases in this section"),
|
||||
@@ -66,6 +67,7 @@ class crm_case_section(osv.osv):
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'allow_unlink': lambda *a: 1,
|
||||
}
|
||||
_sql_constraints = [
|
||||
('code_uniq', 'unique (code)', 'The code of the section must be unique !')
|
||||
@@ -388,12 +390,13 @@ class crm_case(osv.osv):
|
||||
'email_from': _get_default_email,
|
||||
'state': lambda *a: 'open',
|
||||
'priority': lambda *a: AVAILABLE_PRIORITIES[2][0],
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
}
|
||||
_order = 'priority, date_deadline desc, date desc,id desc'
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}):
|
||||
for case in self.browse(cr, uid, ids, context):
|
||||
if case.state <> 'draft':
|
||||
if (not case.section_id.allow_unlink) and (case.state <> 'draft'):
|
||||
raise osv.except_osv(_('Warning !'),
|
||||
_('You can not delete this case. You should better cancel it.'))
|
||||
return super(crm_case, self).unlink(cr, uid, ids, context)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<field name="active" select="2"/>
|
||||
<field name="user_id" select="2"/>
|
||||
<field name="parent_id" select="2"/>
|
||||
<field name="allow_unlink" select="2"/>
|
||||
<field name="reply_to" select="2"/>
|
||||
<label colspan="2" string="Complete this if you use the mail gateway."/>
|
||||
</page>
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support2)+')]'"/>
|
||||
</record>
|
||||
<menuitem parent="menu_action_report_crm_case_lead" name="Cases by Leads and Category2" action="action_report_crm_case_lead_categ" id="menu_action_report_crm_case_lead_categ"/>
|
||||
<menuitem parent="menu_action_report_crm_case_lead" name="Cases by Leads and Type" action="action_report_crm_case_lead_categ" id="menu_action_report_crm_case_lead_categ"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_report_crm_case_lead_stage">
|
||||
<field name="res_model">report.crm.case.section.stage</field>
|
||||
@@ -284,7 +284,7 @@
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support2)+')]'"/>
|
||||
</record>
|
||||
<menuitem name="Cases by Section, Category and Category2" parent="menu_action_report_crm_case_lead" action="action_report_crm_case_lead_categ_categ2" id="menu_action_report_crm_case_lead_categ_categ2"/>
|
||||
<menuitem name="Cases by Section, Category and Type" parent="menu_action_report_crm_case_lead" action="action_report_crm_case_lead_categ_categ2" id="menu_action_report_crm_case_lead_categ_categ2"/>
|
||||
|
||||
|
||||
</data>
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
|
||||
</record>
|
||||
<menuitem name="Cases by Opportunities and Category2" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ" id="menu_action_report_crm_case_oppor_categ"/>
|
||||
<menuitem name="Cases by Opportunities and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ" id="menu_action_report_crm_case_oppor_categ"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_stage">
|
||||
<field name="res_model">report.crm.case.section.stage</field>
|
||||
@@ -271,7 +271,7 @@
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
|
||||
</record>
|
||||
<menuitem name="Cases by Section, Category and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_stage" id="menu_action_report_crm_case_oppor_categ_stage"/>
|
||||
<menuitem name="Cases by Opportunities, Category and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_stage" id="menu_action_report_crm_case_oppor_categ_stage"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_categ_categ2">
|
||||
<field name="res_model">report.crm.case.section.categ.categ2</field>
|
||||
@@ -279,7 +279,7 @@
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
|
||||
</record>
|
||||
<menuitem name="Cases by Section, Category and Category2" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_categ2" id="menu_action_report_crm_case_oppor_categ_categ2"/>
|
||||
<menuitem name="Cases by Opportunities, Category and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_categ2" id="menu_action_report_crm_case_oppor_categ_categ2"/>
|
||||
|
||||
|
||||
</data>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#
|
||||
|
||||
<record model="ir.ui.view" id="view_crm_case_section_categ_tree">
|
||||
<field name="name">CRM Report - Sections and Category2(Tree)</field>
|
||||
<field name="name">CRM Report - Sections and Type(Tree)</field>
|
||||
<field name="model">report.crm.case.section.categ2</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Cases by Section and Category2">
|
||||
<tree string="Cases by Section and Type">
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="section_id"/>
|
||||
@@ -24,7 +24,7 @@
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_crm_case_section_categ_form">
|
||||
<field name="name">CRM Report - Sections and Category2(Form)</field>
|
||||
<field name="name">CRM Report - Sections and Type(Form)</field>
|
||||
<field name="model">report.crm.case.section.categ2</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -42,11 +42,11 @@
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_crm_case_section_categ_graph">
|
||||
<field name="name">CRM Report - Sections and Category2(Graph)</field>
|
||||
<field name="name">CRM Report - Sections and Type(Graph)</field>
|
||||
<field name="model">report.crm.case.section.categ2</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Cases by Section and Category2" type="bar" orientation="horizontal">
|
||||
<graph string="Cases by Section and Type" type="bar" orientation="horizontal">
|
||||
<field name="category2_id"/>
|
||||
<field name="amount_revenue" operator="+"/>
|
||||
<field name="section_id" group="True"/>
|
||||
@@ -60,14 +60,14 @@
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
|
||||
</record>
|
||||
<menuitem parent="report_crm.next_id_65" name="Cases by Section and Category2" action="action_report_crm_case_section_categ_tree_month" id="menu_crm_case_section_categ_tree_month"/>
|
||||
<menuitem parent="report_crm.next_id_65" name="Cases by Section and Type" action="action_report_crm_case_section_categ_tree_month" id="menu_crm_case_section_categ_tree_month"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_tree">
|
||||
<field name="res_model">report.crm.case.section.categ2</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem parent="report_crm.next_id_66" name="Cases by Section and Category2" action="action_report_crm_case_section_categ_tree" id="menu_crm_case_section_categ_tree"/>
|
||||
<menuitem parent="report_crm.next_id_66" name="Cases by Section and Type" action="action_report_crm_case_section_categ_tree" id="menu_crm_case_section_categ_tree"/>
|
||||
|
||||
#
|
||||
# Cases by section and stage
|
||||
@@ -192,11 +192,11 @@
|
||||
#
|
||||
|
||||
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_tree">
|
||||
<field name="name">CRM Report - Section, Category and Category2(Tree)</field>
|
||||
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
|
||||
<field name="model">report.crm.case.section.categ.categ2</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Cases by Section, Category and Category2">
|
||||
<tree string="Cases by Section, Category and Type">
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="section_id"/>
|
||||
@@ -210,11 +210,11 @@
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_form">
|
||||
<field name="name">CRM Report - Section, Category and Category2(Form)</field>
|
||||
<field name="name">CRM Report - Section, Category and Type(Form)</field>
|
||||
<field name="model">report.crm.case.section.categ.categ2</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cases by Section, Category and Category2">
|
||||
<form string="Cases by Section, Category and Type">
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="section_id" select="1"/>
|
||||
@@ -234,12 +234,12 @@
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
|
||||
</record>
|
||||
<menuitem parent="report_crm.next_id_65" name="Cases by Section, Category and Category2" action="action_report_crm_case_section_categ_categ2_tree_month" id="menu_crm_case_section_categ_categ2_tree_month"/>
|
||||
<menuitem parent="report_crm.next_id_65" name="Cases by Section, Category and Type" action="action_report_crm_case_section_categ_categ2_tree_month" id="menu_crm_case_section_categ_categ2_tree_month"/>
|
||||
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_categ2_tree">
|
||||
<field name="res_model">report.crm.case.section.categ.categ2</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
<menuitem parent="report_crm.next_id_66" name="Cases by Section, Category and Category2" action="action_report_crm_case_section_categ_categ2_tree" id="menu_crm_case_section_categ_categ2_tree"/>
|
||||
<menuitem parent="report_crm.next_id_66" name="Cases by Section, Category and Type" action="action_report_crm_case_section_categ_categ2_tree" id="menu_crm_case_section_categ_categ2_tree"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+70
-86
@@ -62,13 +62,55 @@ class hr_holidays_status(osv.osv):
|
||||
}
|
||||
hr_holidays_status()
|
||||
|
||||
class hr_holidays_per_user(osv.osv):
|
||||
_name = "hr.holidays.per.user"
|
||||
_description = "Holidays Per User"
|
||||
_rec_name = "user_id"
|
||||
|
||||
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
|
||||
obj_holiday = self.pool.get('hr.holidays')
|
||||
result = {}
|
||||
for holiday_user in self.browse(cr, uid, ids):
|
||||
days = 0.0
|
||||
ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
|
||||
if ids_request:
|
||||
holidays = obj_holiday.browse(cr, uid, ids_request)
|
||||
for holiday in holidays:
|
||||
days += holiday.number_of_days
|
||||
days = holiday_user.max_leaves - days
|
||||
result[holiday_user.id] = days
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'employee_id': fields.many2one('hr.employee', 'Employee',required=True),
|
||||
'user_id' : fields.many2one('res.users','User'),
|
||||
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
|
||||
'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
|
||||
'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
|
||||
'active' : fields.boolean('Active'),
|
||||
'notes' : fields.text('Notes'),
|
||||
'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
|
||||
'holiday_ids': fields.one2many('hr.holidays', 'holiday_user_id', 'Holidays')
|
||||
}
|
||||
_defaults = {
|
||||
'active' : lambda *a: True,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
if vals['employee_id']:
|
||||
obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
|
||||
vals.update({'user_id': obj_emp.user_id.id})
|
||||
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
|
||||
|
||||
hr_holidays_per_user()
|
||||
|
||||
class hr_holidays(osv.osv):
|
||||
_name = "hr.holidays"
|
||||
_description = "Holidays"
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Description', required=True, readonly=True, size=64, states={'draft':[('readonly',False)]}),
|
||||
'state': fields.selection([('draft', 'draft'), ('confirm', 'Waiting Validation'), ('refuse', 'Refused'), ('validated', 'Validate'), ('cancel', 'Cancel')], 'Status', readonly=True),
|
||||
'state': fields.selection([('draft', 'draft'), ('confirm', 'Waiting Validation'), ('refuse', 'Refused'), ('validate', 'Validate'), ('cancel', 'Cancel')], 'Status', readonly=True),
|
||||
'date_from' : fields.datetime('Vacation start day', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'date_to' : fields.datetime('Vacation end day',required=True,readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True,readonly=True, states={'draft':[('readonly',False)]}),
|
||||
@@ -76,8 +118,9 @@ class hr_holidays(osv.osv):
|
||||
'user_id':fields.many2one('res.users', 'Employee_id', states={'draft':[('readonly',False)]}, select=True, readonly=True),
|
||||
'manager_id' : fields.many2one('hr.employee', 'Holiday manager', invisible=False, readonly=True),
|
||||
'notes' : fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'number_of_days': fields.float('Number of Days in this Holiday Request',required=True),
|
||||
'case_id':fields.many2one('crm.case', 'Case'),
|
||||
'number_of_days': fields.float('Number of Days in this Holiday Request', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'case_id': fields.many2one('crm.case', 'Case'),
|
||||
'holiday_user_id': fields.many2one('hr.holidays.per.user', 'Holiday per user')
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -87,29 +130,31 @@ class hr_holidays(osv.osv):
|
||||
}
|
||||
_order = 'date_from desc'
|
||||
|
||||
def _check_date(self, cr, uid, ids):
|
||||
if ids:
|
||||
cr.execute('select number_of_days from hr_holidays where id in ('+','.join(map(str, ids))+')')
|
||||
res = cr.fetchall()
|
||||
if res and res[0][0] < 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [(_check_date, 'Start date should not be larger than end date! ', ['number_of_days'])]
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs)
|
||||
self._create_log(cr, uid, [id_holiday])
|
||||
self._create_holiday(cr, uid, [id_holiday])
|
||||
return id_holiday
|
||||
|
||||
def _create_log(self, cr, uid, ids):
|
||||
def _create_holiday(self, cr, uid, ids):
|
||||
holidays_user_obj = self.pool.get('hr.holidays.per.user')
|
||||
list_request = []
|
||||
holidays_data = self.browse(cr, uid, ids[0])
|
||||
datas = {
|
||||
'employee_id' : holidays_data.employee_id.id,
|
||||
'name' : holidays_data.state,
|
||||
'holiday_status' : holidays_data.holiday_status.id,
|
||||
'holiday_req_id' : holidays_data.id,
|
||||
'nb_holidays' : holidays_data.number_of_days
|
||||
}
|
||||
ids_log = self.pool.get('hr.holidays.log').create(cr, uid, datas)
|
||||
list_holiday = []
|
||||
ids_user_hdays = holidays_user_obj.search(cr, uid, [('employee_id', '=', holidays_data.employee_id.id),('holiday_status', '=', holidays_data.holiday_status.id)])
|
||||
for hdays in holidays_user_obj.browse(cr, uid, ids_user_hdays):
|
||||
for req in hdays.history:
|
||||
list_request.append(req.id)
|
||||
list_request.append(ids_log)
|
||||
holidays_user_obj.write(cr, uid, ids_user_hdays, {'history' : [(6,0,list_request)]})
|
||||
for req in hdays.holiday_ids:
|
||||
list_holiday.append(req.id)
|
||||
list_holiday.append(ids[0])
|
||||
holidays_user_obj.write(cr, uid, ids_user_hdays, {'holiday_ids': [(6, 0, list_holiday)]})
|
||||
return True
|
||||
|
||||
def onchange_date_to(self, cr, uid, ids, date_from, date_to):
|
||||
@@ -133,7 +178,7 @@ class hr_holidays(osv.osv):
|
||||
'state':'draft',
|
||||
'manager_id': False
|
||||
})
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def holidays_validate(self, cr, uid, ids, *args):
|
||||
@@ -145,7 +190,7 @@ class hr_holidays(osv.osv):
|
||||
if ids2:
|
||||
vals['manager_id'] = ids2[0]
|
||||
self.write(cr, uid, ids, vals)
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def holidays_confirm(self, cr, uid, ids, *args):
|
||||
@@ -157,7 +202,7 @@ class hr_holidays(osv.osv):
|
||||
'state':'confirm',
|
||||
'user_id': user,
|
||||
})
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, *args):
|
||||
@@ -166,7 +211,7 @@ class hr_holidays(osv.osv):
|
||||
'state':'refuse',
|
||||
'manager_id':ids2[0]
|
||||
})
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def holidays_cancel(self, cr, uid, ids, *args):
|
||||
@@ -185,14 +230,14 @@ class hr_holidays(osv.osv):
|
||||
self.write(cr, uid, ids, {
|
||||
'state':'cancel'
|
||||
})
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def holidays_draft(self, cr, uid, ids, *args):
|
||||
self.write(cr, uid, ids, {
|
||||
'state':'draft'
|
||||
})
|
||||
self._create_log(cr, uid, ids)
|
||||
self._create_holiday(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def check_holidays(self,cr,uid,ids):
|
||||
@@ -238,65 +283,4 @@ class hr_holidays(osv.osv):
|
||||
return True
|
||||
hr_holidays()
|
||||
|
||||
|
||||
class hr_holidays_per_user(osv.osv):
|
||||
_name = "hr.holidays.per.user"
|
||||
_description = "Holidays Per User"
|
||||
|
||||
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
|
||||
obj_holiday = self.pool.get('hr.holidays')
|
||||
days = 0.0
|
||||
result = {}
|
||||
for holiday_user in self.browse(cr, uid, ids):
|
||||
ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
|
||||
if ids_request:
|
||||
holidays = obj_holiday.browse(cr, uid, ids_request)
|
||||
for holiday in holidays:
|
||||
days += holiday.number_of_days
|
||||
days = holiday_user.max_leaves - days
|
||||
result[holiday_user.id] = days
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'employee_id' : fields.many2one('hr.employee', 'Employee',required=True),
|
||||
'user_id' : fields.many2one('res.users','User'),
|
||||
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
|
||||
'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
|
||||
'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
|
||||
'active' : fields.boolean('Active'),
|
||||
'notes' : fields.text('Notes'),
|
||||
'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
|
||||
'history' : fields.one2many('hr.holidays.log', 'holiday_user_id', 'History')
|
||||
}
|
||||
_defaults = {
|
||||
'active' : lambda *a: True,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
if vals['employee_id']:
|
||||
obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
|
||||
vals.update({'user_id': obj_emp.user_id.id})
|
||||
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
|
||||
|
||||
hr_holidays_per_user()
|
||||
|
||||
class holiday_user_log(osv.osv):
|
||||
_name = 'hr.holidays.log'
|
||||
_description = 'hr.holidays.log'
|
||||
_order = "holiday_req_id desc"
|
||||
_columns = {
|
||||
'name' : fields.char('Action', size=64, readonly=True),
|
||||
'holiday_req_id' : fields.char('Holiday Request ID', size=64),
|
||||
'nb_holidays' : fields.float('Number of Holidays Requested'),
|
||||
'employee_id' : fields.many2one('hr.employee', 'Employee', readonly=True),
|
||||
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", readonly=True),
|
||||
'holiday_user_id' : fields.many2one('hr.holidays.per.user', 'Holidays user'),
|
||||
'date': fields.datetime('Date'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
}
|
||||
holiday_user_log()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -51,36 +51,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- holidays log -->
|
||||
<record model="ir.ui.view" id="holiday_log_form">
|
||||
<field name="name">hr.holidays.log.form</field>
|
||||
<field name="model">hr.holidays.log</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Log Holidays">
|
||||
<field name="name" select="1"/>
|
||||
<field name="employee_id" select="2"/>
|
||||
<field name="holiday_status" select="1" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="holiday_log_tree">
|
||||
<field name="name">>hr.holidays.log.tree</field>
|
||||
<field name="model">hr.holidays.log</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Log Holidays">
|
||||
<field name="holiday_req_id" />
|
||||
<field name="date" />
|
||||
<field name="employee_id" />
|
||||
<field name="name" />
|
||||
<field name="holiday_status" />
|
||||
<field name="nb_holidays" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- holidays status -->
|
||||
<record model="ir.ui.view" id="edit_holiday_status_form">
|
||||
<field name="name">hr.holidays.status.form</field>
|
||||
@@ -129,21 +99,21 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Holidays Per Employee">
|
||||
<notebook>
|
||||
<group>
|
||||
<field name="employee_id" select="1" />
|
||||
<field name="holiday_status" select="1" />
|
||||
<field name="max_leaves" select="2" />
|
||||
<field name="active" select="2"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="General Information">
|
||||
<field name="employee_id" select="1" />
|
||||
<field name="holiday_status" select="1" />
|
||||
<newline/>
|
||||
<field name="max_leaves" select="2" />
|
||||
<field name="leaves_taken" select="2" />
|
||||
<newline/>
|
||||
<field name="remaining_leaves" select="2" colspan="2" />
|
||||
<field name="active" select="2"/>
|
||||
<newline/>
|
||||
<field name="notes" colspan="4" select="2"/>
|
||||
</page>
|
||||
<page string="History" >
|
||||
<field name="history" nolabel="1"/>
|
||||
<page string="Holidays" >
|
||||
<field name="holiday_ids" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
||||
@@ -32,7 +32,6 @@ def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
|
||||
current=som+datetime.timedelta(diff)
|
||||
|
||||
for item in ids_date:
|
||||
# print current,"from",item['date_from'],"to",item['date_to']
|
||||
if current >= strToDate(item['date_from']) and current <= strToDate(item['date_to']):
|
||||
if item['state'] in holiday_type:
|
||||
display[index]=item['holiday_status'][0]
|
||||
@@ -150,7 +149,6 @@ class report_custom(report_rml):
|
||||
width_dict[j]=x
|
||||
|
||||
day_diff1=day_diff1-x
|
||||
# print "now day_diff1 is..frst.",day_diff1
|
||||
else:
|
||||
years=year+1
|
||||
year=years
|
||||
@@ -175,7 +173,6 @@ class report_custom(report_rml):
|
||||
width_dict[j]=x
|
||||
|
||||
day_diff1=day_diff1-x
|
||||
# print "now day_diff1 is..scnd.",day_diff1
|
||||
|
||||
date_xml.append('</days>')
|
||||
date_xml.append('<cols>3.5cm%s,0.4cm</cols>\n' % (',0.4cm' * (60)))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_hr_holidays_log","hr.holidays.log","model_hr_holidays_log","hr.group_hr_user",1,1,1,1
|
||||
"access_hr_holidays_per_user","hr.holidays.per.user","model_hr_holidays_per_user","hr.group_hr_user",1,1,1,1
|
||||
"access_hr_holydays_status_user","hr.holidays.status user","model_hr_holidays_status","hr.group_hr_user",1,1,1,1
|
||||
"access_hr_holidays_user","hr holidays user","model_hr_holidays","hr.group_hr_user",1,1,1,1
|
||||
|
||||
|
@@ -141,7 +141,7 @@ def _state_check(self, cr, uid, data, context):
|
||||
class wiz_si_so(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'actions' : [_get_empid],
|
||||
'result' : {'type' : 'choice', 'next_state': _state_check}
|
||||
},
|
||||
'sign_out' : { # this means sign_in...
|
||||
|
||||
@@ -51,12 +51,12 @@ class invoice_create(wizard.interface):
|
||||
for account in analytic_account_obj.browse(cr, uid, account_ids, context):
|
||||
partner = account.partner_id
|
||||
if (not partner) or not (account.pricelist_id):
|
||||
raise wizard.except_wizard(_('Analytic account incomplete'),
|
||||
_('Please fill in the partner and pricelist field in the analytic account:\n%s') % (account.name,))
|
||||
raise wizard.except_wizard(_('Analytic Account incomplete'),
|
||||
_('Please fill in the Associate Partner and Sale Pricelist fields in the Analytic Account:\n%s') % (account.name,))
|
||||
|
||||
if not partner.address:
|
||||
raise wizard.except_wizard(_('Partner incomplete'),
|
||||
_('Please fill in the address field in the partner: %s.') % (partner.name,))
|
||||
_('Please fill in the Address field in the Partner: %s.') % (partner.name,))
|
||||
|
||||
date_due = False
|
||||
if partner.property_payment_term:
|
||||
|
||||
@@ -362,7 +362,7 @@ class Partner(osv.osv):
|
||||
selection = STATE ,store = {
|
||||
'account.invoice':(_get_invoice_partner,['state'], 10),
|
||||
'membership.membership_line':(_get_partner_id,['state'], 10),
|
||||
'res.partner':(_get_partners, ['free_member','membership_state'], 10)
|
||||
'res.partner':(_get_partners, ['free_member', 'membership_state'], 10)
|
||||
}
|
||||
),
|
||||
'membership_start': fields.function(
|
||||
@@ -756,5 +756,4 @@ class account_invoice_line(osv.osv):
|
||||
return result
|
||||
|
||||
account_invoice_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -28,7 +28,6 @@ def _invoice_membership(self, cr, uid, data, context):
|
||||
partner_ids = data['ids']
|
||||
product_id = data['form']['product']
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
cr.execute('''
|
||||
SELECT partner_id, id, type
|
||||
FROM res_partner_address
|
||||
@@ -43,7 +42,6 @@ def _invoice_membership(self, cr, uid, data, context):
|
||||
pid = fetchal[x][0]
|
||||
id = fetchal[x][1]
|
||||
type = fetchal[x][2]
|
||||
|
||||
if partner_address_ids.has_key(pid) and partner_address_ids[pid]['type'] == 'invoice':
|
||||
continue
|
||||
partner_address_ids[pid] = {'id': id, 'type': type}
|
||||
@@ -95,7 +93,6 @@ def _invoice_membership(self, cr, uid, data, context):
|
||||
'res_model': 'account.invoice',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
|
||||
return value
|
||||
|
||||
wizard_arch= """<?xml version="1.0"?>
|
||||
@@ -110,7 +107,6 @@ wizard_arch= """<?xml version="1.0"?>
|
||||
class wizard_invoice_membership(wizard.interface):
|
||||
|
||||
states = {
|
||||
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result' : {
|
||||
|
||||
@@ -268,6 +268,8 @@ class product_pricelist_version(osv.osv):
|
||||
#
|
||||
def _check_date(self, cursor, user, ids):
|
||||
for pricelist_version in self.browse(cursor, user, ids):
|
||||
if not pricelist_version.active:
|
||||
continue
|
||||
if not pricelist_version.active:
|
||||
continue
|
||||
cursor.execute('SELECT id ' \
|
||||
|
||||
@@ -24,6 +24,7 @@ from lxml import etree
|
||||
from mx import DateTime
|
||||
from mx.DateTime import now
|
||||
import time
|
||||
from tools.translate import _
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
@@ -335,7 +336,7 @@ class task(osv.osv):
|
||||
if project:
|
||||
if project.warn_manager and project.manager and (project.manager.id != uid):
|
||||
request.create(cr, uid, {
|
||||
'name': "Task '%s' closed" % task.name,
|
||||
'name': _("Task '%s' closed") % task.name,
|
||||
'state': 'waiting',
|
||||
'act_from': uid,
|
||||
'act_to': project.manager.id,
|
||||
@@ -345,7 +346,12 @@ class task(osv.osv):
|
||||
})
|
||||
self.write(cr, uid, [task.id], {'state': 'done', 'date_close':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
|
||||
if task.parent_id and task.parent_id.state in ('pending','draft'):
|
||||
self.do_reopen(cr, uid, [task.parent_id.id])
|
||||
reopen = True
|
||||
for child in task.parent_id.child_ids:
|
||||
if child.id != task.id and child.state not in ('done','cancelled'):
|
||||
reopen = False
|
||||
if reopen:
|
||||
self.do_reopen(cr, uid, [task.parent_id.id])
|
||||
return True
|
||||
|
||||
def do_reopen(self, cr, uid, ids, *args):
|
||||
@@ -355,7 +361,7 @@ class task(osv.osv):
|
||||
project = task.project_id
|
||||
if project and project.warn_manager and project.manager.id and (project.manager.id != uid):
|
||||
request.create(cr, uid, {
|
||||
'name': "Task '%s' set in progress" % task.name,
|
||||
'name': _("Task '%s' set in progress") % task.name,
|
||||
'state': 'waiting',
|
||||
'act_from': uid,
|
||||
'act_to': project.manager.id,
|
||||
@@ -374,7 +380,7 @@ class task(osv.osv):
|
||||
project = task.project_id
|
||||
if project.warn_manager and project.manager and (project.manager.id != uid):
|
||||
request.create(cr, uid, {
|
||||
'name': "Task '%s' cancelled" % task.name,
|
||||
'name': _("Task '%s' cancelled") % task.name,
|
||||
'state': 'waiting',
|
||||
'act_from': uid,
|
||||
'act_to': project.manager.id,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<separator colspan="4" string="Project's members"/>
|
||||
<field colspan="4" name="members" nolabel="1"/>
|
||||
<group col="9" colspan="8">
|
||||
<field name="state"/>
|
||||
<field name="state" select="1"/>
|
||||
<button name="set_template" string="Set as Template" type="object" states="open" icon="gtk-convert"/>
|
||||
<button name="set_open" string="Reactivate Project" type="object" states="pending,cancelled,done" icon="gtk-ok"/>
|
||||
<button name="set_pending" string="Pending" type="object" states="open" icon="gtk-media-pause"/>
|
||||
@@ -310,10 +310,11 @@
|
||||
<tree string="Delegated tasks">
|
||||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="date_deadline"/>
|
||||
<field name="planned_hours" widget="float_time"/>
|
||||
<field name="effective_hours" widget="float_time"/>
|
||||
<field name="state"/>
|
||||
<field name="effective_hours" widget="float_time"/>
|
||||
<field name="progress" widget="progressbar"/>
|
||||
<field name="remaining_hours" widget="float_time"/>
|
||||
<field name="date_deadline"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field colspan="4" name="parent_id"/>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import wizard
|
||||
from tools import email_send as email
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
ask_form = """<?xml version="1.0" ?>
|
||||
<form string="Delegate this task to a user">
|
||||
@@ -51,7 +52,6 @@ class wizard_delegate(wizard.interface):
|
||||
def _do_assign(self, cr, uid, data, context):
|
||||
task_obj = pooler.get_pool(cr.dbname).get('project.task')
|
||||
task = task_obj.browse(cr, uid, data['id'], context)
|
||||
newname = task.name
|
||||
newname = data['form']['prefix'] or ''
|
||||
task_obj.copy(cr, uid, data['id'], {
|
||||
'name': data['form']['name'],
|
||||
@@ -77,12 +77,16 @@ class wizard_delegate(wizard.interface):
|
||||
def _ask_auto_complete(self, cr, uid, data, context):
|
||||
task_obj = pooler.get_pool(cr.dbname).get('project.task')
|
||||
task = task_obj.browse(cr, uid, data['id'], context)
|
||||
if task.name.startswith(_('CHECK: ')):
|
||||
newname = task.name.strip(_('CHECK: '))
|
||||
else:
|
||||
newname = task.name or ''
|
||||
return {
|
||||
'name':task.name,
|
||||
'name': newname,
|
||||
'user_id': False,
|
||||
'planned_hours': task.remaining_hours,
|
||||
'planned_hours_me': 1.0,
|
||||
'prefix': 'CHECK: '+ (task.name or ''),
|
||||
'prefix': _('CHECK: ')+ newname,
|
||||
'include_info': 1,
|
||||
'state': 'pending'
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class project_gtd_timebox(osv.osv):
|
||||
<field name="%s" colspan="4" nolabel="1">
|
||||
<tree editable="bottom" colors="grey:state in ('done','pending');red:state=='cancelled'" string="Tasks">
|
||||
<field name="name"/>
|
||||
""" % (getattr(rec, 'context%d_id'%(i,)).name, 'task%d_ids'%(i,))
|
||||
""" % (getattr(rec, 'context%d_id'%(i,)).name.encode('utf-8'), 'task%d_ids'%(i,))
|
||||
if rec.col_project:
|
||||
res['arch'] += '<field name="project_id" required="1"/>\n'
|
||||
if rec.col_date_start:
|
||||
|
||||
@@ -151,5 +151,57 @@ class report_aged_receivable(osv.osv):
|
||||
|
||||
report_aged_receivable()
|
||||
|
||||
class report_invoice_created(osv.osv):
|
||||
_name = "report.invoice.created"
|
||||
_description = "Report of Invoices Created within Last 15 days"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'type': fields.selection([
|
||||
('out_invoice','Customer Invoice'),
|
||||
('in_invoice','Supplier Invoice'),
|
||||
('out_refund','Customer Refund'),
|
||||
('in_refund','Supplier Refund'),
|
||||
],'Type', readonly=True),
|
||||
'number': fields.char('Invoice Number', size=32, readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'amount_untaxed': fields.float('Untaxed', readonly=True),
|
||||
'amount_total': fields.float('Total', readonly=True),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
|
||||
'date_invoice': fields.date('Date Invoiced', readonly=True),
|
||||
'date_due': fields.date('Due Date', readonly=True),
|
||||
'residual': fields.float('Residual', readonly=True),
|
||||
'state': fields.selection([
|
||||
('draft','Draft'),
|
||||
('proforma','Pro-forma'),
|
||||
('proforma2','Pro-forma'),
|
||||
('open','Open'),
|
||||
('paid','Done'),
|
||||
('cancel','Cancelled')
|
||||
],'State', readonly=True),
|
||||
'origin': fields.char('Origin', size=64, readonly=True),
|
||||
'create_date' : fields.datetime('Create Date', readonly=True)
|
||||
}
|
||||
_order = 'create_date'
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""create or replace view report_invoice_created as (
|
||||
select
|
||||
inv.id as id, inv.name as name, inv.type as type,
|
||||
inv.number as number, inv.partner_id as partner_id,
|
||||
inv.amount_untaxed as amount_untaxed,
|
||||
inv.amount_total as amount_total, inv.currency_id as currency_id,
|
||||
inv.date_invoice as date_invoice, inv.date_due as date_due,
|
||||
inv.residual as residual, inv.state as state,
|
||||
inv.origin as origin, inv.create_date as create_date
|
||||
from
|
||||
account_invoice inv
|
||||
where
|
||||
(to_date(to_char(inv.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
|
||||
AND
|
||||
(to_date(to_char(inv.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
|
||||
)""")
|
||||
report_invoice_created()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -81,5 +81,38 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
|
||||
<!-- Created Invoice for random activities of service dashboard -->
|
||||
|
||||
<record id="board_view_created_invoice" model="ir.ui.view">
|
||||
<field name="name">report.invoice.created.tree</field>
|
||||
<field name="model">report.invoice.created</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state=='draft'" string="Invoices">
|
||||
<field name="create_date"/>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="amount_untaxed" sum="Untaxed Amount"/>
|
||||
<field name="amount_total" sum="Total Amount"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="date_invoice"/>
|
||||
<field name="date_due" select="1"/>
|
||||
<field name="residual"/>
|
||||
<field name="state"/>
|
||||
<field name="origin"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_created_invoice_dashboard" model="ir.actions.act_window">
|
||||
<field name="name">Invoices Created Within Past 15 Days</field>
|
||||
<field name="res_model">report.invoice.created</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="board_view_created_invoice"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -106,5 +106,109 @@ class report_crm_case_categ(osv.osv):
|
||||
)""")
|
||||
report_crm_case_categ()
|
||||
|
||||
|
||||
class report_crm_case_section(osv.osv):
|
||||
_name = "report.crm.case.section"
|
||||
_description = "Cases by Section"
|
||||
_auto = False
|
||||
|
||||
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
|
||||
res = {}
|
||||
state_perc = 0.0
|
||||
avg_ans = 0.0
|
||||
|
||||
for case in self.browse(cr, uid, ids, context):
|
||||
if field_name != 'avg_answers':
|
||||
state = field_name[5:]
|
||||
cr.execute("select count(*) from crm_case where section_id =%s and state='%s'"%(case.section_id.id,state))
|
||||
state_cases = cr.fetchone()[0]
|
||||
perc_state = (state_cases / float(case.nbr_cases) ) * 100
|
||||
|
||||
res[case.id] = perc_state
|
||||
else:
|
||||
cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
|
||||
logs = cr.fetchone()[0]
|
||||
|
||||
avg_ans = logs / case.nbr_cases
|
||||
res[case.id] = avg_ans
|
||||
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.date('Month', readonly=True),
|
||||
# 'user_id':fields.many2one('res.users', 'User', readonly=True),
|
||||
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
|
||||
'nbr_cases': fields.integer('# of Cases', readonly=True),
|
||||
'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
|
||||
'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
|
||||
'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
|
||||
'delay_close': fields.char('Delay to close', size=20, readonly=True),
|
||||
}
|
||||
_order = 'name desc, section_id'
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view report_crm_case_section as (
|
||||
select
|
||||
min(c.id) as id,
|
||||
to_char(c.create_date, 'YYYY-MM-01') as name,
|
||||
c.section_id as section_id,
|
||||
count(*) as nbr_cases,
|
||||
0 as avg_answers,
|
||||
0.0 as perc_done,
|
||||
0.0 as perc_cancel,
|
||||
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
|
||||
from
|
||||
crm_case c
|
||||
group by to_char(c.create_date, 'YYYY-MM-01'),c.section_id
|
||||
)""")
|
||||
report_crm_case_section()
|
||||
|
||||
class report_crm_case_service_dashboard(osv.osv):
|
||||
_name = "report.crm.case.service.dashboard"
|
||||
_description = "Report of Closed and Open CRM Cases within past 15 days"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.datetime('Date', readonly=True),
|
||||
'date_deadline': fields.datetime('Deadline', readonly=True),
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'user_id': fields.many2one('res.users', 'Responsible', readonly=True),
|
||||
'priority': fields.char('Priority', size=64, readonly=True),
|
||||
'planned_revenue': fields.float('Planned Revenue', readonly=True),
|
||||
'planned_cost': fields.float('Planned Costs', readonly=True),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
|
||||
'date_closed' : fields.datetime('Date Closed', readonly=True),
|
||||
'create_date' : fields.datetime('Create Date', readonly=True)
|
||||
}
|
||||
_order = 'date_closed, create_date'
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""create or replace view report_crm_case_service_dashboard as (
|
||||
select
|
||||
cse.id as id, cse.date as date, cse.date_deadline as date_deadline,
|
||||
cse.name as name, cse.partner_id as partner_id, cse.user_id as user_id,
|
||||
cse.priority as priority, cse.planned_revenue as planned_revenue,
|
||||
cse.planned_cost as planned_cost, cse.state as state,
|
||||
cse.date_closed as date_closed, cse.create_date as create_date
|
||||
from
|
||||
crm_case cse
|
||||
where
|
||||
((to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
|
||||
AND
|
||||
(to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
|
||||
AND
|
||||
cse.state='done')
|
||||
|
||||
OR
|
||||
|
||||
((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
|
||||
AND
|
||||
(to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
|
||||
AND
|
||||
cse.state='open')
|
||||
)""")
|
||||
report_crm_case_service_dashboard()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -155,5 +155,104 @@
|
||||
|
||||
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case.categ" src_model="crm.case.section"/>
|
||||
|
||||
|
||||
<!-- Cases by Section -->
|
||||
|
||||
<record id="view_report_crm_case_section_tree" model="ir.ui.view">
|
||||
<field name="name">report.crm.case.section.tree</field>
|
||||
<field name="model">report.crm.case.section</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Cases by Section">
|
||||
<field name="name"/>
|
||||
<field name="section_id"/>
|
||||
<field name="nbr_cases"/>
|
||||
<field name="avg_answers"/>
|
||||
<field name="perc_done"/>
|
||||
<field name="perc_cancel"/>
|
||||
<field name="delay_close"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_report_crm_case_section_graph" model="ir.ui.view">
|
||||
<field name="name">report.crm.case.section.graph</field>
|
||||
<field name="model">report.crm.case.section</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph orientation="horizontal" string="Cases by Section" type="bar">
|
||||
<field name="name"/>
|
||||
<field name="nbr_cases" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_crm_case_section_tree" model="ir.actions.act_window">
|
||||
<field name="name">Cases by Section</field>
|
||||
<field name="res_model">report.crm.case.section</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
</record>
|
||||
|
||||
<!-- Closed & Open CRM Case view for Random Acitivities dashboard -->
|
||||
|
||||
<record id="board_view_crm_case_open_dashboard_tree" model="ir.ui.view">
|
||||
<field name="name">report.crm.case.dashboard.tree</field>
|
||||
<field name="model">report.crm.case.dashboard</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:date_deadline<current_date and state=='open'" string="CRM Cases">
|
||||
<field name="create_date"/>
|
||||
<field name="date"/>
|
||||
<field name="date_deadline"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="priority"/>
|
||||
<field name="planned_revenue" sum="Planned revenue"/>
|
||||
<field name="planned_cost" sum="Planned costs"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="board_view_crm_case_done_dashboard_tree" model="ir.ui.view">
|
||||
<field name="name">report.crm.case.dashboard.tree</field>
|
||||
<field name="model">report.crm.case.dashboard</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:date_deadline<current_date and state=='open'" string="CRM Cases">
|
||||
<field name="date_closed"/>
|
||||
<field name="date"/>
|
||||
<field name="date_deadline"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="priority"/>
|
||||
<field name="planned_revenue" sum="Planned revenue"/>
|
||||
<field name="planned_cost" sum="Planned costs"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_closed_crm_case_dashboard" model="ir.actions.act_window">
|
||||
<field name="name">Closed CRM Cases Wtihin Past 15 Days</field>
|
||||
<field name="res_model">report.crm.case.service.dashboard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="board_view_crm_case_done_dashboard_tree"/>
|
||||
<field name="domain">[('state','=','done')]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_open_crm_case_dashboard" model="ir.actions.act_window">
|
||||
<field name="name">Open CRM Cases Wtihin Past 15 Days</field>
|
||||
<field name="res_model">report.crm.case.service.dashboard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="board_view_crm_case_open_dashboard_tree"/>
|
||||
<field name="domain">[('state','=','open')]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -110,5 +110,67 @@ class report_sale_order_category(osv.osv):
|
||||
""")
|
||||
report_sale_order_category()
|
||||
|
||||
class report_turnover_per_month(osv.osv):
|
||||
_name = "report.turnover.per.month"
|
||||
_description = "Turnover Per Month"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.date('Month', readonly=True),
|
||||
'turnover': fields.float('Total Turnover', readonly=True),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view report_turnover_per_month as (
|
||||
select min(am.id) as id, sum(credit) as turnover,to_char(am.date, 'YYYY-MM-01') as name from account_move_line am
|
||||
where am.account_id in (select distinct(account_id) from account_invoice_line)
|
||||
and
|
||||
am.move_id in(select distinct(aw.move_id) from account_invoice aw,account_invoice_line l where l.invoice_id=aw.id)
|
||||
group by to_char(am.date, 'YYYY-MM-01')
|
||||
)
|
||||
""")
|
||||
report_turnover_per_month()
|
||||
|
||||
class report_sale_order_created(osv.osv):
|
||||
_name = "report.sale.order.created"
|
||||
_description = "Report of Creaed Sale Order"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date_order':fields.date('Date Ordered', readonly=True),
|
||||
'name': fields.char('Order Reference', size=64, readonly=True),
|
||||
'partner_id':fields.many2one('res.partner', 'Customer', readonly=True),
|
||||
'partner_shipping_id':fields.many2one('res.partner.address', 'Shipping Address', readonly=True),
|
||||
'amount_untaxed': fields.float('Untaxed Amount', readonly=True),
|
||||
'state': fields.selection([
|
||||
('draft','Quotation'),
|
||||
('waiting_date','Waiting Schedule'),
|
||||
('manual','Manual In Progress'),
|
||||
('progress','In Progress'),
|
||||
('shipping_except','Shipping Exception'),
|
||||
('invoice_except','Invoice Exception'),
|
||||
('done','Done'),
|
||||
('cancel','Cancel')
|
||||
], 'Order State', readonly=True),
|
||||
'create_date' : fields.datetime('Create Date', readolnly=True)
|
||||
}
|
||||
_order = 'create_date'
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""create or replace view report_sale_order_created as (
|
||||
select
|
||||
sale.id as id, sale.date_order as date_order, sale.name as name,
|
||||
sale.partner_id as partner_id,
|
||||
sale.partner_shipping_id as partner_shipping_id,
|
||||
sale.amount_untaxed as amount_untaxed, sale.state as state,
|
||||
sale.create_date as create_date
|
||||
from
|
||||
sale_order sale
|
||||
where
|
||||
(to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') < CURRENT_DATE)
|
||||
AND
|
||||
(to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') >= (CURRENT_DATE-15))
|
||||
)""")
|
||||
report_sale_order_created()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -171,6 +171,64 @@
|
||||
<field name="domain">[('state','<>','done')]</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_turnover_month_tree">
|
||||
<field name="name">report.turnover.per.month.tree</field>
|
||||
<field name="model">report.turnover.per.month</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Turnover Per Month">
|
||||
<field name="name" select="1"/>
|
||||
<field name="turnover" select="2"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_turnover_month_graph" model="ir.ui.view">
|
||||
<field name="name">report.turnover.per.month.graph</field>
|
||||
<field name="model">report.turnover.per.month</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Turnover Per Month" type="bar">
|
||||
<field name="name" />
|
||||
<field name="turnover" />
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_turnover_month_tree">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="name">Turnover Per Month</field>
|
||||
<field name="res_model">report.turnover.per.month</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="view_id" ref="view_turnover_month_tree"/>
|
||||
</record>
|
||||
|
||||
<!-- Created Sale orders for random activities dashboard -->
|
||||
|
||||
<record id="board_view_created_sale_order" model="ir.ui.view">
|
||||
<field name="name">report.sale.order.created.tree</field>
|
||||
<field name="model">report.sale.order.created</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Created Sales orders">
|
||||
<field name="create_date"/>
|
||||
<field name="date_order"/>
|
||||
<field name="name" string="Reference"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="partner_shipping_id"/>
|
||||
<field name="amount_untaxed"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_created_sale_order_dashboard" model="ir.actions.act_window">
|
||||
<field name="name">Created Sale Orders</field>
|
||||
<field name="res_model">report.sale.order.created</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="board_view_created_sale_order"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -58,7 +58,81 @@ class report_task_user_pipeline_open (osv.osv):
|
||||
''')
|
||||
report_task_user_pipeline_open()
|
||||
|
||||
class report_closed_task(osv.osv):
|
||||
_name = "report.closed.task"
|
||||
_description = "Closed Task Report"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'sequence': fields.integer('Sequence', readonly=True),
|
||||
'name': fields.char('Task summary', size=128, readonly=True),
|
||||
'project_id': fields.many2one('project.project', 'Project', readonly=True),
|
||||
'user_id': fields.many2one('res.users', 'Assigned to', readonly=True),
|
||||
'date_deadline': fields.datetime('Deadline', readonly=True),
|
||||
'planned_hours': fields.float('Planned Hours', readonly=True),
|
||||
'delay_hours': fields.float('Delay Hours', readonly=True),
|
||||
'progress': fields.float('Progress (%)', readonly=True),
|
||||
'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance', readonly=True),
|
||||
'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'Status', readonly=True),
|
||||
'remaining_hours': fields.float('Remaining Hours', readonly=True),
|
||||
'date_close' : fields.datetime('Date Closed', readonly=True)
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute('''
|
||||
create or replace view report_closed_task as (
|
||||
select
|
||||
tsk.id as id, tsk.sequence as sequence, tsk.name as name,
|
||||
tsk.project_id as project_id, tsk.user_id as user_id,
|
||||
tsk.date_deadline as date_deadline, tsk.planned_hours as planned_hours,
|
||||
tsk.delay_hours as delay_hours, tsk.progress as progress,
|
||||
tsk.priority as priority, tsk.state as state,
|
||||
tsk.remaining_hours as remaining_hours, tsk.date_close as date_close
|
||||
from
|
||||
project_task tsk
|
||||
where
|
||||
(tsk.date_close < CURRENT_DATE AND tsk.date_close >= (CURRENT_DATE-15))
|
||||
)
|
||||
''')
|
||||
report_closed_task()
|
||||
|
||||
#class report_timesheet_task(osv.osv):
|
||||
# _name = "report.timesheet.task"
|
||||
# _description = "Report on Timesheets and Tasks per User Per Month"
|
||||
# _auto = False
|
||||
#
|
||||
# def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
|
||||
# result = {}
|
||||
#
|
||||
# for record in self.browse(cr, uid, ids, context):
|
||||
# last_date = mx.DateTime.strptime(record.month, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
|
||||
# obj=self.pool.get('hr_timesheet_sheet.sheet')
|
||||
# sheet_ids = obj.search(cr,uid,[('user_id','=',record.user_id.id),('date_current','>=',record.month),('date_current','<=',last_date.strftime('%Y-%m-%d'))])
|
||||
# data_days = obj.read(cr,uid,sheet_ids,['total_attendance_day','date_current','user_id'])
|
||||
# total = 0.0
|
||||
# for day_attendance in data_days:
|
||||
# total += day_attendance['total_attendance_day']
|
||||
# result[record.id] = total
|
||||
#
|
||||
# return result
|
||||
#
|
||||
# _columns = {
|
||||
# 'month': fields.date('Month', required=True,readonly=True),
|
||||
# 'user_id': fields.many2one('res.users', 'User' ,readonly=True, required=True),
|
||||
# 'timesheet_hrs': fields.function(get_hrs_timesheet,method=True, string="Timesheet Hrs" ),
|
||||
# 'task_hrs': fields.float('Task Hrs', readonly=True, required=True),
|
||||
# }
|
||||
#
|
||||
#
|
||||
# def init(self, cr):
|
||||
# cr.execute("""create or replace view report_timesheet_task as (
|
||||
# select min(p.id) as id, to_char(p.date, 'YYYY-MM-01') as month, min(r.id) as user_id, sum(p.hours) as task_hrs,0.0 as timesheet_hrs
|
||||
# from project_task_work p,res_users r
|
||||
# where (r.id=p.user_id)
|
||||
# group by to_char(p.date, 'YYYY-MM-01'))""")
|
||||
#
|
||||
#
|
||||
#
|
||||
#report_timesheet_task()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -58,5 +58,37 @@
|
||||
<menuitem id="next_id_57" name="Reporting" parent="project.menu_main" sequence="50"/>
|
||||
<menuitem id="next_id_58" name="All Months" parent="next_id_57"/><menuitem action="action_project_task" id="menu_project_task_user_tree" parent="next_id_58"/>
|
||||
|
||||
<!-- Closed Task in Random Acitivities dashboard -->
|
||||
|
||||
<record id="view_task_closed_board_tree" model="ir.ui.view">
|
||||
<field name="name">report.closed.task.tree</field>
|
||||
<field name="model">report.closed.task</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Closed Tasks">
|
||||
<field name="date_close" />
|
||||
<field name="sequence"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="project_id" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="date_deadline"/>
|
||||
<field name="planned_hours" sum="Planned" widget="float_time"/>
|
||||
<field name="delay_hours" sum="Delay" widget="float_time"/>
|
||||
<field name="progress" widget="progressbar"/>
|
||||
<field name="priority"/>
|
||||
<field name="state"/>
|
||||
<field name="remaining_hours" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_closed_task_board" model="ir.actions.act_window">
|
||||
<field name="name">Task Closed Within Past 15 Days</field>
|
||||
<field name="res_model">report.closed.task</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_task_closed_board_tree"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -113,7 +113,6 @@ class report_timesheet_account_date(osv.osv):
|
||||
report_timesheet_account_date()
|
||||
|
||||
|
||||
|
||||
class report_timesheet_invoice(osv.osv):
|
||||
_name = "report_timesheet.invoice"
|
||||
_description = "Costs to invoice"
|
||||
@@ -159,40 +158,83 @@ class report_random_timsheet(osv.osv):
|
||||
_auto = False
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'date': fields.date('Date', readonly=True),
|
||||
'analytic_account_id' : fields.many2one('account.analytic.account','Analytic Account', readonly=True),
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'quantity' : fields.float('Quantity', readonly=True),
|
||||
'product_id' : fields.many2one('product.product','Product', readonly=True),
|
||||
'amount' : fields.float('Amount', readonly=True),
|
||||
'uom_id' : fields.many2one('product.uom','UOM', readonly=True)
|
||||
}
|
||||
'date': fields.date('Date', readonly=True),
|
||||
'user_id' : fields.many2one('res.users', 'User', readonly=True)
|
||||
}
|
||||
_order = "date desc"
|
||||
|
||||
def init(self, cr):
|
||||
def __init__(self, pool, cr):
|
||||
super(report_random_timsheet, self).__init__(pool, cr)
|
||||
self.called = False
|
||||
|
||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
||||
""" To call the init() method timely
|
||||
"""
|
||||
if not self.called:
|
||||
self.init(cr, user)
|
||||
self.called = True # To make sure that init doesn't get called multiple times
|
||||
|
||||
res = super(report_random_timsheet, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
|
||||
return res
|
||||
|
||||
def init(self, cr, uid=1):
|
||||
|
||||
cr.execute("""create or replace view report_random_timesheet as (
|
||||
|
||||
select line.id as id, line.name as name, line.date as date,
|
||||
act.id as analytic_account_id, line.unit_amount as quantity,
|
||||
prod.id as product_id, line.amount as amount, uom_uom.id as uom_id
|
||||
|
||||
from account_analytic_line line
|
||||
|
||||
left join account_analytic_account act on (line.account_id = act.id)
|
||||
left join hr_employee emp on (line.user_id = emp.id)
|
||||
left join hr_department dept on (dept.manager_id = emp.parent_id)
|
||||
left join hr_department_user_rel dept_user on (line.user_id = dept_user.user_id)
|
||||
left join product_template prod on (line.product_id = prod.id)
|
||||
left join product_uom uom_uom on (line.product_uom_id = uom_uom.id)
|
||||
|
||||
where (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-3))
|
||||
|
||||
select
|
||||
line.id as id, line.account_id as analytic_account_id, line.name as name,
|
||||
line.unit_amount as quantity, line.date as date, line.user_id as user_id
|
||||
from
|
||||
account_analytic_line line, hr_department dept,hr_department_user_rel dept_user
|
||||
where
|
||||
(dept.id = dept_user.department_id AND dept_user.user_id=line.user_id AND line.user_id is not null)
|
||||
AND (dept.manager_id = """ + str(uid) + """ )
|
||||
AND (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-3))
|
||||
ORDER BY line.name LIMIT 10
|
||||
)
|
||||
""")
|
||||
""" )
|
||||
|
||||
report_random_timsheet()
|
||||
|
||||
class random_timesheet_lines(osv.osv):
|
||||
_name = "random.timesheet.lines"
|
||||
_description = "Random Timesheet Lines"
|
||||
_auto = False
|
||||
|
||||
_columns = {
|
||||
'date': fields.date('Date', readonly=True),
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'user_id' : fields.many2one('res.users', 'User', readonly=True),
|
||||
'quantity' : fields.float('Quantity', readonly=True),
|
||||
'product_id' : fields.many2one('product.product', 'Product', readonly=True),
|
||||
'analytic_account_id' : fields.many2one('account.analytic.account','Analytic Account', readonly=True),
|
||||
'uom_id' : fields.many2one('product.uom', 'UoM', readonly=True),
|
||||
'amount' : fields.float('Amount', readonly=True),
|
||||
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Invoicing', readonly=True),
|
||||
'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True)
|
||||
}
|
||||
|
||||
_order = "date desc"
|
||||
|
||||
def init(self, cr):
|
||||
|
||||
cr.execute("""create or replace view random_timesheet_lines as (
|
||||
select
|
||||
line.id as id, line.date as date, line.name as name, line.unit_amount as quantity,
|
||||
line.product_id as product_id, line.account_id as analytic_account_id,
|
||||
line.product_uom_id as uom_id, line.amount as amount, line.to_invoice as to_invoice,
|
||||
line.general_account_id as general_account_id, line.user_id as user_id
|
||||
from
|
||||
account_analytic_line line
|
||||
where
|
||||
(line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-15))
|
||||
)
|
||||
""" )
|
||||
|
||||
random_timesheet_lines()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -287,13 +287,10 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Random Timesheets">
|
||||
<field name="analytic_account_id" />
|
||||
<field name="name" />
|
||||
<field name="quantity" />
|
||||
<field name="product_id" />
|
||||
<field name="amount" />
|
||||
<field name="uom_id" />
|
||||
<field name="date" />
|
||||
<field name="analytic_account_id" select="1"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="quantity" select="2" />
|
||||
<field name="date" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -306,5 +303,37 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_random_timesheet_tree"/>
|
||||
</record>
|
||||
|
||||
<!-- Random Timesheet Lines of random activities -->
|
||||
|
||||
<record model="ir.ui.view" id="view_random_timesheet_lines_tree">
|
||||
<field name="name">random.timesheet.lines.tree</field>
|
||||
<field name="model">random.timesheet.lines</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Random Timesheets Lines">
|
||||
<field name="date" select="1"/>
|
||||
<field name="user_id" />
|
||||
<field name="name" select="1"/>
|
||||
<field name="quantity" />
|
||||
<field name="product_id" select="1"/>
|
||||
<field name="analytic_account_id" select="1"/>
|
||||
<field name="uom_id" />
|
||||
<field name="amount" />
|
||||
<field name="to_invoice" select="1"/>
|
||||
<field name="general_account_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_random_timesheet_lines_board">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="name">Random Timesheet Lines</field>
|
||||
<field name="res_model">random.timesheet.lines</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_random_timesheet_lines_tree"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -757,6 +757,14 @@ stock_picking()
|
||||
|
||||
class stock_production_lot(osv.osv):
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(stock_production_lot, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
|
||||
if res:
|
||||
return [k for k,v in self._get_stock(cr, uid, res, 'stock_available', None, context).items() if v]
|
||||
return res
|
||||
|
||||
def name_get(self, cr, uid, ids, context={}):
|
||||
if not ids:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user