Browse Source

[FIX] fixed conflict with latest version + modified store conditions for related fields

pull/2/head
Matthieu Dietrich 11 years ago
parent
commit
82482c73ba
  1. 1
      analytic_hours_block/__init__.py
  2. 5
      analytic_hours_block/__openerp__.py
  3. 84
      analytic_hours_block/hours_block.py
  4. 1
      analytic_hours_block/hours_block_menu.xml
  5. 5
      analytic_hours_block/hours_block_view.xml
  6. 33
      analytic_hours_block/project.py
  7. 19
      analytic_hours_block/project_view.xml

1
analytic_hours_block/__init__.py

@ -20,3 +20,4 @@
############################################################################## ##############################################################################
import hours_block import hours_block
import report import report
import project

5
analytic_hours_block/__openerp__.py

@ -40,13 +40,16 @@ you can track and follow how much has been used.
"depends": [ "depends": [
"account", "account",
"hr_timesheet_invoice", "hr_timesheet_invoice",
"analytic"
"analytic",
"project",
], ],
"data": [ "data": [
"report.xml", "report.xml",
"hours_block_view.xml", "hours_block_view.xml",
"hours_block_data.xml", "hours_block_data.xml",
"hours_block_menu.xml", "hours_block_menu.xml",
"project_view.xml",
"report.xml",
"security/hours_block_security.xml", "security/hours_block_security.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
], ],

84
analytic_hours_block/hours_block.py

@ -267,74 +267,130 @@ class AccountHoursBlock(orm.Model):
'invoice_id', 'date_invoice', 'invoice_id', 'date_invoice',
type="date", type="date",
string="Invoice Date", string="Invoice Date",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['date_invoice'], 10),
},
readonly=True), readonly=True),
'user_id': fields.related( 'user_id': fields.related(
'invoice_id', 'user_id', 'invoice_id', 'user_id',
type="many2one", type="many2one",
relation="res.users", relation="res.users",
string="Salesman", string="Salesman",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['user_id'], 10),
},
readonly=True), readonly=True),
'partner_id': fields.related( 'partner_id': fields.related(
'invoice_id', 'partner_id', 'invoice_id', 'partner_id',
type="many2one", type="many2one",
relation="res.partner", relation="res.partner",
string="Partner", string="Partner",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['partner_id'], 10),
},
readonly=True), readonly=True),
'name': fields.related( 'name': fields.related(
'invoice_id', 'name', 'invoice_id', 'name',
type="char", type="char",
string="Description", string="Description",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['name'], 10),
},
readonly=True), readonly=True),
'number': fields.related( 'number': fields.related(
'invoice_id', 'number', 'invoice_id', 'number',
type="char", type="char",
string="Number", string="Number",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['number'], 10),
},
readonly=True), readonly=True),
'journal_id': fields.related( 'journal_id': fields.related(
'invoice_id', 'journal_id', 'invoice_id', 'journal_id',
type="many2one", type="many2one",
relation="account.journal", relation="account.journal",
string="Journal", string="Journal",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['journal_id'], 10),
},
readonly=True), readonly=True),
'period_id': fields.related( 'period_id': fields.related(
'invoice_id', 'period_id', 'invoice_id', 'period_id',
type="many2one", type="many2one",
relation="account.period", relation="account.period",
string="Period", string="Period",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['period_id'], 10),
},
readonly=True), readonly=True),
'company_id': fields.related( 'company_id': fields.related(
'invoice_id', 'company_id', 'invoice_id', 'company_id',
type="many2one", type="many2one",
relation="res.company", relation="res.company",
string="Company", string="Company",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['company_id'], 10),
},
readonly=True), readonly=True),
'currency_id': fields.related( 'currency_id': fields.related(
'invoice_id', 'currency_id', 'invoice_id', 'currency_id',
type="many2one", type="many2one",
relation="res.currency", relation="res.currency",
string="Currency", string="Currency",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['currency_id'], 10),
},
readonly=True), readonly=True),
'residual': fields.related( 'residual': fields.related(
'invoice_id', 'residual', 'invoice_id', 'residual',
type="float", type="float",
string="Residual", string="Residual",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['residual'], 10),
},
readonly=True), readonly=True),
'amount_total': fields.related( 'amount_total': fields.related(
'invoice_id', 'amount_total', 'invoice_id', 'amount_total',
type="float", type="float",
string="Total", string="Total",
store=True,
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['amount_total'], 10),
},
readonly=True), readonly=True),
'department_id': fields.related(
'invoice_id', 'department_id',
type='many2one',
relation='hr.department',
string='Department',
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['department_id'], 10),
},
readonly=True),
'state': fields.related( 'state': fields.related(
'invoice_id', 'state', 'invoice_id', 'state',
type='selection', type='selection',
@ -348,7 +404,11 @@ class AccountHoursBlock(orm.Model):
], ],
string='State', string='State',
readonly=True, readonly=True,
store=True),
store={
'account.hours.block': (lambda self, cr, uid, ids, c=None:
ids, ['invoice_id'], 10),
'account.invoice': (_get_invoice, ['state'], 10),
}),
} }

