diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index ce9c89ad531..1b2bc15b7ad 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -47,19 +47,11 @@ class account_invoice_line(osv.osv): if inv.type in ('out_invoice','out_refund'): for i_line in inv.invoice_line: if i_line.product_id and i_line.product_id.valuation == 'real_time': - if inv.type == 'out_invoice': - # debit account dacc will be the output account - # first check the product, if empty check the category - dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id - if not dacc: - dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id - else: - # = out_refund - # debit account dacc will be the input account - # first check the product, if empty check the category - dacc = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id - if not dacc: - dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id + # debit account dacc will be the output account + # first check the product, if empty check the category + dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id + if not dacc: + dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id # in both cases the credit account cacc will be the expense account # first check the product, if empty check the category cacc = i_line.product_id.property_account_expense and i_line.product_id.property_account_expense.id @@ -102,19 +94,12 @@ class account_invoice_line(osv.osv): # if not found on the product get the price difference account at the category acc = i_line.product_id.categ_id.property_account_creditor_price_difference_categ and i_line.product_id.categ_id.property_account_creditor_price_difference_categ.id a = None - if inv.type == 'in_invoice': - # oa will be the stock input account - # first check the product, if empty check the category - oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id - if not oa: - oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id - else: - # = in_refund - # oa will be the stock output account - # first check the product, if empty check the category - oa = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id - if not oa: - oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id + + # oa will be the stock input account + # first check the product, if empty check the category + oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id + if not oa: + oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id if oa: # get the fiscal position fpos = i_line.invoice_id.fiscal_position or False diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 83f74e463df..9cf19a2752a 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -105,7 +105,10 @@ class hr_timesheet_sheet(osv.osv): for att_tuple in attendance_tuples: if att_tuple[0] in [0,1,4]: if att_tuple[0] in [0,1]: - name = att_tuple[2]['name'] + if att_tuple[2] and att_tuple[2].has_key('name'): + name = att_tuple[2]['name'] + else: + name = self.pool['hr.attendance'].browse(cr, uid, att_tuple[1]).name else: name = self.pool['hr.attendance'].browse(cr, uid, att_tuple[1]).name date_attendances.append((1, name, att_tuple)) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index bf5a95d7abe..8595742e64f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -645,6 +645,10 @@ class purchase_order(osv.osv): def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None): ''' prepare the stock move data from the PO line ''' + price_unit = order_line.price_unit + if order.currency_id.id != order.company_id.currency_id.id: + #we don't round the price_unit, as we may want to store the standard price with more digits than allowed by the currency + price_unit = self.pool.get('res.currency').compute(cr, uid, order.currency_id.id, order.company_id.currency_id.id, price_unit, round=False, context=context) return { 'name': order_line.name or '', 'product_id': order_line.product_id.id, @@ -663,7 +667,7 @@ class purchase_order(osv.osv): 'type':'in', 'purchase_line_id': order_line.id, 'company_id': order.company_id.id, - 'price_unit': order_line.price_unit + 'price_unit': price_unit } def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None): diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 7cec0137155..69f97e7d697 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -20,6 +20,7 @@ ############################################################################## from openerp.osv import fields, osv +from openerp.tools.translate import _ class stock_move(osv.osv): _inherit = 'stock.move' @@ -126,11 +127,30 @@ class stock_partial_picking(osv.osv_memory): # Overridden to inject the purchase price as true 'cost price' when processing # incoming pickings. def _product_cost_for_average_update(self, cr, uid, move): - if move.picking_id.purchase_id and move.purchase_line_id: - return {'cost': move.purchase_line_id.price_unit, - 'currency': move.picking_id.purchase_id.currency_id.id} + if move.purchase_line_id and move.purchase_line_id and move.purchase_line_id.invoice_lines: + cost = move.price_unit + for inv_line in move.purchase_line_id.invoice_lines: + if inv_line.invoice_id.state not in ('draft', 'cancel'): + inv_currency = inv_line.invoice_id.currency_id.id + company_currency = inv_line.invoice_id.company_id.currency_id.id + cost = self.pool.get('res.currency').compute(cr, uid, inv_currency, company_currency, inv_line.price_unit, round=False, context={'date': inv_line.invoice_id.date_invoice}) + return {'cost': cost, 'currency': company_currency} return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move) + def __get_help_text(self, cursor, user, picking_id, context=None): + picking = self.pool.get('stock.picking').browse(cursor, user, picking_id, context=context) + if picking.purchase_id: + text = _("The proposed cost is made based on %s") + value = _("Purchase Order %s") % picking.purchase_id.name + if picking.purchase_id.pricelist_id.currency_id != picking.purchase_id.company_id.currency_id: + value += _(" (currency rate of purchase order taken)") + if any([x.state not in ('draft', 'cancel') for x in picking.purchase_id.invoice_ids]): + value = _("Invoices made on Purchase Order %s") % (picking.purchase_id.name) + if picking.purchase_id.pricelist_id.currency_id != picking.purchase_id.company_id.currency_id: + value += _(" (currency rate of invoices taken)") + return text % value + return super(stock_partial_picking, self).__get_help_text(cursor, user, picking_id, context=context) + # Redefinition of the new field in order to update the model stock.picking.in in the orm # FIXME: this is a temporary workaround because of a framework bug (ref: lp996816). It should be removed as soon as # the bug is fixed diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 6d41deeb85e..4d364490943 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -75,11 +75,23 @@ class stock_partial_picking(osv.osv_memory): res[wizard.id] = any([not(x.tracking) for x in wizard.move_ids]) return res + def __get_help_text(self, cursor, user, picking_id, context=None): + text = _("The proposed cost is made based on %s") + value = _("standard prices set on the products") + return text % value + + def _get_help_text(self, cursor, user, ids, name, arg, context=None): + res = {} + for wiz in self.browse(cursor, user, ids, context=context): + res[wiz.id] = self.__get_help_text(cursor, user, wiz.picking_id.id, context=context) + return res + _columns = { 'date': fields.datetime('Date', required=True), 'move_ids' : fields.one2many('stock.partial.picking.line', 'wizard_id', 'Product Moves'), 'picking_id': fields.many2one('stock.picking', 'Picking', required=True, ondelete='CASCADE'), 'hide_tracking': fields.function(_hide_tracking, string='Tracking', type='boolean', help='This field is for internal purpose. It is used to decide if the column production lot has to be shown on the moves or not.'), + 'help_text': fields.function(_get_help_text, string='Note', type='char'), } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): @@ -122,6 +134,7 @@ class stock_partial_picking(osv.osv_memory): res.update(move_ids=moves) if 'date' in fields: res.update(date=time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)) + res['help_text'] = self.__get_help_text(cr, uid, picking_id, context=context) return res def _product_cost_for_average_update(self, cr, uid, move): @@ -150,6 +163,7 @@ class stock_partial_picking(osv.osv_memory): 'move_id' : move.id, 'location_id' : move.location_id.id, 'location_dest_id' : move.location_dest_id.id, + 'currency': move.picking_id.company_id.currency_id.id, } if move.picking_id.type == 'in' and move.product_id.cost_method == 'average': partial_move.update(update_cost=True, **self._product_cost_for_average_update(cr, uid, move)) diff --git a/addons/stock/wizard/stock_partial_picking_view.xml b/addons/stock/wizard/stock_partial_picking_view.xml index f4bab484483..595336071d7 100644 --- a/addons/stock/wizard/stock_partial_picking_view.xml +++ b/addons/stock/wizard/stock_partial_picking_view.xml @@ -26,10 +26,11 @@ - - + + +