From e61970241f2ffab2ed0f8247c57f80195bb18c56 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 16 Jul 2015 09:46:36 +0200 Subject: [PATCH 01/20] [FIX] sale_stock: SO status When creating a SO with a line without specifying a product, the workflow didn't allow to pass the SO in Done when the invoice is paid. opw:644853 --- addons/sale_stock/sale_stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 4cca4aeda79..8f82f6dcc29 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -196,7 +196,7 @@ class product_product(osv.osv): #when sale/product is installed alone, there is no need to create procurements, but with sale_stock #we must create a procurement for each product that is not a service. for product in self.browse(cr, uid, ids, context=context): - if product.type != 'service': + if product.id and product.type != 'service': return True return super(product_product, self).need_procurement(cr, uid, ids, context=context) From 8f07f01783a7c059243ae21152e803d0c12e555d Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 16 Jul 2015 14:33:44 +0200 Subject: [PATCH 02/20] [FIX] base: res.company _company_default_get Fix rule processing the criteria user.company_id was not honored. Closes: #4614, #7504 --- openerp/addons/base/res/res_company.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index fc0c442c493..8b0cce0741a 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -232,9 +232,10 @@ class res_company(osv.osv): args = [ ('object_id.model', '=', object), ('field_id', '=', field), + ('company_id', '=', self.pool['res.users']._get_company(cr, uid, context=context)), ] - ids = proxy.search(cr, uid, args, context=context) + ids = proxy.search(cr, uid, args, context=context, order='sequence') user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context) for rule in proxy.browse(cr, uid, ids, context): if eval(rule.expression, {'context': context, 'user': user}): From 39d17c258057ba8ec05b0a2a350c3fb1a1219d3d Mon Sep 17 00:00:00 2001 From: Raf Ven Date: Fri, 9 Jan 2015 15:12:38 +0100 Subject: [PATCH 03/20] [FIX] base: avoid deleting translations When updating a translation, the previous one is deleted and a new one is recreated (with no module and state). When the source module is updated, the previous term is inserted again to the lsit of terms. Instead of dropping and recreating terms during update, simply update the existing term and create one only if there were no previous translation. Fixes #4617 --- openerp/addons/base/ir/ir_translation.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py index d2e5ce7a98e..8ec81e94bd0 100644 --- a/openerp/addons/base/ir/ir_translation.py +++ b/openerp/addons/base/ir/ir_translation.py @@ -286,21 +286,31 @@ class ir_translation(osv.osv): def _set_ids(self, cr, uid, name, tt, lang, ids, value, src=None): self._get_ids.clear_cache(self) self.__get_source.clear_cache(self) - - cr.execute('delete from ir_translation ' + original_module = self.pool[name.split(',')[0]]._original_module + cr.execute('update ir_translation ' + 'set value=%s ' + ' , src=%s ' + ' , state=%s ' 'where lang=%s ' 'and type=%s ' 'and name=%s ' - 'and res_id IN %s', - (lang,tt,name,tuple(ids),)) - for id in ids: + 'and module=%s ' + 'and res_id IN %s ' + 'returning res_id', + (value,src,'translated',lang,tt,name,original_module,tuple(ids),)) + + existing_ids = [x[0] for x in cr.fetchall()] + + for id in list(set(ids) - set(existing_ids)): self.create(cr, uid, { 'lang':lang, 'type':tt, 'name':name, 'res_id':id, + 'module':original_module, 'value':value, 'src':src, + 'state':'translated' }) return len(ids) From 4b548d98d112b6d2d32b95d8d89624f0fac0426b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 16 Jul 2015 15:44:00 +0200 Subject: [PATCH 04/20] [FIX] point_of_sale: payment method selection When giving back change, prioritize the same cache method as the one that was use for the transaction. This prevents cases where cash input is registered in journal B and change in journal A. Fixes #6975, closes #6976 --- addons/point_of_sale/point_of_sale.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index bac0498de36..21f9c803993 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -588,9 +588,10 @@ class pos_order(osv.osv): def _process_order(self, cr, uid, order, context=None): order_id = self.create(cr, uid, self._order_fields(cr, uid, order, context=context),context) - + journal_ids = set() for payments in order['statement_ids']: self.add_payment(cr, uid, order_id, self._payment_fields(cr, uid, payments[2], context=context), context=context) + journal_ids.add(payments[2]['journal_id']) session = self.pool.get('pos.session').browse(cr, uid, order['pos_session_id'], context=context) if session.sequence_number <= order['sequence_number']: @@ -600,16 +601,26 @@ class pos_order(osv.osv): if not float_is_zero(order['amount_return'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')): cash_journal = session.cash_journal_id if not cash_journal: - cash_journal_ids = filter(lambda st: st.journal_id.type=='cash', session.statement_ids) - if not len(cash_journal_ids): - raise osv.except_osv( _('error!'), - _("No cash statement found for this session. Unable to record returned cash.")) - cash_journal = cash_journal_ids[0].journal_id + # Select for change one of the cash journals used in this payment + cash_journal_ids = self.pool['account.journal'].search(cr, uid, [ + ('type', '=', 'cash'), + ('id', 'in', list(journal_ids)), + ], limit=1, context=context) + if not cash_journal_ids: + # If none, select for change one of the cash journals of the POS + # This is used for example when a customer pays by credit card + # an amount higher than total amount of the order and gets cash back + cash_journal_ids = [statement.journal_id.id for statement in session.statement_ids + if statement.journal_id.type == 'cash'] + if not cash_journal_ids: + raise osv.except_osv( _('error!'), + _("No cash statement found for this session. Unable to record returned cash.")) + cash_journal = cash_journal_ids[0] self.add_payment(cr, uid, order_id, { 'amount': -order['amount_return'], 'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'payment_name': _('return'), - 'journal': cash_journal.id, + 'journal': cash_journal, }, context=context) return order_id From 521c21bf7f7772a7a3e258ab565039090ef7299f Mon Sep 17 00:00:00 2001 From: Jay Patel Date: Thu, 4 Dec 2014 12:34:29 +0530 Subject: [PATCH 05/20] [IMP] MRP: Press green arrow to consume product qty more than before consumed create new line Avoid creating negative stock move and do basically the same as would have been done when using the Produce wizard --- addons/mrp/wizard/stock_move.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/addons/mrp/wizard/stock_move.py b/addons/mrp/wizard/stock_move.py index 8ab75a7836b..8bad002b28a 100644 --- a/addons/mrp/wizard/stock_move.py +++ b/addons/mrp/wizard/stock_move.py @@ -20,6 +20,7 @@ ############################################################################## from openerp.osv import fields, osv +from openerp.tools import float_compare from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp @@ -58,13 +59,27 @@ class stock_move_consume(osv.osv_memory): context = {} move_obj = self.pool.get('stock.move') uom_obj = self.pool.get('product.uom') + production_obj = self.pool.get('mrp.production') move_ids = context['active_ids'] - for data in self.browse(cr, uid, ids, context=context): - if move_ids and move_ids[0]: - move = move_obj.browse(cr, uid, move_ids[0], context=context) - qty = uom_obj._compute_qty(cr, uid, data['product_uom'].id, data.product_qty, data.product_id.uom_id.id) - move_obj.action_consume(cr, uid, move_ids, - qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, - context=context) - return {'type': 'ir.actions.act_window_close'} + move = move_obj.browse(cr, uid, move_ids[0], context=context) + production_id = move.raw_material_production_id.id + production = production_obj.browse(cr, uid, production_id, context=context) + precision = self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure') + for data in self.browse(cr, uid, ids, context=context): + qty = uom_obj._compute_qty(cr, uid, data['product_uom'].id, data.product_qty, data.product_id.uom_id.id) + remaining_qty = move.product_qty - qty + #check for product quantity is less than previously planned + if float_compare(remaining_qty, 0, precision_digits=precision) >= 0: + move_obj.action_consume(cr, uid, move_ids, qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, context=context) + else: + consumed_qty = min(move.product_qty, qty) + new_moves = move_obj.action_consume(cr, uid, move_ids, consumed_qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, context=context) + #consumed more in wizard than previously planned + extra_more_qty = qty - consumed_qty + #create new line for a remaining qty of the product + extra_move_id = production_obj._make_consume_line_from_data(cr, uid, production, data.product_id, data.product_id.uom_id.id, extra_more_qty, False, 0, context=context) + move_obj.write(cr, uid, [extra_move_id], {'restrict_lot_id': data.restrict_lot_id.id}, context=context) + move_obj.action_done(cr, uid, [extra_move_id], context=context) + + return {'type': 'ir.actions.act_window_close'} \ No newline at end of file From 81b9bc1b1122b43d451aead139891e91d99bfba5 Mon Sep 17 00:00:00 2001 From: Fabrice Henrion Date: Thu, 16 Jul 2015 18:30:48 -0700 Subject: [PATCH 06/20] typo --- doc/setup/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/setup/install.rst b/doc/setup/install.rst index 5cdc9786144..21a7f9b2f4f 100644 --- a/doc/setup/install.rst +++ b/doc/setup/install.rst @@ -223,7 +223,7 @@ There are two way to get the odoo source source zip or git. The git repository is https://github.com/odoo/odoo.git. - Downloading it requires a `a git client `_ + Downloading it requires a `git client `_ (which may be available via your distribution on linux) and can be performed using the following command: From 1cedcf6abb433beb78675557fabd9ee6e49c504e Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Fri, 17 Jul 2015 08:55:42 +0200 Subject: [PATCH 07/20] [FIX] sale: Sale Order Line Onchange Changing the product quantity must not change Product UOM. opw:644542 --- addons/sale/sale.py | 2 ++ addons/sale/sale_view.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 2e628088600..9e5b1f3e4b7 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1188,6 +1188,8 @@ class sale_order_line(osv.osv): warning_msgs += _("No valid pricelist line found ! :") + warn_msg +"\n\n" else: result.update({'price_unit': price}) + if context.get('uom_qty_change', False): + return {'value': {'price_unit': price}, 'domain': {}, 'warning': False} if warning_msgs: warning = { 'title': _('Configuration Error!'), diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index a669ed17681..8ffd75b8e06 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -129,7 +129,7 @@