diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index dd3f32f25f2..1c77df6ef05 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1092,6 +1092,8 @@ class AccountInvoice(models.Model): :param date: payment date, defaults to fields.Date.context_today(self) :param writeoff_acc: account in which to create a writeoff if pay_amount < self.residual, so that the invoice is fully paid """ + if isinstance( pay_journal, ( int, long ) ): + pay_journal = self.env['account.journal'].browse([pay_journal]) assert len(self) == 1, "Can only pay one invoice at a time." payment_type = self.type in ('out_invoice', 'in_refund') and 'inbound' or 'outbound' if payment_type == 'inbound': @@ -1122,6 +1124,8 @@ class AccountInvoice(models.Model): }) payment.post() + return True + @api.multi def _track_subtype(self, init_values): self.ensure_one() diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 73d3daa4e58..6d30c6aa4e1 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -137,7 +137,8 @@ class account_journal(models.Model): currency = self.currency_id or self.company_id.currency_id number_to_reconcile = last_balance = account_sum = 0 title = '' - number_draft = number_waiting = number_late = sum_draft = sum_waiting = sum_late = 0 + number_draft = number_waiting = number_late = 0 + sum_draft = sum_waiting = sum_late = 0.0 if self.type in ['bank', 'cash']: last_bank_stmt = self.env['account.bank.statement'].search([('journal_id', 'in', self.ids)], order="date desc, id desc", limit=1) last_balance = last_bank_stmt and last_bank_stmt[0].balance_end or 0 @@ -163,30 +164,33 @@ class account_journal(models.Model): elif self.type in ['sale', 'purchase']: title = _('Bills to pay') if self.type == 'purchase' else _('Invoices owed to you') # optimization to find total and sum of invoice that are in draft, open state - query = """SELECT state, amount_total, currency_id AS currency FROM account_invoice WHERE journal_id = %s AND state NOT IN ('paid', 'cancel');""" + query = """SELECT state, amount_total, currency_id AS currency, type FROM account_invoice WHERE journal_id = %s AND state NOT IN ('paid', 'cancel');""" self.env.cr.execute(query, (self.id,)) query_results = self.env.cr.dictfetchall() today = datetime.today() - query = """SELECT amount_total, currency_id AS currency FROM account_invoice WHERE journal_id = %s AND date < %s AND state = 'open';""" + query = """SELECT amount_total, currency_id AS currency, type FROM account_invoice WHERE journal_id = %s AND date < %s AND state = 'open';""" self.env.cr.execute(query, (self.id, today)) late_query_results = self.env.cr.dictfetchall() - sum_draft = 0.0 - number_draft = 0 - number_waiting = 0 for result in query_results: + if result['type'] in ['in_refund', 'out_refund']: + factor = -1 + else: + factor = 1 cur = self.env['res.currency'].browse(result.get('currency')) if result.get('state') == 'draft': number_draft += 1 - sum_draft += cur.compute(result.get('amount_total'), currency) + sum_draft += cur.compute(result.get('amount_total'), currency) * factor elif result.get('state') == 'open': number_waiting += 1 - sum_waiting += cur.compute(result.get('amount_total'), currency) - sum_late = 0.0 - number_late = 0 + sum_waiting += cur.compute(result.get('amount_total'), currency) * factor for result in late_query_results: + if result['type'] in ['in_refund', 'out_refund']: + factor = -1 + else: + factor = 1 cur = self.env['res.currency'].browse(result.get('currency')) number_late += 1 - sum_late += cur.compute(result.get('amount_total'), currency) + sum_late += cur.compute(result.get('amount_total'), currency) * factor return { 'number_to_reconcile': number_to_reconcile, diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index 79ab283d34c..6372b054ad1 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -320,12 +320,9 @@ class ResPartner(models.Model): def _compute_issued_total(self): """ Returns the issued total as will be displayed on partner view """ today = fields.Date.context_today(self) - for partner in self: - domain = partner.get_followup_lines_domain(today, overdue_only=True) - issued_total = 0 - for aml in self.env['account.move.line'].search(domain): - issued_total += aml.amount_residual - partner.issued_total = issued_total + domain = self.get_followup_lines_domain(today, overdue_only=True) + for aml in self.env['account.move.line'].search(domain): + aml.partner_id.issued_total += aml.amount_residual @api.one def _compute_has_unreconciled_entries(self): diff --git a/addons/hr_maintenance/views/maintenance_views.xml b/addons/hr_maintenance/views/maintenance_views.xml index 72970f9cd77..976279d57b6 100644 --- a/addons/hr_maintenance/views/maintenance_views.xml +++ b/addons/hr_maintenance/views/maintenance_views.xml @@ -65,6 +65,14 @@ [('employee_id', '=', False), ('department_id', '=', False)] + + + + + + + + diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml index e9554e5155c..bfa78eb1213 100644 --- a/addons/mail/views/mail_templates.xml +++ b/addons/mail/views/mail_templates.xml @@ -36,7 +36,7 @@ diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 7d7e4beecb6..6276d9c8aa9 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -410,7 +410,7 @@ class MrpProduction(models.Model): quantity = order.product_uom_id._compute_quantity(order.product_qty, order.bom_id.product_uom_id) / order.bom_id.product_qty boms, lines = order.bom_id.explode(order.product_id, quantity, picking_type=order.bom_id.picking_type_id) order._generate_workorders(boms) - orders_to_plan.write({'state': 'planned'}) + return orders_to_plan.write({'state': 'planned'}) @api.multi def _generate_workorders(self, exploded_boms): @@ -539,17 +539,19 @@ class MrpProduction(models.Model): moves_to_cancel.action_cancel() self.write({'state': 'done', 'date_finished': fields.Datetime.now()}) self.env["procurement.order"].search([('production_id', 'in', self.ids)]).check() - self.write({'state': 'done'}) + return self.write({'state': 'done'}) @api.multi def do_unreserve(self): for production in self: production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')).do_unreserve() + return True @api.multi def button_unreserve(self): self.ensure_one() self.do_unreserve() + return True @api.multi def button_scrap(self): diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index 86dde92fbfa..31cd5226346 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -131,7 +131,7 @@ class MrpUnbuild(models.Model): produced_quant_ids = produce_moves.mapped('quant_ids').filtered(lambda quant: quant.qty > 0) consume_move.quant_ids.sudo().write({'produced_quant_ids': [(6, 0, produced_quant_ids.ids)]}) - self.write({'state': 'done'}) + return self.write({'state': 'done'}) def _generate_consume_moves(self): moves = self.env['stock.move'] diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 23cd851b780..86107856873 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -342,6 +342,7 @@ class MrpWorkorder(models.Model): self.final_lot_id = False if self.qty_produced >= self.production_id.product_qty: self.button_finish() + return True @api.multi def button_start(self): @@ -369,7 +370,7 @@ class MrpWorkorder(models.Model): 'date_start': datetime.now(), 'user_id': self.env.user.id }) - self.write({'state': 'progress', + return self.write({'state': 'progress', 'date_start': datetime.now(), }) @@ -377,7 +378,7 @@ class MrpWorkorder(models.Model): def button_finish(self): self.ensure_one() self.end_all() - self.write({'state': 'done', 'date_finished': fields.Datetime.now()}) + return self.write({'state': 'done', 'date_finished': fields.Datetime.now()}) @api.multi def end_previous(self, doall=False): @@ -405,6 +406,7 @@ class MrpWorkorder(models.Model): if not len(loss_id): raise UserError(_("You need to define at least one unactive productivity loss in the category 'Performance'. Create one from the Manufacturing app, menu: Configuration / Productivity Losses.")) timeline.copy({'date_start': maxdate, 'date_end': enddate, 'loss_id': loss_id.id}) + return True @api.multi def end_all(self): @@ -413,22 +415,24 @@ class MrpWorkorder(models.Model): @api.multi def button_pending(self): self.end_previous() + return True @api.multi def button_unblock(self): for order in self: order.workcenter_id.unblock() + return True @api.multi def action_cancel(self): - self.write({'state': 'cancel'}) + return self.write({'state': 'cancel'}) @api.multi def button_done(self): if any([x.state in ('done', 'cancel') for x in self]): raise UserError(_('A Manufacturing Order is already done or cancelled!')) self.end_all() - self.write({'state': 'done', + return self.write({'state': 'done', 'date_finished': datetime.now()}) @api.multi diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index f254bbc9032..580401e2a9c 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -17,7 +17,9 @@ var FieldPad = form_common.AbstractField.extend(form_common.ReinitializeWidgetMi event.preventDefault(); self.set("configured", true); }); - this.pad_loading_request = null; + // CHANGES ONLY NEEDED UNTIL SAAS-15 + // deferred for request getting pad content (readonly) or new pad url (edit) + this._pad_loading_deferred = null; }, initialize_content: function() { var self = this; @@ -38,14 +40,25 @@ var FieldPad = form_common.AbstractField.extend(form_common.ReinitializeWidgetMi }, render_value: function() { var self = this; - $.when(this._configured_deferred, this.pad_loading_request).always(function() { + $.when(this._configured_deferred).always(function() { if (!self.get('configured')){ return; } + + // reject previously ongoing _pad_loading_deferred + if (self._pad_loading_deferred !== null) { + self._pad_loading_deferred.reject(); + self.$('.oe_pad_content').removeClass('oe_pad_loading').html(''); + } + self._pad_loading_deferred = $.Deferred(); + // keep reference to current _pad_loading_deferred + var loading_def = self._pad_loading_deferred; + var value = self.get('value'); if (self.get('effective_readonly')) { if (_.str.startsWith(value, 'http')) { - self.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) { + self.view.dataset.call('pad_get_content', {url: value}).then(loading_def.resolve, loading_def.reject); + loading_def.done(function(data) { self.$('.oe_pad_content').removeClass('oe_pad_loading').html('
'); self.$('.oe_pad_readonly').html(data); }).fail(function() { @@ -56,21 +69,37 @@ var FieldPad = form_common.AbstractField.extend(form_common.ReinitializeWidgetMi } } else { - var def = $.when(); + var def = $.Deferred(); if (! value || !_.str.startsWith(value, 'http')) { - def = self.view.dataset.call('pad_generate_url', { - context: { - model: self.view.model, - field_name: self.name, - object_id: self.view.datarecord.id - }, - }).then(function(data) { - if (! data.url) { - self.set("configured", false); - } else { - self.internal_set_value(data.url); - } + var deferreds = [ + self.view.dataset.call('pad_generate_url', { + context: { + model: self.view.model, + field_name: self.name, + object_id: self.view.datarecord.id + } + }), + // change record only after record_loaded and its call stack is finished + self.view.record_loaded.then(function() { + var call_stack_ended = $.Deferred(); + _.defer(call_stack_ended.resolve); + return call_stack_ended; + }) + ]; + // delay onchange after x2many views are loaded + deferreds = deferreds.concat(_.compact(_.pluck(self.view.fields, 'is_loaded'))); + $.when.apply($, deferreds).then(function(data) { + // update value only if loading_def has not been previously rejected + loading_def.resolve().done(function(){ + if (! data.url) { + self.set("configured", false); + } else { + self.internal_set_value(data.url); + } + }).then(def.resolve, def.reject); }); + } else { + def.resolve(); } def.then(function() { value = self.get('value'); diff --git a/addons/payment/security/payment_security.xml b/addons/payment/security/payment_security.xml index c5ad3f62fe7..df797070aed 100644 --- a/addons/payment/security/payment_security.xml +++ b/addons/payment/security/payment_security.xml @@ -15,7 +15,7 @@ Access own payment tokens only - [('partner_id','=',user.partner_id.id)] + ['|', ('partner_id','=',user.partner_id.id), ('partner_id', '=', user.partner_id.commercial_partner_id.id)] diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index 5d0fa66ff23..7338313e245 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -55,19 +55,18 @@ odoo.define('payment_stripe.stripe', function(require) { amount: $("input[name='amount']").val(), currency_id: $("input[name='currency_id']").val(), acquirer_id: acquirer_id - }).then(function (data) { + }) handler.open({ name: $("input[name='merchant']").val(), description: $("input[name='invoice_num']").val(), currency: $("input[name='currency']").val(), amount: $("input[name='amount']").val()*100 }); - }); } else { ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', { so_id: so_id, so_token: so_token - }).then(function (data) { + }, {'async': false}).then(function (data) { $form.html(data); handler.open({ name: $("input[name='merchant']").val(), diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index babe056901c..11b7e7c07df 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -334,15 +334,16 @@ class PosOrder(models.Model): def _reconcile_payments(self): for order in self: - aml = order.statement_ids.mapped('journal_entry_ids') | order.account_move.line_ids - aml = aml.filtered(lambda r: not r.reconciled and r.account_id.internal_type == 'receivable' and r.partner_id == order.partner_id) + aml = order.statement_ids.mapped('journal_entry_ids') | order.account_move.line_ids | order.invoice_id.move_id.line_ids + aml = aml.filtered(lambda r: not r.reconciled and r.account_id.internal_type == 'receivable' and r.partner_id == order.partner_id.commercial_partner_id) try: aml.reconcile() - except: + except Exception: # There might be unexpected situations where the automatic reconciliation won't # work. We don't want the user to be blocked because of this, since the automatic # reconciliation is introduced for convenience, not for mandatory accounting # reasons. + _logger.error('Reconciliation did not work for order %s', order.name) continue def _default_session(self): diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index e9d721600e3..22ca547c55d 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -36,8 +36,8 @@ class PosSession(models.Model): paid=order.amount_paid, )) order.action_pos_order_done() - orders = session.order_ids.filtered(lambda order: order.state == 'done') - orders._reconcile_payments() + orders = session.order_ids.filtered(lambda order: order.state in ['invoiced', 'done']) + orders.sudo()._reconcile_payments() config_id = fields.Many2one( 'pos.config', string='Point of Sale', @@ -245,10 +245,6 @@ class PosSession(models.Model): @api.multi def action_pos_session_closing_control(self): for session in self: - #DO NOT FORWARD-PORT - if session.state == 'closing_control': - session.action_pos_session_close() - continue for statement in session.statement_ids: if (statement != session.cash_register_id) and (statement.balance_end != statement.balance_end_real): statement.write({'balance_end_real': statement.balance_end}) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 4cb1cc08296..9566d195c33 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1413,7 +1413,7 @@ exports.Orderline = Backbone.Model.extend({ } return false; }, - compute_all: function(taxes, price_unit, quantity, currency_rounding) { + compute_all: function(taxes, price_unit, quantity, currency_rounding, no_map_tax) { var self = this; var list_taxes = []; var currency_rounding_bak = currency_rounding; @@ -1424,7 +1424,9 @@ exports.Orderline = Backbone.Model.extend({ var total_included = total_excluded; var base = total_excluded; _(taxes).each(function(tax) { - tax = self._map_tax_fiscal_position(tax); + if (!no_map_tax){ + tax = self._map_tax_fiscal_position(tax); + } if (tax.amount_type === 'group'){ var ret = self.compute_all(tax.children_tax_ids, price_unit, quantity, currency_rounding); total_excluded = ret.total_excluded; @@ -1955,6 +1957,27 @@ exports.Order = Backbone.Model.extend({ this.orderlines.remove(line); this.select_orderline(this.get_last_orderline()); }, + + fix_tax_included_price: function(line){ + if(this.fiscal_position){ + var unit_price = line.price; + var taxes = line.get_taxes(); + var mapped_included_taxes = []; + _(taxes).each(function(tax) { + var line_tax = line._map_tax_fiscal_position(tax); + if(tax.price_include && tax.id != line_tax.id){ + + mapped_included_taxes.push(tax); + } + }) + + unit_price = line.compute_all(mapped_included_taxes, unit_price, 1, this.pos.currency.rounding, true).total_excluded; + + line.set_unit_price(unit_price); + } + + }, + add_product: function(product, options){ if(this._printed){ this.destroy(); @@ -1970,9 +1993,14 @@ exports.Order = Backbone.Model.extend({ if(options.quantity !== undefined){ line.set_quantity(options.quantity); } + if(options.price !== undefined){ line.set_unit_price(options.price); } + + //To substract from the unit price the included taxes mapped by the fiscal position + this.fix_tax_included_price(line); + if(options.discount !== undefined){ line.set_discount(options.discount); } diff --git a/addons/product/models/product.py b/addons/product/models/product.py index bc1d0837fde..650ca25754b 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -94,7 +94,8 @@ class ProductPriceHistory(models.Model): def _get_default_company_id(self): return self._context.get('force_company', self.env.user.company_id.id) - company_id = fields.Many2one('res.company', default=_get_default_company_id, required=True) + company_id = fields.Many2one('res.company', string='Company', + default=_get_default_company_id, required=True) product_id = fields.Many2one('product.product', 'Product', ondelete='cascade', required=True) datetime = fields.Datetime('Date', default=fields.Datetime.now) cost = fields.Float('Cost', digits=dp.get_precision('Product Price')) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 12d93931bc8..81ddeea08d8 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -448,7 +448,6 @@ class SaleOrder(models.Model): def action_unlock(self): self.write({'state': 'sale'}) - @api.multi def _prepare_procurement_group(self): return {'name': self.name} diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index d39872a8a5a..1f6d70c404a 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -72,7 +72,6 @@ class SaleOrder(models.Model): invoice_vals['incoterms_id'] = self.incoterm.id or False return invoice_vals - @api.model def _prepare_procurement_group(self): res = super(SaleOrder, self)._prepare_procurement_group() res.update({'move_type': self.picking_policy, 'partner_id': self.partner_shipping_id.id, 'sale_order_id': self.id}) diff --git a/addons/web_kanban/static/src/js/kanban_view.js b/addons/web_kanban/static/src/js/kanban_view.js index 1dbb601889a..39ea7a1a91e 100644 --- a/addons/web_kanban/static/src/js/kanban_view.js +++ b/addons/web_kanban/static/src/js/kanban_view.js @@ -307,7 +307,8 @@ var KanbanView = View.extend({ return this.fields_view.fields.active; }, _is_quick_create_enabled: function() { - if(!_.contains(['char', 'boolean', 'many2one'], this.fields[this.group_by_field].type)){ + var group_by_field = this.group_by_field.split(':')[0] + if(!_.contains(['char', 'boolean', 'many2one'], this.fields[group_by_field].type)){ return false; } if (!this.quick_creatable || !this.is_action_enabled('create')) diff --git a/addons/website_portal/controllers/main.py b/addons/website_portal/controllers/main.py index 4a9a8cb78bb..3f89ed2b80d 100644 --- a/addons/website_portal/controllers/main.py +++ b/addons/website_portal/controllers/main.py @@ -119,7 +119,7 @@ class website_account(http.Controller): # vat validation if data.get("vat") and hasattr(request.env["res.partner"], "check_vat"): - if request.website.company_id.vat_check_vies: + if request.website.company_id.sudo().vat_check_vies: # force full VIES online check check_func = request.env["res.partner"].vies_vat_check else: diff --git a/addons/website_sale/models/res_config.py b/addons/website_sale/models/res_config.py index 59c0390dabe..1d329eae2cb 100644 --- a/addons/website_sale/models/res_config.py +++ b/addons/website_sale/models/res_config.py @@ -30,7 +30,7 @@ class WebsiteConfigSettings(models.TransientModel): module_sale_ebay = fields.Boolean("eBay connector") module_sale_coupon = fields.Boolean("Discount Programs") - group_website_multiimage = fields.Boolean(string='Multi-Images', implied_group='website_sale.group_website_multi_image') + group_website_multiimage = fields.Boolean(string='Multi-Images', implied_group='website_sale.group_website_multi_image', group='base.group_portal,base.group_user,base.group_public') group_discount_per_so_line = fields.Boolean(string="Discounted Prices", implied_group='sale.group_discount_per_so_line') group_delivery_invoice_address = fields.Boolean(string="Shipping Address", implied_group='sale.group_delivery_invoice_address') @@ -60,8 +60,14 @@ class WebsiteConfigSettings(models.TransientModel): order_mail_template = fields.Many2one('mail.template', string='Order Confirmation Email', default=_default_order_mail_template, domain="[('model', '=', 'sale.order')]", help="Email sent to customer at the end of the checkout process") - group_show_price_subtotal = fields.Boolean("Show subtotal", implied_group='sale.group_show_price_subtotal') - group_show_price_total = fields.Boolean("Show total", implied_group='sale.group_show_price_total') + group_show_price_subtotal = fields.Boolean( + "Show subtotal", + implied_group='sale.group_show_price_subtotal', + group='base.group_portal,base.group_user,base.group_public') + group_show_price_total = fields.Boolean( + "Show total", + implied_group='sale.group_show_price_total', + group='base.group_portal,base.group_user,base.group_public') default_invoice_policy = fields.Selection([ ('order', 'Ordered quantities'), diff --git a/doc/cla/corporate/via_laurea.md b/doc/cla/corporate/via_laurea.md index 66986aeaa6e..223b0317a54 100644 --- a/doc/cla/corporate/via_laurea.md +++ b/doc/cla/corporate/via_laurea.md @@ -6,8 +6,8 @@ I declare that I am authorized and able to make this agreement and sign this dec Signed, -Saulius Zilys saulius@vialaurea.lt https://github.com/realsaiko +Saulius Zilys saulius@vialaurea.lt (up to 2017-04-24) List of contributors: -Saulius Zilys saulius@vialaurea.lt https://github.com/realsaiko +Saulius Zilys saulius@vialaurea.lt (up to 2017-04-24) diff --git a/doc/cla/individual/realsaiko.md b/doc/cla/individual/realsaiko.md new file mode 100644 index 00000000000..b38a5fd06f1 --- /dev/null +++ b/doc/cla/individual/realsaiko.md @@ -0,0 +1,11 @@ +Spain, 2017-04-24 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Saulius Žilys realsaiko@gmail.com https://github.com/realsaiko diff --git a/doc/cla/individual/roganw.md b/doc/cla/individual/roganw.md new file mode 100644 index 00000000000..75afdc09ae3 --- /dev/null +++ b/doc/cla/individual/roganw.md @@ -0,0 +1,11 @@ +China, 2017-04-24 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Rogan Wang quangenw@gmail.com https://github.com/RoganW diff --git a/odoo/addons/base/ir/ir_cron.py b/odoo/addons/base/ir/ir_cron.py index a6f29ee0d95..2ba0548b48d 100644 --- a/odoo/addons/base/ir/ir_cron.py +++ b/odoo/addons/base/ir/ir_cron.py @@ -88,10 +88,11 @@ class ir_cron(models.Model): log_depth = (None if _logger.isEnabledFor(logging.DEBUG) else 1) odoo.netsvc.log(_logger, logging.DEBUG, 'cron.object.execute', (self._cr.dbname, self._uid, '*', cron_name, server_action_id), depth=log_depth) + start_time = False if _logger.isEnabledFor(logging.DEBUG): start_time = time.time() self.env['ir.actions.server'].browse(server_action_id).run() - if _logger.isEnabledFor(logging.DEBUG): + if start_time and _logger.isEnabledFor(logging.DEBUG): end_time = time.time() _logger.debug('%.3fs (cron %s, server action %d with uid %d)', end_time - start_time, cron_name, server_action_id, self.env.uid) self.pool.signal_caches_change() diff --git a/odoo/addons/base/res/res_lang.py b/odoo/addons/base/res/res_lang.py index 446565ada13..19a5b9be339 100644 --- a/odoo/addons/base/res/res_lang.py +++ b/odoo/addons/base/res/res_lang.py @@ -261,7 +261,7 @@ class Lang(models.Model): if percent[-1] in 'eEfFgG': parts = formatted.split('.') - parts[0], _ = intersperse(parts[0], eval_lang_grouping, thousands_sep) + parts[0] = intersperse(parts[0], eval_lang_grouping, thousands_sep)[0] formatted = decimal_point.join(parts) diff --git a/odoo/addons/base/tests/test_views.py b/odoo/addons/base/tests/test_views.py index d60212e222a..bd462932e5f 100644 --- a/odoo/addons/base/tests/test_views.py +++ b/odoo/addons/base/tests/test_views.py @@ -8,6 +8,7 @@ from lxml import etree from lxml.builder import E from psycopg2 import IntegrityError +from odoo.osv.orm import modifiers_tests from odoo.exceptions import ValidationError from odoo.tests import common from odoo.tools import mute_logger @@ -876,6 +877,10 @@ class TestViews(ViewCase): string="Replacement title", version="7.0" )) + def test_modifiers(self): + # implemeted elsewhere... + modifiers_tests() + class ViewModeField(ViewCase): """ diff --git a/odoo/models.py b/odoo/models.py index cdee4f9f1cc..6f038058ab7 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -266,6 +266,15 @@ class BaseModel(object): self.env['ir.model']._reflect_model(self) self.env['ir.model.fields']._reflect_model(self) self.env['ir.model.constraint']._reflect_model(self) + if not self.pool._init: + # remove ir.model.fields that are not in self._fields + fields = Fields.browse([col['id'] + for name, col in cols.iteritems() + if name not in self._fields]) + # add key '_force_unlink' in context to (1) force the removal of the + # fields and (2) not reload the registry + fields.with_context(_force_unlink=True).unlink() + self.invalidate_cache() @api.model @@ -287,7 +296,7 @@ class BaseModel(object): This method should only be used for manual fields. """ cls = type(self) - field = cls._fields.pop(name) + field = cls._fields.pop(name, None) if hasattr(cls, name): delattr(cls, name) return field diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index 8ff70b84eb1..068a194c77b 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -262,7 +262,7 @@ class Registry(Mapping): model = cls._build_model(self, cr) model_names.append(model._name) - return self.descendants(model_names, '_inherit') + return self.descendants(model_names, '_inherit', '_inherits') def setup_models(self, cr, partial=False): """ Complete the setup of models. diff --git a/odoo/osv/orm.py b/odoo/osv/orm.py index 2e383ad0d9e..6a815c9577a 100644 --- a/odoo/osv/orm.py +++ b/odoo/osv/orm.py @@ -118,13 +118,13 @@ def test_modifiers(what, expected): node = etree.fromstring(what) transfer_node_to_modifiers(node, modifiers) simplify_modifiers(modifiers) - json = json.dumps(modifiers) - assert json == expected, "%s != %s" % (json, expected) + dump = json.dumps(modifiers) + assert dump == expected, "%s != %s" % (dump, expected) elif isinstance(what, dict): transfer_field_to_modifiers(what, modifiers) simplify_modifiers(modifiers) - json = json.dumps(modifiers) - assert json == expected, "%s != %s" % (json, expected) + dump = json.dumps(modifiers) + assert dump == expected, "%s != %s" % (dump, expected) # To use this test: