diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py
index 42149aca344..1604164a057 100644
--- a/addons/calendar/calendar.py
+++ b/addons/calendar/calendar.py
@@ -1663,12 +1663,6 @@ class calendar_event(osv.Model):
virtual_id = context.get('virtual_id', True)
context.update({'virtual_id': False})
res = super(calendar_event, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy)
- for result in res:
- #remove the count, since the value is not consistent with the result of the search when expand the group
- for groupname in groupby:
- if result.get(groupname + "_count"):
- del result[groupname + "_count"]
- result.get('__context', {}).update({'virtual_id': virtual_id})
return res
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 7f998c7cb95..d92bd493530 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -298,9 +298,10 @@ class crm_lead(format_address, osv.osv):
values = {}
if partner_id:
partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+ partner_name = (partner.parent_id and partner.parent_id.name) or (partner.is_company and partner.name) or False
values = {
- 'partner_name': partner.parent_id.name if partner.parent_id else partner.name,
- 'contact_name': partner.name if partner.parent_id else False,
+ 'partner_name': partner_name,
+ 'contact_name': (not partner.is_company and partner.name) or False,
'title': partner.title and partner.title.id or False,
'street': partner.street,
'street2': partner.street2,
diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py
index ed7a6d859cf..4cd17942c1e 100644
--- a/addons/google_calendar/google_calendar.py
+++ b/addons/google_calendar/google_calendar.py
@@ -422,9 +422,10 @@ class google_calendar(osv.AbstractModel):
if self.get_need_synchro_attendee(cr, uid, context=context):
for google_attendee in single_event_dict.get('attendees', []):
+ partner_email = google_attendee.get('email', False)
if type == "write":
for oe_attendee in event['attendee_ids']:
- if oe_attendee.email == google_attendee['email']:
+ if oe_attendee.email == partner_email:
calendar_attendee_obj.write(cr, uid, [oe_attendee.id], {'state': google_attendee['responseStatus'], 'google_internal_event_id': single_event_dict.get('id')}, context=context)
google_attendee['found'] = True
continue
@@ -432,12 +433,12 @@ class google_calendar(osv.AbstractModel):
if google_attendee.get('found'):
continue
- attendee_id = res_partner_obj.search(cr, uid, [('email', '=', google_attendee['email'])], context=context)
+ attendee_id = res_partner_obj.search(cr, uid, [('email', '=', partner_email)], context=context)
if not attendee_id:
data = {
- 'email': google_attendee['email'],
+ 'email': partner_email,
'customer': False,
- 'name': google_attendee.get("displayName", False) or google_attendee['email']
+ 'name': google_attendee.get("displayName", False) or partner_email
}
attendee_id = [res_partner_obj.create(cr, uid, data, context=context)]
attendee = res_partner_obj.read(cr, uid, attendee_id[0], ['email'], context=context)
diff --git a/addons/google_spreadsheet/google_spreadsheet_data.xml b/addons/google_spreadsheet/google_spreadsheet_data.xml
index 19802e9d140..ceec2327880 100644
--- a/addons/google_spreadsheet/google_spreadsheet_data.xml
+++ b/addons/google_spreadsheet/google_spreadsheet_data.xml
@@ -4,9 +4,9 @@
Base Spreadsheet Template
- https://docs.google.com/spreadsheet/ccc?key=0ApGVjjwUC-ygdDZ0TG5EQnRlLVFQNlFGdFN5b1ZrY1E
+ https://docs.google.com/spreadsheet/ccc?key=1KUlSSzZMzkEEzyroyZ2NerRt1RVCspkG9VQIh2V6dnM
Reporting %(name)s
-
\ No newline at end of file
+
diff --git a/addons/mrp/wizard/stock_move.py b/addons/mrp/wizard/stock_move.py
index 984c112c028..60885cad263 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,12 +59,26 @@ 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']
+ 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):
- 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'}
+ 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
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index ffa1b6d090f..60a84e6d2bc 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -608,9 +608,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']:
@@ -618,17 +619,27 @@ class pos_order(osv.osv):
session.refresh()
if not float_is_zero(order['amount_return'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')):
- cash_journal = session.cash_journal_id
+ cash_journal = session.cash_journal_id.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 UserError(_("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 UserError(_("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
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 0bd4a415e9b..153eb61ce4b 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -1111,7 +1111,7 @@ openerp.point_of_sale.load_models = function load_models(instance, module){ //mo
data = {amount:tmp, price_include:true, id: tax.id};
res.push(data);
} else if (tax.type === "fixed") {
- tmp = round_pr(tax.amount * self.get_quantity(),currency_rounding);
+ tmp = tax.amount * self.get_quantity();
data = {amount:tmp, price_include:true, id: tax.id};
res.push(data);
} else {
@@ -1123,7 +1123,7 @@ openerp.point_of_sale.load_models = function load_models(instance, module){ //mo
data = {amount:tmp, price_include:false, id: tax.id};
res.push(data);
} else if (tax.type === "fixed") {
- tmp = round_pr(tax.amount * self.get_quantity(), currency_rounding);
+ tmp = tax.amount * self.get_quantity();
data = {amount:tmp, price_include:false, id: tax.id};
res.push(data);
} else {
diff --git a/addons/product_extended/product_extended.py b/addons/product_extended/product_extended.py
index 6bc62a55e8e..e500a88987e 100644
--- a/addons/product_extended/product_extended.py
+++ b/addons/product_extended/product_extended.py
@@ -74,7 +74,7 @@ class product_template(osv.osv):
uom_obj = self.pool.get("product.uom")
tmpl_obj = self.pool.get('product.template')
for sbom in bom.bom_line_ids:
- my_qty = sbom.product_qty
+ my_qty = sbom.product_qty / sbom.product_efficiency
if not sbom.attribute_value_ids:
# No attribute_value_ids means the bom line is not variant specific
price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index abb4bacb66a..109d3a6d72f 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -1145,13 +1145,17 @@ class sale_order_line(osv.osv):
uom2 = product_obj.uom_id
if pricelist and partner_id:
+ ctx = dict(
+ context,
+ uom=uom or result.get('product_uom'),
+ date=date_order,
+ )
price = self.pool['product.pricelist'].price_get(cr, uid, [pricelist],
- product, qty or 1.0, partner_id, {
- 'uom': uom or result.get('product_uom'),
- 'date': date_order,
- })[pricelist]
+ product, qty or 1.0, partner_id, ctx)[pricelist]
else:
price = Product.price_get(cr, uid, [product], ptype='list_price', context=ctx_product)[product] or False
+ if context.get('uom_qty_change', False):
+ result, domain = {}, {}
result.update({'price_unit': price})
return {'value': result, 'domain': domain}
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 5f5cf3b1491..59136e20948 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -147,7 +147,7 @@
`_
+ Downloading it requires a `git client `_
(which may be available via your distribution on linux) and can be performed
using the following command:
diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py
index 090e31dbc15..a57d35ff46d 100644
--- a/openerp/addons/base/ir/ir_translation.py
+++ b/openerp/addons/base/ir/ir_translation.py
@@ -287,21 +287,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)
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 9e3c20dcf0b..c269a5beecc 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}):