[FIX] account_analytic_analysis, analytic, hr_timesheet: do not override existing data of analytic account on template on_change
bzr revid: dle@openerp.com-20140401123657-ozh4ycx36jojpg51
This commit is contained in:
parent
a325b746e2
commit
2695cacea4
|
@ -543,33 +543,40 @@ class account_analytic_account(osv.osv):
|
||||||
'nodestroy': True,
|
'nodestroy': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_change_template(self, cr, uid, ids, template_id, context=None):
|
def on_change_template(self, cr, uid, ids, template_id, date_start=False, fix_price_invoices=False, invoice_on_timesheets=False, recurring_invoices=False, context=None):
|
||||||
if not template_id:
|
if not template_id:
|
||||||
return {}
|
return {}
|
||||||
obj_analytic_line = self.pool.get('account.analytic.invoice.line')
|
obj_analytic_line = self.pool.get('account.analytic.invoice.line')
|
||||||
res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
|
res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context)
|
||||||
|
|
||||||
template = self.browse(cr, uid, template_id, context=context)
|
template = self.browse(cr, uid, template_id, context=context)
|
||||||
invoice_line_ids = []
|
|
||||||
for x in template.recurring_invoice_line_ids:
|
if not fix_price_invoices:
|
||||||
invoice_line_ids.append((0, 0, {
|
res['value']['fix_price_invoices'] = template.fix_price_invoices
|
||||||
'product_id': x.product_id.id,
|
res['value']['amount_max'] = template.amount_max
|
||||||
'uom_id': x.uom_id.id,
|
if not invoice_on_timesheets:
|
||||||
'name': x.name,
|
res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets
|
||||||
'quantity': x.quantity,
|
res['value']['hours_qtt_est'] = template.hours_qtt_est
|
||||||
'price_unit': x.price_unit,
|
|
||||||
'analytic_account_id': x.analytic_account_id and x.analytic_account_id.id or False,
|
if template.to_invoice.id:
|
||||||
}))
|
res['value']['to_invoice'] = template.to_invoice.id
|
||||||
res['value']['fix_price_invoices'] = template.fix_price_invoices
|
if template.pricelist_id.id:
|
||||||
res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets
|
res['value']['pricelist_id'] = template.pricelist_id.id
|
||||||
res['value']['hours_qtt_est'] = template.hours_qtt_est
|
if not recurring_invoices:
|
||||||
res['value']['amount_max'] = template.amount_max
|
invoice_line_ids = []
|
||||||
res['value']['to_invoice'] = template.to_invoice.id
|
for x in template.recurring_invoice_line_ids:
|
||||||
res['value']['pricelist_id'] = template.pricelist_id.id
|
invoice_line_ids.append((0, 0, {
|
||||||
res['value']['recurring_invoices'] = template.recurring_invoices
|
'product_id': x.product_id.id,
|
||||||
res['value']['recurring_interval'] = template.recurring_interval
|
'uom_id': x.uom_id.id,
|
||||||
res['value']['recurring_rule_type'] = template.recurring_rule_type
|
'name': x.name,
|
||||||
res['value']['recurring_invoice_line_ids'] = invoice_line_ids
|
'quantity': x.quantity,
|
||||||
|
'price_unit': x.price_unit,
|
||||||
|
'analytic_account_id': x.analytic_account_id and x.analytic_account_id.id or False,
|
||||||
|
}))
|
||||||
|
res['value']['recurring_invoices'] = template.recurring_invoices
|
||||||
|
res['value']['recurring_interval'] = template.recurring_interval
|
||||||
|
res['value']['recurring_rule_type'] = template.recurring_rule_type
|
||||||
|
res['value']['recurring_invoice_line_ids'] = invoice_line_ids
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def onchange_recurring_invoices(self, cr, uid, ids, recurring_invoices, date_start=False, context=None):
|
def onchange_recurring_invoices(self, cr, uid, ids, recurring_invoices, date_start=False, context=None):
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
<field name="partner_id" position="attributes">
|
<field name="partner_id" position="attributes">
|
||||||
<attribute name="attrs">{'required': [('type','=','contract'),'|','|',('fix_price_invoices','=',True), ('invoice_on_timesheets', '=', True), ('recurring_invoices', '=', True)]}</attribute>
|
<attribute name="attrs">{'required': [('type','=','contract'),'|','|',('fix_price_invoices','=',True), ('invoice_on_timesheets', '=', True), ('recurring_invoices', '=', True)]}</attribute>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="template_id" position="attributes">
|
||||||
|
<attribute name="on_change">on_change_template(template_id, date_start, fix_price_invoices, invoice_on_timesheets, recurring_invoices)</attribute>
|
||||||
|
</field>
|
||||||
<xpath expr='//group[@name="invoice_on_timesheets"]' position="replace">
|
<xpath expr='//group[@name="invoice_on_timesheets"]' position="replace">
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr='//separator[@name="description"]' position='before'>
|
<xpath expr='//separator[@name="description"]' position='before'>
|
||||||
|
|
|
@ -203,7 +203,7 @@ class account_analytic_account(osv.osv):
|
||||||
}, string='Currency', type='many2one', relation='res.currency'),
|
}, string='Currency', type='many2one', relation='res.currency'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_change_template(self, cr, uid, ids, template_id, context=None):
|
def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None):
|
||||||
if not template_id:
|
if not template_id:
|
||||||
return {}
|
return {}
|
||||||
res = {'value':{}}
|
res = {'value':{}}
|
||||||
|
@ -213,7 +213,8 @@ class account_analytic_account(osv.osv):
|
||||||
to_dt = datetime.strptime(template.date, tools.DEFAULT_SERVER_DATE_FORMAT)
|
to_dt = datetime.strptime(template.date, tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||||
timedelta = to_dt - from_dt
|
timedelta = to_dt - from_dt
|
||||||
res['value']['date'] = datetime.strftime(datetime.now() + timedelta, tools.DEFAULT_SERVER_DATE_FORMAT)
|
res['value']['date'] = datetime.strftime(datetime.now() + timedelta, tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||||
res['value']['date_start'] = fields.date.today()
|
if not date_start:
|
||||||
|
res['value']['date_start'] = fields.date.today()
|
||||||
res['value']['quantity_max'] = template.quantity_max
|
res['value']['quantity_max'] = template.quantity_max
|
||||||
res['value']['parent_id'] = template.parent_id and template.parent_id.id or False
|
res['value']['parent_id'] = template.parent_id and template.parent_id.id or False
|
||||||
res['value']['description'] = template.description
|
res['value']['description'] = template.description
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="type" invisible="context.get('default_type', False)"/>
|
<field name="type" invisible="context.get('default_type', False)"/>
|
||||||
<field name="template_id" on_change="on_change_template(template_id,context)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
|
<field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/>
|
<field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/>
|
||||||
<field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/>
|
<field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/>
|
||||||
|
|
|
@ -115,8 +115,8 @@ class account_analytic_account(osv.osv):
|
||||||
digits_compute=dp.get_precision('Account')),
|
digits_compute=dp.get_precision('Account')),
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_change_template(self, cr, uid, id, template_id, context=None):
|
def on_change_template(self, cr, uid, id, template_id, date_start=False, context=None):
|
||||||
res = super(account_analytic_account, self).on_change_template(cr, uid, id, template_id, context=context)
|
res = super(account_analytic_account, self).on_change_template(cr, uid, id, template_id, date_start=date_start, context=context)
|
||||||
if template_id and 'value' in res:
|
if template_id and 'value' in res:
|
||||||
template = self.browse(cr, uid, template_id, context=context)
|
template = self.browse(cr, uid, template_id, context=context)
|
||||||
res['value']['charge_expenses'] = template.charge_expenses
|
res['value']['charge_expenses'] = template.charge_expenses
|
||||||
|
|
|
@ -207,8 +207,8 @@ class account_analytic_account(osv.osv):
|
||||||
'use_timesheets': fields.boolean('Timesheets', help="Check this field if this project manages timesheets"),
|
'use_timesheets': fields.boolean('Timesheets', help="Check this field if this project manages timesheets"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_change_template(self, cr, uid, ids, template_id, context=None):
|
def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None):
|
||||||
res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
|
res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context)
|
||||||
if template_id and 'value' in res:
|
if template_id and 'value' in res:
|
||||||
template = self.browse(cr, uid, template_id, context=context)
|
template = self.browse(cr, uid, template_id, context=context)
|
||||||
res['value']['use_timesheets'] = template.use_timesheets
|
res['value']['use_timesheets'] = template.use_timesheets
|
||||||
|
|
Loading…
Reference in New Issue