1
analytic_hours_block/hours_block_menu.xml

@ -6,6 +6,7 @@
Hours block menu Hours block menu
--> -->
<record model="ir.actions.act_window" id="action_all_block_hour"> <record model="ir.actions.act_window" id="action_all_block_hour">
<field name="context">{'search_default_running': 1, 'search_default_group_department_id': 1}</field>
<field name="name">Hours Blocks</field> <field name="name">Hours Blocks</field>
<field name="res_model">account.hours.block</field> <field name="res_model">account.hours.block</field>
<field name="view_type">form</field> <field name="view_type">form</field>

5
analytic_hours_block/hours_block_view.xml

@ -18,15 +18,18 @@
<separator orientation="vertical"/> <separator orientation="vertical"/>
<field name="number"/> <field name="number"/>
<field name="partner_id"/> <field name="partner_id"/>
<field name="department_id" string="Department"/>
<field name="user_id" select="1" widget="selection" string="Salesman"> <field name="user_id" select="1" widget="selection" string="Salesman">
<filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/> <filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/>
</field> </field>
<field name="company_id" widget="selection"/> <field name="company_id" widget="selection"/>
</group> </group>
<newline/> <newline/>
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/> <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Department" icon="terp-personal" domain="[]" context="{'group_by':'department_id'}"/>
<filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> <filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
</group> </group>
</search> </search>
@ -71,6 +74,7 @@
<field name="partner_id" groups="base.group_user"/> <field name="partner_id" groups="base.group_user"/>
<field name="user_id"/> <field name="user_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/> <field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="department_id" widget="selection"/>
<field name="journal_id" invisible="1"/> <field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1" groups="account.group_account_user"/> <field name="period_id" invisible="1" groups="account.group_account_user"/>
@ -108,6 +112,7 @@
<field name="journal_id" invisible="1"/> <field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1" groups="account.group_account_user"/> <field name="period_id" invisible="1" groups="account.group_account_user"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/> <field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="department_id" widget="selection"/>
<field name="user_id"/> <field name="user_id"/>
<field name="currency_id"/> <field name="currency_id"/>
<field name="residual" sum="Residual Amount"/> <field name="residual" sum="Residual Amount"/>

33
analytic_hours_block/project.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from osv import orm
from openerp.tools.translate import _
class project_project(orm.Model):
_inherit = 'project.project'
def hours_block_tree_view(self, cr, uid, ids, context):
invoice_line_obj = self.pool.get('account.invoice.line')
hours_block_obj = self.pool.get('account.hours.block')
project = self.browse(cr, uid , ids)[0]
invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)])
invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids)
invoice_ids = [x.invoice_id.id for x in invoice_lines]
res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)])
domain=False
if res_ids:
domain = [('id', 'in', res_ids)]
else:
raise orm.except_orm(_('Warning'), _("No Hours Block for this project"))
return {
'name': _('Hours Blocks'),
'domain': domain,
'res_model': 'account.hours.block',
'type': 'ir.actions.act_window',
'view_id': False,
'view_mode': 'tree,form',
'view_type': 'form',
'limit': 80,
'res_id' : res_ids or False,
}

19
analytic_hours_block/project_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record model="ir.ui.view" id="edit_project_hours_block_link">
<field name="name">project.project.form.hours.block.link</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//button[@name='attachment_tree_view']" position="after">
<button name="hours_block_tree_view" string="Hours Block" type="object"/>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save