Nimesh Contractor(Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-addons22-nco into lp:openobject-addons.
Requested reviews: OpenERP Core Team (openerp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons22-nco/+merge/134847 Hello, I have fix following Issue:- 1) Set the related Account/Contract Name on expense line. 2) Invoice amount problem in contract. 3) When invoicing several timesheets from the contracts, it create one line per product/invoicing all the timesheets related to this product. Thanks, NCO. -- https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons22-nco/+merge/134847 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-addons22-nco.
=== modified file 'account_analytic_analysis/account_analytic_analysis.py' --- account_analytic_analysis/account_analytic_analysis.py 2012-10-28 12:17:30 +0000 +++ account_analytic_analysis/account_analytic_analysis.py 2012-11-19 09:15:49 +0000 @@ -300,7 +300,7 @@ res[account.id] = 0.0 line_ids = lines_obj.search(cr, uid, [('account_id','=', account.id), ('invoice_id','!=',False), ('to_invoice','!=', False), ('journal_id.type', '=', 'general')], context=context) for line in lines_obj.browse(cr, uid, line_ids, context=context): - res[account.id] += line.invoice_id.amount_untaxed + res[account.id] = line.invoice_id.amount_untaxed return res def _remaining_ca_calc(self, cr, uid, ids, name, arg, context=None): === modified file 'analytic_contract_hr_expense/analytic_contract_hr_expense.py' --- analytic_contract_hr_expense/analytic_contract_hr_expense.py 2012-06-25 06:32:33 +0000 +++ analytic_contract_hr_expense/analytic_contract_hr_expense.py 2012-11-19 09:15:49 +0000 @@ -136,6 +136,7 @@ 'name': name, 'view_type': 'form', 'view_mode': 'tree,form', + 'context':{'analytic_account':ids[0]}, 'domain' : domain, 'res_model': 'hr.expense.expense', 'nodestroy': True, === modified file 'hr_expense/hr_expense_view.xml' --- hr_expense/hr_expense_view.xml 2012-11-15 12:38:51 +0000 +++ hr_expense/hr_expense_view.xml 2012-11-19 09:15:49 +0000 @@ -85,7 +85,7 @@ </group> <notebook> <page string="Description"> - <field name="line_ids" context="{'currency_id': currency_id}"> + <field name="line_ids" context="{'currency_id': currency_id, 'default_analytic_account': context.get('analytic_account')}"> <form string="Expense Lines" version="7.0"> <group> <group> === modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py' --- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-10-30 11:26:32 +0000 +++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-11-19 09:15:49 +0000 @@ -112,6 +112,7 @@ "AND id IN %s AND to_invoice IS NOT NULL " \ "GROUP BY product_id, user_id, to_invoice, product_uom_id, name", (account.id, tuple(ids),)) + curr_line = {} for product_id, user_id, factor_id, qty, uom, line_name in cr.fetchall(): if data.get('product'): product_id = data['product'][0] @@ -133,49 +134,52 @@ raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name) taxes = product.taxes_id or general_account.tax_ids tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes) - curr_line = { - 'price_unit': price, - 'quantity': qty, - 'discount':factor.factor, - 'invoice_line_tax_id': [(6,0,tax )], - 'invoice_id': last_invoice, - 'name': factor_name, - 'product_id': product_id, - 'invoice_line_tax_id': [(6,0,tax)], - 'uos_id': uom, - 'account_id': general_account.id, - 'account_analytic_id': account.id, - } - - # - # Compute for lines - # - cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id IN %s AND product_id=%s and to_invoice=%s ORDER BY account_analytic_line.date", (account.id, tuple(ids), product_id, factor_id)) - - line_ids = cr.dictfetchall() - note = [] - for line in line_ids: - # set invoice_line_note - details = [] - if data.get('date', False): - details.append(line['date']) - if data.get('time', False): - if line['product_uom_id']: - details.append("%s %s" % (line['unit_amount'], product_uom_obj.browse(cr, uid, [line['product_uom_id']],context2)[0].name)) - else: - details.append("%s" % (line['unit_amount'], )) - if data.get('name', False): - details.append(line['name']) - note.append(u' - '.join(map(lambda x: unicode(x) or '',details))) - - if note: - curr_line['name'] += "\n" + ("\n".join(map(lambda x: unicode(x) or '',note))) - invoice_line_obj.create(cr, uid, curr_line, context=context) - cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id IN %s", (last_invoice, account.id, tuple(ids))) + invoice_line_ids = invoice_line_obj.search(cr, uid, [('product_id', '=', product.id), ('invoice_id', '=', last_invoice)]) + if invoice_line_ids: + invoice_line_obj.write(cr, uid, invoice_line_ids, {'quantity': qty+ curr_line.get('quantity')}) + else: + curr_line = { + 'price_unit': price, + 'quantity': qty, + 'discount':factor.factor, + 'invoice_line_tax_id': [(6,0,tax )], + 'invoice_id': last_invoice, + 'name': factor_name, + 'product_id': product_id, + 'invoice_line_tax_id': [(6,0,tax)], + 'uos_id': uom, + 'account_id': general_account.id, + 'account_analytic_id': account.id, + } + + # + # Compute for lines + # + cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id IN %s AND product_id=%s and to_invoice=%s ORDER BY account_analytic_line.date", (account.id, tuple(ids), product_id, factor_id)) + + line_ids = cr.dictfetchall() + note = [] + for line in line_ids: + # set invoice_line_note + details = [] + if data.get('date', False): + details.append(line['date']) + if data.get('time', False): + if line['product_uom_id']: + details.append("%s %s" % (line['unit_amount'], product_uom_obj.browse(cr, uid, [line['product_uom_id']],context2)[0].name)) + else: + details.append("%s" % (line['unit_amount'], )) + if data.get('name', False): + details.append(line['name']) + note.append(u' - '.join(map(lambda x: unicode(x) or '',details))) + + if note: + curr_line['name'] += "\n" + ("\n".join(map(lambda x: unicode(x) or '',note))) + invoice_line_obj.create(cr, uid, curr_line, context=context) + cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id IN %s", (last_invoice, account.id, tuple(ids))) invoice_obj.button_reset_taxes(cr, uid, [last_invoice], context) return invoices - # # TODO: check unit of measure !!! #
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : openerp-dev-gtk@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp