[MERGE] forward port of branch 8.0 up to 9abf868

This commit is contained in:
Christophe Simonis
2015-07-22 14:09:00 +02:00
15 changed files with 82 additions and 44 deletions
-6
View File
@@ -1663,12 +1663,6 @@ class calendar_event(osv.Model):
virtual_id = context.get('virtual_id', True) virtual_id = context.get('virtual_id', True)
context.update({'virtual_id': False}) 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) 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 return res
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
+3 -2
View File
@@ -298,9 +298,10 @@ class crm_lead(format_address, osv.osv):
values = {} values = {}
if partner_id: if partner_id:
partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) 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 = { values = {
'partner_name': partner.parent_id.name if partner.parent_id else partner.name, 'partner_name': partner_name,
'contact_name': partner.name if partner.parent_id else False, 'contact_name': (not partner.is_company and partner.name) or False,
'title': partner.title and partner.title.id or False, 'title': partner.title and partner.title.id or False,
'street': partner.street, 'street': partner.street,
'street2': partner.street2, 'street2': partner.street2,
+5 -4
View File
@@ -422,9 +422,10 @@ class google_calendar(osv.AbstractModel):
if self.get_need_synchro_attendee(cr, uid, context=context): if self.get_need_synchro_attendee(cr, uid, context=context):
for google_attendee in single_event_dict.get('attendees', []): for google_attendee in single_event_dict.get('attendees', []):
partner_email = google_attendee.get('email', False)
if type == "write": if type == "write":
for oe_attendee in event['attendee_ids']: 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) 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 google_attendee['found'] = True
continue continue
@@ -432,12 +433,12 @@ class google_calendar(osv.AbstractModel):
if google_attendee.get('found'): if google_attendee.get('found'):
continue 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: if not attendee_id:
data = { data = {
'email': google_attendee['email'], 'email': partner_email,
'customer': False, '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_id = [res_partner_obj.create(cr, uid, data, context=context)]
attendee = res_partner_obj.read(cr, uid, attendee_id[0], ['email'], context=context) attendee = res_partner_obj.read(cr, uid, attendee_id[0], ['email'], context=context)
@@ -4,9 +4,9 @@
<record id="google_spreadsheet_template" model="google.drive.config"> <record id="google_spreadsheet_template" model="google.drive.config">
<field name="name">Base Spreadsheet Template</field> <field name="name">Base Spreadsheet Template</field>
<field name="model_id" ref="base.model_res_partner"/> <field name="model_id" ref="base.model_res_partner"/>
<field name="google_drive_template_url">https://docs.google.com/spreadsheet/ccc?key=0ApGVjjwUC-ygdDZ0TG5EQnRlLVFQNlFGdFN5b1ZrY1E</field> <field name="google_drive_template_url">https://docs.google.com/spreadsheet/ccc?key=1KUlSSzZMzkEEzyroyZ2NerRt1RVCspkG9VQIh2V6dnM</field>
<field name="name_template">Reporting %(name)s</field> <field name="name_template">Reporting %(name)s</field>
<field name="active" eval="0" /> <field name="active" eval="0" />
</record> </record>
</data> </data>
</openerp> </openerp>
+21 -6
View File
@@ -20,6 +20,7 @@
############################################################################## ##############################################################################
from openerp.osv import fields, osv from openerp.osv import fields, osv
from openerp.tools import float_compare
from openerp.tools.translate import _ from openerp.tools.translate import _
import openerp.addons.decimal_precision as dp import openerp.addons.decimal_precision as dp
@@ -58,12 +59,26 @@ class stock_move_consume(osv.osv_memory):
context = {} context = {}
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
production_obj = self.pool.get('mrp.production')
move_ids = context['active_ids'] 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): 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) 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, remaining_qty = move.product_qty - qty
qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, #check for product quantity is less than previously planned
context=context) if float_compare(remaining_qty, 0, precision_digits=precision) >= 0:
return {'type': 'ir.actions.act_window_close'} 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'}
+18 -7
View File
@@ -608,9 +608,10 @@ class pos_order(osv.osv):
def _process_order(self, cr, uid, order, context=None): def _process_order(self, cr, uid, order, context=None):
order_id = self.create(cr, uid, self._order_fields(cr, uid, order, context=context),context) order_id = self.create(cr, uid, self._order_fields(cr, uid, order, context=context),context)
journal_ids = set()
for payments in order['statement_ids']: for payments in order['statement_ids']:
self.add_payment(cr, uid, order_id, self._payment_fields(cr, uid, payments[2], context=context), context=context) 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) session = self.pool.get('pos.session').browse(cr, uid, order['pos_session_id'], context=context)
if session.sequence_number <= order['sequence_number']: if session.sequence_number <= order['sequence_number']:
@@ -618,17 +619,27 @@ class pos_order(osv.osv):
session.refresh() session.refresh()
if not float_is_zero(order['amount_return'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')): 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: if not cash_journal:
cash_journal_ids = filter(lambda st: st.journal_id.type=='cash', session.statement_ids) # Select for change one of the cash journals used in this payment
if not len(cash_journal_ids): cash_journal_ids = self.pool['account.journal'].search(cr, uid, [
raise UserError(_("No cash statement found for this session. Unable to record returned cash.")) ('type', '=', 'cash'),
cash_journal = cash_journal_ids[0].journal_id ('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, { self.add_payment(cr, uid, order_id, {
'amount': -order['amount_return'], 'amount': -order['amount_return'],
'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'),
'payment_name': _('return'), 'payment_name': _('return'),
'journal': cash_journal.id, 'journal': cash_journal,
}, context=context) }, context=context)
return order_id return order_id
+2 -2
View File
@@ -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}; data = {amount:tmp, price_include:true, id: tax.id};
res.push(data); res.push(data);
} else if (tax.type === "fixed") { } 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}; data = {amount:tmp, price_include:true, id: tax.id};
res.push(data); res.push(data);
} else { } 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}; data = {amount:tmp, price_include:false, id: tax.id};
res.push(data); res.push(data);
} else if (tax.type === "fixed") { } 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}; data = {amount:tmp, price_include:false, id: tax.id};
res.push(data); res.push(data);
} else { } else {
+1 -1
View File
@@ -74,7 +74,7 @@ class product_template(osv.osv):
uom_obj = self.pool.get("product.uom") uom_obj = self.pool.get("product.uom")
tmpl_obj = self.pool.get('product.template') tmpl_obj = self.pool.get('product.template')
for sbom in bom.bom_line_ids: 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: if not sbom.attribute_value_ids:
# No attribute_value_ids means the bom line is not variant specific # 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 price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty
+8 -4
View File
@@ -1145,13 +1145,17 @@ class sale_order_line(osv.osv):
uom2 = product_obj.uom_id uom2 = product_obj.uom_id
if pricelist and partner_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], price = self.pool['product.pricelist'].price_get(cr, uid, [pricelist],
product, qty or 1.0, partner_id, { product, qty or 1.0, partner_id, ctx)[pricelist]
'uom': uom or result.get('product_uom'),
'date': date_order,
})[pricelist]
else: else:
price = Product.price_get(cr, uid, [product], ptype='list_price', context=ctx_product)[product] or False 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}) result.update({'price_unit': price})
return {'value': result, 'domain': domain} return {'value': result, 'domain': domain}
+1 -1
View File
@@ -147,7 +147,7 @@
<label for="product_uom_qty"/> <label for="product_uom_qty"/>
<div> <div>
<field <field
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'uom_qty_change':True}"
name="product_uom_qty" class="oe_inline" name="product_uom_qty" class="oe_inline"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/> on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
<field name="product_uom" groups="product.group_uom" class="oe_inline oe_no_button" <field name="product_uom" groups="product.group_uom" class="oe_inline oe_no_button"
+1 -1
View File
@@ -204,7 +204,7 @@ class product_product(osv.osv):
#when sale/product is installed alone, there is no need to create procurements, but with sale_stock #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. #we must create a procurement for each product that is not a service.
for product in self.browse(cr, uid, ids, context=context): for product in self.browse(cr, uid, ids, context=context):
if product.type != 'service': if product.id and product.type != 'service':
return True return True
return super(product_product, self).need_procurement(cr, uid, ids, context=context) return super(product_product, self).need_procurement(cr, uid, ids, context=context)
+2 -1
View File
@@ -13,4 +13,5 @@ Jos De Graeve Jos.DeGraeve@apertoso.be https://github.com/apertoso
List of contributors: List of contributors:
Jos De Graeve Jos.DeGraeve@apertoso.be https://github.com/JosDeGraeve Jos De Graeve Jos.DeGraeve@apertoso.be https://github.com/JosDeGraeve
Maarten De Wispelaere Maarten.DeWispelaere https://github.com/bitprocessor Maarten De Wispelaere Maarten.DeWispelaere@apertoso.be https://github.com/bitprocessor
Jean-Paul Robineau Jean-Paul.Robineau@apertoso.be https://github.com/jeanpaulrobineau
+1 -1
View File
@@ -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. The git repository is https://github.com/odoo/odoo.git.
Downloading it requires a `a git client <http://git-scm.com/download/>`_ Downloading it requires a `git client <http://git-scm.com/download/>`_
(which may be available via your distribution on linux) and can be performed (which may be available via your distribution on linux) and can be performed
using the following command: using the following command:
+15 -5
View File
@@ -287,21 +287,31 @@ class ir_translation(osv.osv):
def _set_ids(self, cr, uid, name, tt, lang, ids, value, src=None): def _set_ids(self, cr, uid, name, tt, lang, ids, value, src=None):
self._get_ids.clear_cache(self) self._get_ids.clear_cache(self)
self.__get_source.clear_cache(self) self.__get_source.clear_cache(self)
original_module = self.pool[name.split(',')[0]]._original_module
cr.execute('delete from ir_translation ' cr.execute('update ir_translation '
'set value=%s '
' , src=%s '
' , state=%s '
'where lang=%s ' 'where lang=%s '
'and type=%s ' 'and type=%s '
'and name=%s ' 'and name=%s '
'and res_id IN %s', 'and module=%s '
(lang,tt,name,tuple(ids),)) 'and res_id IN %s '
for id in ids: '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, { self.create(cr, uid, {
'lang':lang, 'lang':lang,
'type':tt, 'type':tt,
'name':name, 'name':name,
'res_id':id, 'res_id':id,
'module':original_module,
'value':value, 'value':value,
'src':src, 'src':src,
'state':'translated'
}) })
return len(ids) return len(ids)
+2 -1
View File
@@ -232,9 +232,10 @@ class res_company(osv.osv):
args = [ args = [
('object_id.model', '=', object), ('object_id.model', '=', object),
('field_id', '=', field), ('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) user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
for rule in proxy.browse(cr, uid, ids, context): for rule in proxy.browse(cr, uid, ids, context):
if eval(rule.expression, {'context': context, 'user': user}): if eval(rule.expression, {'context': context, 'user': user}):