summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-05-05 17:23:23 +0200
committerChristophe Simonis <chs@odoo.com>2017-05-05 17:23:23 +0200
commit9898b125ad00aa2288017761297003a3a4e1ddb0 (patch)
tree4c2b383e9a99018412fabe51355cac3587649bd0
parent4d6aff97b6ada270593e5cd45393b455cfa8455d (diff)
parentc0e4ab80804fffb88e4f9fe4e35f7bce1f441f9e (diff)
[MERGE] forward port branch saas-15 up to c0e4ab80804
-rw-r--r--addons/account/models/account_invoice.py8
-rw-r--r--addons/mass_mailing/wizard/mail_compose_message.py20
-rw-r--r--addons/mrp/models/mrp_production.py1
-rw-r--r--addons/mrp/wizard/mrp_product_produce.py2
-rw-r--r--addons/procurement/models/procurement.py3
-rw-r--r--addons/purchase/models/account_invoice.py7
-rw-r--r--odoo/addons/base/ir/ir_cron.py4
-rw-r--r--odoo/tools/convert.py3
-rw-r--r--odoo/tools/yaml_import.py2
9 files changed, 30 insertions, 20 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py
index 2e1528b4d8d..8cfafcdc537 100644
--- a/addons/account/models/account_invoice.py
+++ b/addons/account/models/account_invoice.py
@@ -1236,11 +1236,11 @@ class AccountInvoiceLine(models.Model):
string='Analytic Account')
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags')
company_id = fields.Many2one('res.company', string='Company',
- related='invoice_id.company_id', store=True, readonly=True)
+ related='invoice_id.company_id', store=True, readonly=True, related_sudo=False)
partner_id = fields.Many2one('res.partner', string='Partner',
- related='invoice_id.partner_id', store=True, readonly=True)
- currency_id = fields.Many2one('res.currency', related='invoice_id.currency_id', store=True)
- company_currency_id = fields.Many2one('res.currency', related='invoice_id.company_currency_id', readonly=True)
+ related='invoice_id.partner_id', store=True, readonly=True, related_sudo=False)
+ currency_id = fields.Many2one('res.currency', related='invoice_id.currency_id', store=True, related_sudo=False)
+ company_currency_id = fields.Many2one('res.currency', related='invoice_id.company_currency_id', readonly=True, related_sudo=False)
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index c8b1e54f316..6c1fc81280e 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -40,11 +40,29 @@ class MailComposeMessage(models.TransientModel):
'mailing_model': self.model,
'mailing_domain': self.active_domain,
})
+
+ # Preprocess res.partners to batch-fetch from db
+ # if recipient_ids is present, it means they are partners
+ # (the only object to fill get_default_recipient this way)
+ recipient_partners_ids = []
+ read_partners = {}
+ for res_id in res_ids:
+ mail_values = res[res_id]
+ if mail_values.get('recipient_ids'):
+ # recipient_ids is a list of x2m command tuples at this point
+ recipient_partners_ids.append(mail_values.get('recipient_ids')[0][1])
+ read_partners = self.env['res.partner'].browse(recipient_partners_ids)
+
+ partners_email = {p.id: p.email for p in read_partners}
+
blacklist = self._context.get('mass_mailing_blacklist')
seen_list = self._context.get('mass_mailing_seen_list')
for res_id in res_ids:
mail_values = res[res_id]
- recips = tools.email_split(mail_values.get('email_to'))
+ if mail_values.get('email_to'):
+ recips = tools.email_split(mail_values['email_to'])
+ else:
+ recips = tools.email_split(partners_email.get(res_id))
mail_to = recips[0].lower() if recips else False
if (blacklist and mail_to in blacklist) or (seen_list and mail_to in seen_list):
# prevent sending to blocked addresses that were included by mistake
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index 6276d9c8aa9..5fd40f455c7 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -307,6 +307,7 @@ class MrpProduction(models.Model):
'production_id': self.id,
'origin': self.name,
'group_id': self.procurement_group_id.id,
+ 'propagate': self.propagate,
})
move.action_confirm()
return move
diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py
index b7cd863a5fc..0bb35fe9c90 100644
--- a/addons/mrp/wizard/mrp_product_produce.py
+++ b/addons/mrp/wizard/mrp_product_produce.py
@@ -29,7 +29,7 @@ class MrpProductProduce(models.TransientModel):
lines = []
existing_lines = []
for move in production.move_raw_ids.filtered(lambda x: (x.product_id.tracking != 'none') and x.state not in ('done', 'cancel')):
- if not move.move_lot_ids:
+ if not move.move_lot_ids.filtered(lambda x: not x.lot_produced_id):
qty = quantity / move.bom_line_id.bom_id.product_qty * move.bom_line_id.product_qty
if move.product_id.tracking == 'serial':
while float_compare(qty, 0.0, precision_rounding=move.product_uom.rounding) > 0:
diff --git a/addons/procurement/models/procurement.py b/addons/procurement/models/procurement.py
index c6534f7ed5f..f9b9ef8119b 100644
--- a/addons/procurement/models/procurement.py
+++ b/addons/procurement/models/procurement.py
@@ -289,12 +289,11 @@ class ProcurementOrder(models.Model):
This is appropriate for batch jobs only.
@return: Dictionary of values
'''
- ProcurementSudo = self.env['procurement.order'].sudo()
try:
if use_new_cursor:
cr = registry(self._cr.dbname).cursor()
self = self.with_env(self.env(cr=cr)) # TDE FIXME
-
+ ProcurementSudo = self.env['procurement.order'].sudo()
# Run confirmed procurements
procurements = ProcurementSudo.search([('state', '=', 'confirmed')] + (company_id and [('company_id', '=', company_id)] or []))
while procurements:
diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py
index 00e11060444..9c1cf48312c 100644
--- a/addons/purchase/models/account_invoice.py
+++ b/addons/purchase/models/account_invoice.py
@@ -68,10 +68,7 @@ class AccountInvoice(models.Model):
self.partner_id = self.purchase_id.partner_id.id
new_lines = self.env['account.invoice.line']
- for line in self.purchase_id.order_line:
- # Load a PO line only once
- if line in self.invoice_line_ids.mapped('purchase_line_id'):
- continue
+ for line in self.purchase_id.order_line - self.invoice_line_ids.mapped('purchase_line_id'):
data = self._prepare_invoice_line_from_po_line(line)
new_line = new_lines.new(data)
new_line._set_additional_fields(self)
@@ -217,5 +214,5 @@ class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
purchase_line_id = fields.Many2one('purchase.order.line', 'Purchase Order Line', ondelete='set null', index=True, readonly=True)
- purchase_id = fields.Many2one('purchase.order', related='purchase_line_id.order_id', string='Purchase Order', store=False, readonly=True,
+ purchase_id = fields.Many2one('purchase.order', related='purchase_line_id.order_id', string='Purchase Order', store=False, readonly=True, related_sudo=False,
help='Associated Purchase Order. Filled in automatically when a PO is chosen on the vendor bill.')
diff --git a/odoo/addons/base/ir/ir_cron.py b/odoo/addons/base/ir/ir_cron.py
index 5b0c6567ec7..17b92cae609 100644
--- a/odoo/addons/base/ir/ir_cron.py
+++ b/odoo/addons/base/ir/ir_cron.py
@@ -72,8 +72,6 @@ class ir_cron(models.Model):
Simply logs the exception and rollback the transaction. """
self._cr.rollback()
- _logger.exception("Call from cron %s for server action %d failed in Job %s",
- cron_name, server_action_id, job_id)
@api.model
def _callback(self, cron_name, server_action_id, job_id):
@@ -98,6 +96,8 @@ class ir_cron(models.Model):
self.pool.signal_changes()
except Exception as e:
self.pool.reset_changes()
+ _logger.exception("Call from cron %s for server action #%s failed in Job #%s",
+ cron_name, server_action_id, job_id)
self._handle_callback_exception(cron_name, server_action_id, job_id, e)
@classmethod
diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py
index 84dbeec3a5e..2dd45699edb 100644
--- a/odoo/tools/convert.py
+++ b/odoo/tools/convert.py
@@ -250,9 +250,6 @@ form: module.record_id""" % (xml_id,)
modcnt = self.env['ir.module.module'].search_count([('name', '=', module), ('state', '=', 'installed')])
assert modcnt == 1, """The ID "%s" refers to an uninstalled module""" % (xml_id,)
- if len(id) > 64:
- _logger.error('id: %s is to long (max: 64)', id)
-
def _tag_delete(self, rec, data_node=None, mode=None):
d_model = rec.get("model")
d_search = rec.get("search",'').encode('utf-8')
diff --git a/odoo/tools/yaml_import.py b/odoo/tools/yaml_import.py
index 02ef732c2e6..ad9a48e8a84 100644
--- a/odoo/tools/yaml_import.py
+++ b/odoo/tools/yaml_import.py
@@ -136,8 +136,6 @@ class YamlInterpreter(object):
if module != self.module:
module_count = self.env['ir.module.module'].search_count([('name', '=', module), ('state', '=', 'installed')])
assert module_count == 1, 'The ID "%s" refers to an uninstalled module.' % (xml_id,)
- if len(id) > 64: # TODO where does 64 come from (DB is 128)? should be a constant or loaded form DB
- _logger.error('id: %s is to long (max: 64)', id)
def get_id(self, xml_id):
if xml_id is False or xml_id is None: