diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index f6b74edeccd..b8dcefdd3a4 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -922,7 +922,7 @@ - + @@ -932,7 +932,7 @@ - + @@ -1039,7 +1039,7 @@ - + @@ -1084,7 +1084,7 @@ - + @@ -1338,7 +1338,7 @@ - + @@ -1357,7 +1357,7 @@ - + diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 4acbb47f6c4..aa567d2fc79 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -11,8 +11,8 @@ - + diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 708c4b56629..64912213520 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -215,6 +215,8 @@ class account_analytic_account(osv.osv): GROUP BY account_analytic_line.account_id", (child_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) + for acc in self.browse(cr, uid, res.keys(), context=context): + res[acc.id] = res[acc.id] - (acc.timesheet_ca_invoiced or 0.0) res_final = res return res_final @@ -295,7 +297,7 @@ class account_analytic_account(osv.osv): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = 0.0 - sale_ids = sale_obj.search(cr, uid, [('project_id','=', account.id), ('partner_id', '=', account.partner_id.id)], context=context) + sale_ids = sale_obj.search(cr, uid, [('project_id','=', account.id), ('state', '=', 'manual')], context=context) for sale in sale_obj.browse(cr, uid, sale_ids, context=context): if not sale.invoiced: res[account.id] += sale.amount_untaxed @@ -527,10 +529,21 @@ class account_analytic_account(osv.osv): for user_id, data in remind.items(): context["data"] = data _logger.debug("Sending reminder to uid %s", user_id) - self.pool.get('email.template').send_mail(cr, uid, template_id, user_id, context=context) + self.pool.get('email.template').send_mail(cr, uid, template_id, user_id, force_send=True, context=context) return True + def onchange_invoice_on_timesheets(self, cr, uid, ids, invoice_on_timesheets, context=None): + if not invoice_on_timesheets: + return {} + result = {'value': {'use_timesheets': True}} + try: + to_invoice = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor1') + result['value']['to_invoice'] = to_invoice[1] + except ValueError: + pass + return result + class account_analytic_account_summary_user(osv.osv): _name = "account_analytic_analysis.summary.user" _description = "Hours Summary by User" diff --git a/addons/account_analytic_analysis/account_analytic_analysis_view.xml b/addons/account_analytic_analysis/account_analytic_analysis_view.xml index ccd6d6b86b0..2e5565a263b 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis_view.xml +++ b/addons/account_analytic_analysis/account_analytic_analysis_view.xml @@ -5,6 +5,15 @@ Sales Orders sale.order account.analytic.account + + + Click to create a quotation that can be converted into a sales + order. + + Use sale orders to track everything that should be invoiced + at a fix price on a contract. + + @@ -26,6 +35,9 @@ + + {'required': [('type','=','contract'),'|',('fix_price_invoices','=',True), ('invoice_on_timesheets', '=', True)]} + @@ -62,20 +74,20 @@ or view - + No order to invoice, create - - + @@ -84,7 +96,7 @@ - + account.analytic.account - + diff --git a/addons/account_analytic_default/account_analytic_default_view.xml b/addons/account_analytic_default/account_analytic_default_view.xml index ff09fb4b0db..03054ac7bb2 100644 --- a/addons/account_analytic_default/account_analytic_default_view.xml +++ b/addons/account_analytic_default/account_analytic_default_view.xml @@ -7,7 +7,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/addons/account_budget/account_budget_view.xml b/addons/account_budget/account_budget_view.xml index 80c9b699183..9ad61d7c286 100644 --- a/addons/account_budget/account_budget_view.xml +++ b/addons/account_budget/account_budget_view.xml @@ -60,7 +60,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 85e21d5fbc5..42651acb0c6 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -194,7 +194,7 @@ class account_analytic_account(osv.osv): 'user_id': fields.many2one('res.users', 'Project Manager'), 'manager_id': fields.many2one('res.users', 'Account Manager'), 'date_start': fields.date('Start Date'), - 'date': fields.date('Date End', select=True), + 'date': fields.date('End Date', select=True), 'company_id': fields.many2one('res.company', 'Company', required=False), #not required because we want to allow different companies to use the same chart of account, except for leaf accounts. 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'),('pending','To Renew'),('close','Closed'),('cancelled', 'Cancelled')], 'Status', required=True, track_visibility='onchange'), 'currency_id': fields.function(_currency, fnct_inv=_set_company_currency, #the currency_id field is readonly except if it's a view account and if there is no company diff --git a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py index 4ce2eca1ee4..254dad95c7d 100644 --- a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py +++ b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py @@ -22,6 +22,8 @@ from openerp.osv import fields, osv from openerp.osv.orm import intersect from openerp.tools.translate import _ +from openerp.addons.decimal_precision import decimal_precision as dp + class account_analytic_account(osv.osv): _name = "account.analytic.account" _inherit = "account.analytic.account" @@ -91,6 +93,11 @@ class account_analytic_account(osv.osv): res[account.id] += line.invoice_id.amount_untaxed return res + def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): + result = super(account_analytic_account, self)._ca_invoiced_calc(cr, uid, ids, name, arg, context=context) + for acc in self.browse(cr, uid, result.keys(), context=context): + result[acc.id] = result[acc.id] - (acc.expense_invoiced or 0.0) + return result _columns = { 'charge_expenses' : fields.boolean('Charge Expenses'), @@ -98,6 +105,9 @@ class account_analytic_account(osv.osv): 'expense_to_invoice' : fields.function(_expense_to_invoice_calc, type='float'), 'remaining_expense' : fields.function(_remaining_expnse_calc, type="float"), 'est_expenses': fields.float('Estimation of Expenses to Invoice'), + 'ca_invoiced': fields.function(_ca_invoiced_calc, type='float', string='Invoiced Amount', + help="Total customer invoiced amount for this account.", + digits_compute=dp.get_precision('Account')), } def on_change_template(self, cr, uid, id, template_id, context=None): diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index ec2aa1688d6..0573292c1f6 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -42,12 +42,12 @@ class analytic_user_funct_grid(osv.osv): return {} value = {} + if product_id: + prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) emp = emp_obj.browse(cr, uid, emp_id[0], context=context) if emp.product_id and not product_id: value['product_id'] = emp.product_id.id prod = emp.product_id - if product_id: - prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) if prod: value['price'] = prod.list_price value['uom_id'] = prod.uom_id.id diff --git a/addons/analytic_user_function/analytic_user_function_view.xml b/addons/analytic_user_function/analytic_user_function_view.xml index 490b3026d7f..69e1add13bb 100644 --- a/addons/analytic_user_function/analytic_user_function_view.xml +++ b/addons/analytic_user_function/analytic_user_function_view.xml @@ -11,7 +11,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 1cb5c57e67e..828c7230ddf 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -74,9 +74,6 @@ class account_analytic_account(osv.osv): 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Timesheet Invoicing Ratio', help="You usually invoice 100% of the timesheets. But if you mix fixed price and timesheet invoicing, you may use another ratio. For instance, if you do a 20% advance invoice (fixed price, based on a sales order), you should invoice the rest on timesheet with a 80% ratio."), } - _defaults = { - 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False), - } def on_change_partner_id(self, cr, uid, ids, partner_id, name, context=None): res = super(account_analytic_account, self).on_change_partner_id(cr, uid, ids, partner_id, name, context=context) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index c148df363f7..63735b090dd 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -395,7 +395,7 @@ - + @@ -461,7 +461,7 @@ domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/> - + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 8e944691a1d..056cb3eb905 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -694,7 +694,9 @@ class sale_order_line(osv.osv): 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True), 'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True), 'invoiced': fields.function(_fnct_line_invoiced, string='Invoiced', type='boolean', - store={'account.invoice': (_order_lines_from_invoice, ['state'], 10)}), + store={ + 'account.invoice': (_order_lines_from_invoice, ['state'], 10), + 'sale.order.line': (lambda self,cr,uid,ids,ctx=None: ids, ['invoice_lines'], 10)}), 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}), 'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="From stock: When needed, the product is taken from the stock or we wait for replenishment.\nOn order: When needed, the product is purchased or produced."), @@ -805,7 +807,7 @@ class sale_order_line(osv.osv): vals = self._prepare_order_line_invoice_line(cr, uid, line, False, context) if vals: inv_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context) - cr.execute('insert into sale_order_line_invoice_rel (order_line_id,invoice_id) values (%s,%s)', (line.id, inv_id)) + self.write(cr, uid, [line.id], {'invoice_lines': [(4, inv_id)]}, context=context) sales.add(line.order_id.id) create_ids.append(inv_id) # Trigger workflow events diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index cfb638cff33..a6cc7df1f12 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -156,7 +156,7 @@ - +
+ Click to create a quotation that can be converted into a sales + order. +
+ Use sale orders to track everything that should be invoiced + at a fix price on a contract. +