[FIX] project, hr_timesheet_invoice, project_timesheet: fixed flow to invoice on timesheets + some code cleaning

bzr revid: qdp-launchpad@openerp.com-20120618115634-eos7eq6gdvxqoyn6
This commit is contained in:
Quentin (OpenERP) 2012-06-18 13:56:34 +02:00
parent a1467226e9
commit c0f54153c7
5 changed files with 17 additions and 7 deletions

View File

@ -115,10 +115,6 @@ class account_analytic_line(osv.osv):
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Type of Invoicing', help="It allows to set the discount while making invoice"),
}
def unlink(self, cursor, user, ids, context=None):
return super(account_analytic_line,self).unlink(cursor, user, ids,
context=context)
def write(self, cr, uid, ids, vals, context=None):
self._check_inv(cr, uid, ids, vals)
return super(account_analytic_line,self).write(cr, uid, ids, vals,

View File

@ -89,7 +89,7 @@
<field name="inherit_id" ref="account.view_account_analytic_line_filter"/>
<field name="arch" type="xml">
<field name="date" position="before">
<filter name="to_invoice" string="To Invoice" context="{'to_invoice': 1}" domain="[('invoice_id','=',False), ('to_invoice','&lt;&gt;',False)]" icon="terp-dolar"/>
<filter name="to_invoice" string="To Invoice" context="{'to_invoice': 1}" domain="[('move_id','=',False), ('to_invoice','&lt;&gt;',False)]" icon="terp-dolar"/>
<filter name="invoiced" string="Invoiced" domain="[('invoice_id','!=',False), ('to_invoice','&lt;&gt;',False)]" icon="terp-dolar"/>
<separator orientation="vertical"/>
</field>

View File

@ -14,6 +14,7 @@
</header>
<notebook>
<page string="Billing Data">
<group>
<group string="Do you want to show details of work in invoice?">
<field name="date"/>
<field name="time"/>
@ -23,6 +24,11 @@
<group string="Force to use a specific product">
<field name="product"/>
</group>
<group colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel' colspan="1"/>
<button name="do_create" string="Create Invoices" colspan="1" type="object" icon="terp-gtk-go-back-rtl"/>
</group>
</group>
</page>
</notebook>
</form>

View File

@ -1234,7 +1234,7 @@ class account_analytic_account(osv.osv):
This function is called at the time of analytic account creation and is used to create a project automatically linked to it if the conditions are meet.
'''
project_pool = self.pool.get('project.project')
project_id = project_pool.search(cr, uid, [('name','=',vals.get('name'))])
project_id = project_pool.search(cr, uid, [('analytic_account_id','=', analytic_account_id)])
if not project_id and self._trigger_project_creation(cr, uid, vals, context=context):
project_values = {
'name': vals.get('name'),
@ -1252,6 +1252,14 @@ class account_analytic_account(osv.osv):
self.project_create(cr, uid, analytic_account_id, vals, context=context)
return analytic_account_id
def write(self, cr, uid, ids, vals, context=None):
name = vals.get('name')
for account in self.browse(cr, uid, ids, context=context):
if not name:
vals['name'] = account.name
self.project_create(cr, uid, account.id, vals, context=context)
return super(account_analytic_account, self).write(cr, uid, ids, vals, context=context)
def unlink(self, cr, uid, ids, *args, **kwargs):
project_obj = self.pool.get('project.project')
analytic_ids = project_obj.search(cr, uid, [('analytic_account_id','in',ids)])

View File

@ -94,7 +94,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="context">{'search_default_to_invoice': 1}</field>
<field name="view_id" ref="view_account_analytic_line_tree_inherit_account_id"/>
<field name="help">You will find here all works made on tasks that you can invoice.
In order to invoice the time spent on a project, you must define the