[IMP]Improve code and remove extra views
bzr revid: dbr@tinyerp.com-20130226095232-yxjjlsqzj9bvdbg3
This commit is contained in:
parent
5576777efa
commit
d9d7c96218
|
@ -85,15 +85,12 @@ class account_analytic_invoice_line(osv.osv):
|
|||
'price_unit': fields.float('Unit Price'),
|
||||
'price_subtotal': fields.function(_amount_line, string='Amount', type="float",
|
||||
digits_compute= dp.get_precision('Account')),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'tax_ids':fields.function(_get_tax_lines, type='many2many', relation='account.tax', string='Taxes'),
|
||||
'invoice_id': fields.many2one('account.invoice', 'Invoice Reference', ondelete='cascade', select=True),
|
||||
'invoiced': fields.boolean('Invoiced')
|
||||
}
|
||||
_order = 'name desc'
|
||||
|
||||
_defaults = {
|
||||
'invoiced': False,
|
||||
'uom_id' : _get_uom_id,
|
||||
'quantity' : 1,
|
||||
'price_unit': 0.0,
|
||||
|
@ -103,15 +100,16 @@ class account_analytic_invoice_line(osv.osv):
|
|||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', partner_id=False, price_unit=False, currency_id=False, company_id=None, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
|
||||
company_id = company_id or False
|
||||
context.update({'company_id': company_id, 'force_company': company_id})
|
||||
|
||||
if not product:
|
||||
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
|
||||
if not partner_id:
|
||||
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a Customer !") )
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
|
||||
fpos_obj = self.pool.get('account.fiscal.position')
|
||||
fpos = False
|
||||
|
||||
if part.lang:
|
||||
context.update({'lang': part.lang})
|
||||
|
@ -121,15 +119,11 @@ class account_analytic_invoice_line(osv.osv):
|
|||
a = res.property_account_income.id
|
||||
if not a:
|
||||
a = res.categ_id.property_account_income_categ.id
|
||||
a = fpos_obj.map_account(cr, uid, fpos, a)
|
||||
if a:
|
||||
result['account_id'] = a
|
||||
|
||||
taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False)
|
||||
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
|
||||
result.update( {'price_unit': res.list_price or res.standard_price,'tax_ids': tax_id} )
|
||||
result['name'] = res.partner_ref
|
||||
result['uom_id'] = uom_id or res.uom_id.id
|
||||
result.update( {'name':res.partner_ref,'uom_id': uom_id or res.uom_id.id, 'price_unit': res.list_price or res.standard_price,'tax_ids': [x.id for x in taxes]} )
|
||||
if res.description:
|
||||
result['name'] += '\n'+res.description
|
||||
|
||||
|
@ -144,9 +138,9 @@ class account_analytic_invoice_line(osv.osv):
|
|||
new_price = res_final['value']['price_unit'] * currency.rate
|
||||
res_final['value']['price_unit'] = new_price
|
||||
|
||||
if result['uom_id'] and result['uom_id'] != res.uom_id.id:
|
||||
selected_uom = self.pool.get('product.uom').browse(cr, uid, result['uom_id'], context=context)
|
||||
new_price = self.pool.get('product.uom')._compute_price(cr, uid, res.uom_id.id, res_final['value']['price_unit'], result['uom_id'])
|
||||
if result['uom_id'] != res.uom_id.id:
|
||||
selected_uom = uom_obj.browse(cr, uid, result['uom_id'], context=context)
|
||||
new_price = uom_obj._compute_price(cr, uid, res.uom_id.id, res_final['value']['price_unit'], result['uom_id'])
|
||||
res_final['value']['price_unit'] = new_price
|
||||
return res_final
|
||||
|
||||
|
@ -705,16 +699,23 @@ class account_analytic_account(osv.osv):
|
|||
res['value']['pricelist_id'] = template.pricelist_id.id
|
||||
return res
|
||||
|
||||
def onchange_next_date(self, cr, uid, ids, next_date,context=None):
|
||||
value = {}
|
||||
current_date = time.strftime('%Y-%m-%d')
|
||||
if next_date and next_date < current_date:
|
||||
value = {'value':{'next_date': self.browse(cr, uid,ids[0]).next_date}}
|
||||
raise osv.except_osv(_('Warning!'), _("Define Next Date Greater or Same as Current Date."))
|
||||
return {'value':value}
|
||||
|
||||
def onchange_recurring_invoices(self, cr, uid, ids, recurring_invoices, date_start=False, context=None):
|
||||
result = {}
|
||||
if ids:
|
||||
if date_start and recurring_invoices == True:
|
||||
result = {'value': {
|
||||
'next_date': date_start,
|
||||
'rrule_type':'monthly'
|
||||
}
|
||||
value = {}
|
||||
if ids and date_start and recurring_invoices == True:
|
||||
value = {'value': {
|
||||
'next_date': date_start,
|
||||
'rrule_type':'monthly'
|
||||
}
|
||||
return result
|
||||
}
|
||||
return {'value':value}
|
||||
|
||||
def cron_account_analytic_account(self, cr, ids, uid, context=None):
|
||||
if context is None:
|
||||
|
|
|
@ -2,75 +2,6 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_analytic_invoice_line_tree" model="ir.ui.view">
|
||||
<field name="name">account.analytic.invoice.line.tree</field>
|
||||
<field name="model">account.analytic.invoice.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Account Analytic Line">
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="tax_ids"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="price_subtotal"/>
|
||||
<field name="invoiced"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_analytic_invoice_line_form" model="ir.ui.view">
|
||||
<field name="name">account.analytic.invoice.line.form</field>
|
||||
<field name="model">account.analytic.invoice.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Account Virtual Invoice" version="7.0">
|
||||
<sheet string="Account Virtual Invoice">
|
||||
<table class="oe_form_analytic_account">
|
||||
<tr>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="Product"/></th>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="Description"/></th>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="Quantity"/></th>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="UOM"/></th>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="Unit Price"/></th>
|
||||
<th class="oe_timesheet_grey" width="100px"><label string="Sub total"/></th>
|
||||
<th width="30px"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px">
|
||||
<field name="product_id" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<field name="name" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<field name="quantity" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<field name="uom_id" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<field name="price_unit" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<field name="price_subtotal" class="oe_inline"/>
|
||||
</td>
|
||||
<td width="30px"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_analytic_invoice_line" model="ir.actions.act_window">
|
||||
<field name="name">Account Virtual Invoice</field>
|
||||
<field name="res_model">account.analytic.invoice.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Analytic Account form
|
||||
-->
|
||||
|
@ -222,7 +153,7 @@
|
|||
<field name="rrule_type" class="oe_inline"/>
|
||||
</div>
|
||||
<p colspan="2" >
|
||||
Following Invoice will be generated on <field name="next_date" class="oe_inline"/>.
|
||||
Following Invoice will be generated on <field name="next_date" on_change="onchange_next_date(next_date)" class="oe_inline"/>.
|
||||
</p>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('recurring_invoices','=',False)]}">
|
||||
|
@ -416,8 +347,5 @@
|
|||
</field>
|
||||
</record>
|
||||
<menuitem action="template_of_contract_action" id="menu_template_of_contract_action" parent="base.menu_base_config"/>
|
||||
<menuitem action="action_account_analytic_invoice_line"
|
||||
id="menu_action_account_analytic_invoice_line"
|
||||
parent="menu_template_of_contract_action" sequence="4"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue