summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-09-15 18:09:39 +0200
committerChristophe Simonis <chs@odoo.com>2017-09-15 18:09:39 +0200
commit66ca68732431dd6bfc3c6df1fe17ef6fab98da40 (patch)
treedc6ad0715b030fadddc5ed502aac9ba01a58a1b4
parent6aebc800538b6fabd79c6cd1e819ef6d961e7589 (diff)
parented901bedcb7c8b840ae5cf4731b946e998b8b141 (diff)
[MERGE] forward port branch saas-17 up to ed901bedcb7
-rw-r--r--addons/account/i18n/account.pot6
-rw-r--r--addons/account/models/account_invoice.py2
-rw-r--r--addons/account/models/account_payment.py2
-rw-r--r--addons/account/report/account_invoice_report.py2
-rw-r--r--addons/base_vat/models/res_partner.py10
-rw-r--r--addons/l10n_mx/models/chart_template.py1
-rw-r--r--addons/mass_mailing/models/mass_mailing_stats.py3
-rw-r--r--addons/mrp/models/mrp_workorder.py4
-rw-r--r--addons/mrp/views/mrp_workorder_views.xml3
-rw-r--r--addons/purchase/models/stock.py8
-rw-r--r--addons/stock/models/stock_move.py1
-rw-r--r--addons/stock/models/stock_picking.py50
-rw-r--r--addons/stock/views/stock_move_views.xml66
-rw-r--r--addons/stock/views/stock_production_lot_views.xml2
-rw-r--r--addons/stock/views/stock_quant_views.xml2
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js8
-rw-r--r--addons/web/static/src/js/fields/upgrade_fields.js22
-rw-r--r--addons/web/static/src/js/views/form/form_renderer.js9
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_model.js3
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_renderer.js6
-rw-r--r--addons/web/static/src/js/views/list/list_editable_renderer.js3
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js50
-rw-r--r--addons/web/static/tests/fields/upgrade_fields_tests.js22
-rw-r--r--addons/web/static/tests/helpers/mock_server.js4
-rw-r--r--addons/web/static/tests/views/kanban_tests.js81
-rw-r--r--addons/web/static/tests/views/list_tests.js49
-rw-r--r--addons/website_customer/security/ir.model.access.csv3
-rw-r--r--addons/website_sale/static/src/js/website_sale_payment.js5
-rw-r--r--odoo/addons/base/ir/ir_model.py6
-rw-r--r--odoo/modules/migration.py68
-rw-r--r--odoo/service/model.py4
31 files changed, 354 insertions, 151 deletions
diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot
index 3d8be6134ce..6a2d2722232 100644
--- a/addons/account/i18n/account.pot
+++ b/addons/account/i18n/account.pot
@@ -9689,6 +9689,12 @@ msgid "You have"
msgstr ""
#. module: account
+#: code:addons/account/models/account_payment.py:360
+#, python-format
+msgid "You have to define a sequence for %s in your company."
+msgstr ""
+
+#. module: account
#: code:addons/account/wizard/account_report_general_ledger.py:21
#, python-format
msgid "You must define a Start Date"
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py
index 77a0dc50c3a..1e76dbc4b63 100644
--- a/addons/account/models/account_invoice.py
+++ b/addons/account/models/account_invoice.py
@@ -122,7 +122,7 @@ class AccountInvoice(models.Model):
def _get_outstanding_info_JSON(self):
self.outstanding_credits_debits_widget = json.dumps(False)
if self.state == 'open':
- domain = [('account_id', '=', self.account_id.id), ('partner_id', '=', self.env['res.partner']._find_accounting_partner(self.partner_id).id), ('reconciled', '=', False), ('amount_residual', '!=', 0.0)]
+ domain = [('account_id', '=', self.account_id.id), ('partner_id', '=', self.env['res.partner']._find_accounting_partner(self.partner_id).id), ('reconciled', '=', False), '|', ('amount_residual', '!=', 0.0), ('amount_residual_currency', '!=', 0.0)]
if self.type in ('out_invoice', 'in_refund'):
domain.extend([('credit', '>', 0), ('debit', '=', 0)])
type_payment = _('Outstanding credits')
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index 4bae1793ddd..e3b923aca12 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -473,6 +473,8 @@ class account_payment(models.Model):
if rec.payment_type == 'outbound':
sequence_code = 'account.payment.supplier.invoice'
rec.name = self.env['ir.sequence'].with_context(ir_sequence_date=rec.payment_date).next_by_code(sequence_code)
+ if not rec.name and self.payment_type != 'transfer':
+ raise UserError(_("You have to define a sequence for %s in your company.") % (sequence_code,))
# Create the journal entry
amount = rec.amount * (rec.payment_type in ('outbound', 'transfer') and 1 or -1)
diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py
index 1bcfab43b06..4753ce92a86 100644
--- a/addons/account/report/account_invoice_report.py
+++ b/addons/account/report/account_invoice_report.py
@@ -110,7 +110,7 @@ class AccountInvoiceReport(models.Model):
ai.type, ai.state, pt.categ_id, ai.date_due, ai.account_id, ail.account_id AS account_line_id,
ai.partner_bank_id,
SUM ((invoice_type.sign * ail.quantity) / u.factor * u2.factor) AS product_qty,
- SUM(ail.price_subtotal_signed) AS price_total,
+ SUM(ail.price_subtotal_signed * invoice_type.sign) AS price_total,
SUM(ABS(ail.price_subtotal_signed)) / CASE
WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric
THEN SUM(ail.quantity / u.factor * u2.factor)
diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py
index b2525706da5..dc547b2c422 100644
--- a/addons/base_vat/models/res_partner.py
+++ b/addons/base_vat/models/res_partner.py
@@ -200,11 +200,11 @@ class ResPartner(models.Model):
# Mexican VAT verification, contributed by Vauxoo
# and Panos Christeas <p_christ@hol.gr>
- __check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
- r"[ \-_]?" \
- r"(?P<ano>[0-9]{2})(?P<mes>[01][0-9])(?P<dia>[0-3][0-9])" \
- r"[ \-_]?" \
- r"(?P<code>[A-Za-z0-9&\xd1\xf1]{3})$")
+ __check_vat_mx_re = re.compile(br"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
+ br"[ \-_]?" \
+ br"(?P<ano>[0-9]{2})(?P<mes>[01][0-9])(?P<dia>[0-3][0-9])" \
+ br"[ \-_]?" \
+ br"(?P<code>[A-Za-z0-9&\xd1\xf1]{3})$")
def check_vat_mx(self, vat):
''' Mexican VAT verification
diff --git a/addons/l10n_mx/models/chart_template.py b/addons/l10n_mx/models/chart_template.py
index 4e1397073ba..d6607a7a359 100644
--- a/addons/l10n_mx/models/chart_template.py
+++ b/addons/l10n_mx/models/chart_template.py
@@ -16,6 +16,7 @@ class AccountChartTemplate(models.Model):
if not self == self.env.ref('l10n_mx.mx_coa'):
return res
journal_basis = self.env['account.journal'].search([
+ ('company_id', '=', company.id),
('type', '=', 'general'),
('code', '=', 'CBMX')], limit=1)
company.write({'tax_cash_basis_journal_id': journal_basis.id})
diff --git a/addons/mass_mailing/models/mass_mailing_stats.py b/addons/mass_mailing/models/mass_mailing_stats.py
index 2b22ae1d508..91648f22d35 100644
--- a/addons/mass_mailing/models/mass_mailing_stats.py
+++ b/addons/mass_mailing/models/mass_mailing_stats.py
@@ -20,7 +20,8 @@ class MailMailStats(models.Model):
string='Mail ID (tech)',
help='ID of the related mail_mail. This field is an integer field because '
'the related mail_mail can be deleted separately from its statistics. '
- 'However the ID is needed for several action and controllers.'
+ 'However the ID is needed for several action and controllers.',
+ index=True,
)
message_id = fields.Char(string='Message-ID')
model = fields.Char(string='Document model')
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index 89a89fcaf55..9c39ab507d4 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -127,6 +127,10 @@ class MrpWorkorder(models.Model):
'Capacity', default=1.0,
help="Number of pieces that can be produced in parallel.")
+ @api.multi
+ def name_get(self):
+ return [(wo.id, "%s - %s - %s" % (wo.production_id.name, wo.product_id.name, wo.name)) for wo in self]
+
@api.one
@api.depends('production_id.product_qty', 'qty_produced')
def _compute_is_produced(self):
diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml
index dc4f003ffb6..b0ee656152d 100644
--- a/addons/mrp/views/mrp_workorder_views.xml
+++ b/addons/mrp/views/mrp_workorder_views.xml
@@ -363,6 +363,7 @@
<field name="view_mode">gantt,tree,form,calendar,pivot,graph</field>
<field name="search_view_id" ref="view_mrp_production_workcenter_form_view_filter"/>
<field name="view_id" ref="mrp_workorder_view_gantt"/>
+ <field name="context">{'search_default_work_center': True}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Work Orders are operations to be processed at a Work Center to realize a
@@ -379,7 +380,9 @@
<field name="view_type">form</field>
<field name="domain">[('production_state','not in',('done','cancel'))]</field>
<field name="view_mode">gantt,tree,form,calendar,pivot,graph</field>
+ <field name="search_view_id" ref="view_mrp_production_workcenter_form_view_filter"/>
<field name="view_id" ref="workcenter_line_gantt_production"/>
+ <field name="context">{'search_default_production': True}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to start a new work order.
diff --git a/addons/purchase/models/stock.py b/addons/purchase/models/stock.py
index 1f02f4cc8d2..64aa739daaa 100644
--- a/addons/purchase/models/stock.py
+++ b/addons/purchase/models/stock.py
@@ -16,10 +16,10 @@ class StockPicking(models.Model):
res = super(StockPicking, self)._create_backorder(backorder_moves)
for picking in self:
if picking.picking_type_id.code == 'incoming':
- backorder = self.search([('backorder_id', '=', picking.id)])
- backorder.message_post_with_view('mail.message_origin_link',
- values={'self': backorder, 'origin': backorder.purchase_id},
- subtype_id=self.env.ref('mail.mt_note').id)
+ for backorder in self.search([('backorder_id', '=', picking.id)]):
+ backorder.message_post_with_view('mail.message_origin_link',
+ values={'self': backorder, 'origin': backorder.purchase_id},
+ subtype_id=self.env.ref('mail.mt_note').id)
return res
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 874a819acae..a6b1af3664b 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -864,7 +864,6 @@ class StockMove(models.Model):
# If you were already putting stock.move.lots on the next one in the work order, transfer those to the new move
move.move_line_ids.filtered(lambda x: x.qty_done == 0.0).write({'move_id': new_move})
- self.browse(new_move).quantity_done = 0.0
move.move_line_ids._action_done()
picking = self and self[0].picking_id or False
moves_todo.write({'state': 'done', 'date': fields.Datetime.now()})
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 40cd8c8700f..afb80b4c44d 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -662,56 +662,6 @@ class Picking(models.Model):
quantity_done[pack.product_id.id] += pack.qty_done
return any(quantity_done[x] < quantity_todo.get(x, 0) for x in quantity_done)
- def _create_extra_moves(self):
- '''This function creates move lines on a picking, at the time of do_transfer, based on
- unexpected product transfers (or exceeding quantities) found in the pack operations.
- '''
- # TDE FIXME: move to batch
- self.ensure_one()
- moves = self.env['stock.move']
- for move_line in self.move_line_ids:
- for product, remaining_qty in move_line._get_remaining_prod_quantities().items():
- if float_compare(remaining_qty, 0, precision_rounding=product.uom_id.rounding) > 0:
- vals = self._prepare_values_extra_move(move_line, product, remaining_qty)
- moves |= moves.create(vals)
- if moves:
- moves.with_context(skip_check=True)._action_confirm()
- return moves
-
- @api.model
- def _prepare_values_extra_move(self, op, product, remaining_qty):
- """
- Creates an extra move when there is no corresponding original move to be copied
- """
- Uom = self.env["product.uom"]
- uom_id = product.uom_id.id
- qty = remaining_qty
- if op.product_id and op.product_uom_id and op.product_uom_id.id != product.uom_id.id:
- if op.product_uom_id.factor > product.uom_id.factor: # If the pack operation's is a smaller unit
- uom_id = op.product_uom_id.id
- # HALF-UP rounding as only rounding errors will be because of propagation of error from default UoM
- qty = product.uom_id._compute_quantity(remaining_qty, op.product_uom_id, rounding_method='HALF-UP')
- picking = op.picking_id
- ref = product.default_code
- name = '[' + ref + ']' + ' ' + product.name if ref else product.name
- proc_id = False
- for m in op.linked_move_operation_ids:
- if m.move_id.procurement_id:
- proc_id = m.move_id.procurement_id.id
- break
- return {
- 'picking_id': picking.id,
- 'location_id': picking.location_id.id,
- 'location_dest_id': picking.location_dest_id.id,
- 'product_id': product.id,
- 'product_uom': uom_id,
- 'product_uom_qty': qty,
- 'name': _('Extra Move: ') + name,
- 'state': 'draft',
- 'restrict_partner_id': op.owner_id.id,
- 'group_id': picking.group_id.id,
- }
-
def _create_backorder(self, backorder_moves=[]):
""" Move all non-done lines into a new backorder picking. If the key 'do_only_split' is given in the context, then move all lines not in context.get('split', []) instead of all non-done lines.
"""
diff --git a/addons/stock/views/stock_move_views.xml b/addons/stock/views/stock_move_views.xml
index c4c360774e6..195579065ab 100644
--- a/addons/stock/views/stock_move_views.xml
+++ b/addons/stock/views/stock_move_views.xml
@@ -156,25 +156,7 @@
</group>
</group>
- <field name="move_line_ids" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
- <tree editable="bottom" decoration-succes="product_uom_qty==qty_done" decoration-danger="qty_done > product_uom_qty)">
- <field name="picking_id" invisible="1"/>
- <field name="product_id" invisible="1"/>
- <field name="location_id" invisible="not context.get('show_source_location')" domain="[('id', 'child_of', parent.location_id)])" groups="stock.group_stock_multi_locations"/>
- <field name="location_dest_id" invisible="not context.get('show_destination_location')" domain="[('id', 'child_of', parent.location_dest_id)]" groups="stock.group_stock_multi_locations"/>
- <field name="lot_id" invisible="not context.get('show_lots_m2o')" domain="[('product_id', '=', parent.product_id)]" groups="stock.group_production_lot" context="{'default_product_id': parent.product_id, 'active_picking_id': picking_id}"/>
- <field name="lot_name" invisible="not context.get('show_lots_text')" groups="stock.group_production_lot"/>
- <field name="package_id" invisible="not context.get('show_package')" groups="stock.group_tracking_lot"/>
- <field name="result_package_id" groups="stock.group_tracking_lot"/>
- <field name="owner_id" groups="stock.group_tracking_owner"/>
- <field name="is_initial_demand_editable" invisible="1"/>
- <field name="product_uom_qty" invisible="not context.get('show_reserved_quantity')" readonly="1"/>
- <field name="state" invisible="1"/>
- <field name="is_locked" invisible="1"/>
- <field name="qty_done" attrs="{'readonly': ['|', ('is_initial_demand_editable', '=', True), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}"/>
- <field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': [('product_uom_qty', '!=', 0.0)]}" string="Unit of Measure" groups="product.group_uom"/>
- </tree>
- </field>
+ <field name="move_line_ids" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'tree_view_ref': 'stock.view_stock_move_line_operation_tree', 'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"/>
<footer class="oe_edit_only">
<button string="Confirm" special="save" class="oe_highlight"/>
<button string="Discard" special="cancel"/>
@@ -190,31 +172,37 @@
<field name="mode">primary</field>
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
<field name="arch" type="xml">
- <field name="move_line_ids" position="before">
- <field name="quantity_done" readonly="1"/>
- <field name="product_uom_qty" readonly="1"/>
- </field>
<field name="move_line_ids" position="replace">
- <field name="move_line_nosuggest_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" context="{'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
- <tree editable="bottom" decoration-succes="product_uom_qty==qty_done" decoration-danger="(product_uom_qty &gt; 0) and (qty_done&gt;product_uom_qty)">
- <field name="location_id" invisible="context.get('hide_source')" domain="[('id', 'child_of', parent.location_id)])" groups="stock.group_stock_multi_locations"/>
- <field name="package_id" groups="stock.group_tracking_lot" invisible="context.get('from_supplier')"/>
- <field name="lot_id" domain="[('product_id', '=', parent.product_id)]" invisible="context.get('show_lots_inv', True)" context="{'default_product_id': parent.product_id}"/>
- <field name="lot_name" invisible="context.get('show_lots_name_inv', True)"/>
- <field name="product_uom_qty" invisible="1"/>
- <field name="location_dest_id" invisible="context.get('hide_dest')" domain="[('id', 'child_of', parent.location_dest_id)]" groups="stock.group_stock_multi_locations"/>
- <field name="qty_done"/>
- <field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': [('product_uom_qty', '!=', 0.0)]}" string="Unit of Measure" groups="product.group_uom"/>
- <field name="result_package_id" groups="stock.group_tracking_lot"/>
- <field name="owner_id" groups="stock.group_tracking_owner"/>
- <field name="picking_id" invisible="1"/>
- <field name="product_id" invisible="1"/>
- </tree>
- </field>
+ <field name="move_line_nosuggest_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" context="{'tree_view_ref': 'stock.view_stock_move_line_operation_tree','default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"/>
</field>
</field>
</record>
+ <record id="view_stock_move_line_operation_tree" model="ir.ui.view">
+ <field name="name">stock.move.line.operations.tree</field>
+ <field name="model">stock.move.line</field>
+ <field name="priority">1000</field>
+ <field name="arch" type="xml">
+ <tree editable="bottom" decoration-succes="product_uom_qty==qty_done" decoration-danger="qty_done > product_uom_qty)">
+ <field name="picking_id" invisible="1"/>
+ <field name="product_id" invisible="1"/>
+ <field name="location_id" invisible="not context.get('show_source_location')" domain="[('id', 'child_of', parent.location_id)])" groups="stock.group_stock_multi_locations"/>
+ <field name="location_dest_id" invisible="not context.get('show_destination_location')" domain="[('id', 'child_of', parent.location_dest_id)]" groups="stock.group_stock_multi_locations"/>
+ <field name="lot_id" invisible="not context.get('show_lots_m2o')" domain="[('product_id', '=', parent.product_id)]" groups="stock.group_production_lot" context="{'default_product_id': parent.product_id, 'active_picking_id': picking_id}"/>
+ <field name="lot_name" invisible="not context.get('show_lots_text')" groups="stock.group_production_lot"/>
+ <field name="package_id" invisible="not context.get('show_package')" groups="stock.group_tracking_lot"/>
+ <field name="result_package_id" groups="stock.group_tracking_lot"/>
+ <field name="owner_id" groups="stock.group_tracking_owner"/>
+ <field name="is_initial_demand_editable" invisible="1"/>
+ <field name="product_uom_qty" invisible="not context.get('show_reserved_quantity')" readonly="1"/>
+ <field name="state" invisible="1"/>
+ <field name="is_locked" invisible="1"/>
+ <field name="qty_done" attrs="{'readonly': ['|', ('is_initial_demand_editable', '=', True), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}"/>
+ <field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': [('product_uom_qty', '!=', 0.0)]}" string="Unit of Measure" groups="product.group_uom"/>
+ </tree>
+ </field>
+ </record>
+
<record id="view_move_form" model="ir.ui.view">
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
diff --git a/addons/stock/views/stock_production_lot_views.xml b/addons/stock/views/stock_production_lot_views.xml
index 0f6a934832b..98347b3beef 100644
--- a/addons/stock/views/stock_production_lot_views.xml
+++ b/addons/stock/views/stock_production_lot_views.xml
@@ -28,7 +28,7 @@
<label for="product_qty"/>
<div class="o_row">
<field name="product_qty"/>
- <field name="product_uom_id" groups="product.group_uom"/>
+ <field name="product_uom_id" readonly="1" groups="product.group_uom"/>
</div>
<field name="ref"/>
</group>
diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml
index f3160638a4d..792399b62d3 100644
--- a/addons/stock/views/stock_quant_views.xml
+++ b/addons/stock/views/stock_quant_views.xml
@@ -74,7 +74,7 @@
<field name="model">stock.quant</field>
<field eval="10" name="priority"/>
<field name="arch" type="xml">
- <tree string="Inventory Valuation" create="0" delete="0">
+ <tree string="Inventory Valuation" create="0" delete="0" decoration-danger="quantity &lt; 0">
<field name="product_id"/>
<field name="location_id"/>
<field name="lot_id" groups="stock.group_production_lot"/>
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index b5d779039d6..7df5b390a2c 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -94,8 +94,12 @@ var FieldMany2One = AbstractField.extend({
this._super.apply(this, arguments);
this.limit = 7;
this.orderer = new concurrency.DropMisordered();
- this.can_create = ('can_create' in this.attrs ? this.attrs.can_create : true) && !this.nodeOptions.no_create;
- this.can_write = 'can_write' in this.attrs ? this.attrs.can_write : true;
+
+ // should normally also be set, except in standalone M20
+ this.can_create = ('can_create' in this.attrs ? JSON.parse(this.attrs.can_create) : true) &&
+ !this.nodeOptions.no_create;
+ this.can_write = 'can_write' in this.attrs ? JSON.parse(this.attrs.can_write) : true;
+
this.nodeOptions = _.defaults(this.nodeOptions, {
quick_create: true,
});
diff --git a/addons/web/static/src/js/fields/upgrade_fields.js b/addons/web/static/src/js/fields/upgrade_fields.js
index 4c3b26b9802..9d61036ab8b 100644
--- a/addons/web/static/src/js/fields/upgrade_fields.js
+++ b/addons/web/static/src/js/fields/upgrade_fields.js
@@ -52,9 +52,9 @@ var AbstractFieldUpgrade = {
*
* @abstract
* @private
- * @param {JQuery} the 'Enterprise' label to insert
+ * @param {jQuery} $enterpriseLabel the 'Enterprise' label to insert
*/
- _insertEnterpriseLabel: function ($enterprise_label) {},
+ _insertEnterpriseLabel: function ($enterpriseLabel) {},
/**
* Opens the Upgrade dialog.
*
@@ -127,6 +127,15 @@ var UpgradeBoolean = FieldBoolean.extend(AbstractFieldUpgrade, {
events: _.extend({}, AbstractField.prototype.events, {
'click input': '_onInputClicked',
}),
+ /**
+ * Re-renders the widget with the label
+ *
+ * @param {jQuery} $label
+ */
+ renderWithLabel: function ($label) {
+ this.$label = $label;
+ this._render();
+ },
//--------------------------------------------------------------------------
// Private
@@ -136,8 +145,9 @@ var UpgradeBoolean = FieldBoolean.extend(AbstractFieldUpgrade, {
* @override
* @private
*/
- _insertEnterpriseLabel: function ($enterprise_label) {
- this.$el.append('&nbsp;').append($enterprise_label);
+ _insertEnterpriseLabel: function ($enterpriseLabel) {
+ var $el = this.$label || this.$el;
+ $el.append('&nbsp;').append($enterpriseLabel);
},
/**
* @override
@@ -170,8 +180,8 @@ var UpgradeRadio = FieldRadio.extend(AbstractFieldUpgrade, {
* @override
* @private
*/
- _insertEnterpriseLabel: function ($enterprise_label) {
- this.$('label').last().append('&nbsp;').append($enterprise_label);
+ _insertEnterpriseLabel: function ($enterpriseLabel) {
+ this.$('label').last().append('&nbsp;').append($enterpriseLabel);
},
/**
* @override
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js
index 7d962e223ce..8f1724c3e64 100644
--- a/addons/web/static/src/js/views/form/form_renderer.js
+++ b/addons/web/static/src/js/views/form/form_renderer.js
@@ -805,11 +805,16 @@ var FormRenderer = BasicRenderer.extend({
// Attach the tooltips on the fields' label
_.each(this.allFieldWidgets[this.state.id], function (widget) {
+ var idForLabel = self.idsForLabels[widget.name];
+ var $label = idForLabel ? self.$('label[for=' + idForLabel + ']') : $();
if (core.debug || widget.attrs.help || widget.field.help) {
- var idForLabel = self.idsForLabels[widget.name];
- var $label = idForLabel ? self.$('label[for=' + idForLabel + ']') : $();
self._addFieldTooltip(widget, $label);
}
+ if (widget.attrs.widget === 'upgrade_boolean') {
+ // this widget needs a reference to its $label to be correctly
+ // rendered
+ widget.renderWithLabel($label);
+ }
});
},
/**
diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js
index 400d73c0b7d..04ee7012bc4 100644
--- a/addons/web/static/src/js/views/kanban/kanban_model.js
+++ b/addons/web/static/src/js/views/kanban/kanban_model.js
@@ -157,6 +157,9 @@ var KanbanModel = BasicModel.extend({
id: new_group.res_id,
display_name: new_group.value,
};
+ } else if (groupedField.type === 'selection') {
+ var value = _.findWhere(groupedField.selection, {1: new_group.value});
+ changes[groupedFieldName] = value && value[0] || false;
} else {
changes[groupedFieldName] = new_group.value;
}
diff --git a/addons/web/static/src/js/views/kanban/kanban_renderer.js b/addons/web/static/src/js/views/kanban/kanban_renderer.js
index 49752ca2678..b46d1f7c5fd 100644
--- a/addons/web/static/src/js/views/kanban/kanban_renderer.js
+++ b/addons/web/static/src/js/views/kanban/kanban_renderer.js
@@ -145,10 +145,10 @@ var KanbanRenderer = BasicRenderer.extend({
* @returns {Deferred}
*/
updateColumn: function (localID, columnState) {
- var column = _.findWhere(this.widgets, {db_id: localID});
- this.widgets.splice(_.indexOf(this.widgets, column), 1); // remove column from widgets' list
var newColumn = new KanbanColumn(this, columnState, this.columnOptions, this.recordOptions);
- this.widgets.push(newColumn);
+ var index = _.findIndex(this.widgets, {db_id: localID});
+ var column = this.widgets[index];
+ this.widgets[index] = newColumn;
return newColumn.insertAfter(column.$el).then(column.destroy.bind(column));
},
/**
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js
index 229c61733e5..7984ebf21e1 100644
--- a/addons/web/static/src/js/views/list/list_editable_renderer.js
+++ b/addons/web/static/src/js/views/list/list_editable_renderer.js
@@ -477,6 +477,9 @@ ListRenderer.include({
return this._selectRow(rowIndex).then(function () {
var record = self.state.data[rowIndex];
var correctedIndex = colIndex - getNbButtonBefore(colIndex);
+ if (correctedIndex >= (self.allFieldWidgets[record.id] || []).length) {
+ return $.Deferred().reject();
+ }
var fieldIndex = self._activateFieldWidget(record, correctedIndex, {
inc: 1,
wrap: wrap,
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 48245df73cf..fc969aeae87 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -1363,6 +1363,56 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('can_create and can_write option on a many2one', function (assert) {
+ assert.expect(5);
+
+ this.data.product.options = {
+ can_create: "false",
+ can_write: "false",
+ };
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<field name="product_id" can_create="false" can_write="false"/>' +
+ '</sheet>' +
+ '</form>',
+ archs: {
+ 'product,false,form': '<form string="Products"><field name="display_name"/></form>',
+ },
+ mockRPC: function (route) {
+ if (route === '/web/dataset/call_kw/product/get_formview_id') {
+ return $.when(false);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ form.$('.o_field_many2one input').click();
+ assert.strictEqual($('.ui-autocomplete .o_m2o_dropdown_option:contains(Create)').length, 0,
+ "there shouldn't be any option to search and create");
+
+ $('.ui-autocomplete li:contains(xpad)').mouseenter().click();
+ assert.strictEqual(form.$('.o_field_many2one input').val(), "xpad",
+ "the correct record should be selected");
+ assert.strictEqual(form.$('.o_field_many2one .o_external_button').length, 1,
+ "there should be an external button displayed");
+
+ form.$('.o_field_many2one .o_external_button').click();
+ assert.strictEqual($('.modal .o_form_view.o_form_readonly').length, 1,
+ "there should be a readonly form view opened");
+
+ $('.modal .o_form_button_cancel').click();
+
+ form.$('.o_field_many2one input').val('new product').trigger('keyup').trigger('focusout');
+
+ assert.strictEqual($('.modal').length, 0, "should not display the create modal");
+ form.destroy();
+ });
+
QUnit.test('pressing enter in a m2o in an editable list', function (assert) {
assert.expect(9);
var done = assert.async();
diff --git a/addons/web/static/tests/fields/upgrade_fields_tests.js b/addons/web/static/tests/fields/upgrade_fields_tests.js
index babc32b60a8..427ec7b54e3 100644
--- a/addons/web/static/tests/fields/upgrade_fields_tests.js
+++ b/addons/web/static/tests/fields/upgrade_fields_tests.js
@@ -39,6 +39,28 @@ QUnit.module('upgrade_fields', {
form.destroy();
});
+ QUnit.test('widget upgrade_boolean in a form view', function (assert) {
+ assert.expect(3);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form>' +
+ '<div class="o_field"><field name="bar" widget="upgrade_boolean"/></div>' +
+ '<div class="o_label"><label for="bar"/><div>Coucou</div></div>' +
+ '</form>',
+ });
+
+ assert.strictEqual(form.$('.o_field .label').length, 0,
+ "the upgrade label shouldn't be inside the field section");
+ assert.strictEqual(form.$('.o_label .label').length, 1,
+ "the upgrade label should be inside the label section");
+ assert.strictEqual(form.$('.o_label').text(), "Bar EnterpriseCoucou",
+ "the upgrade label should be inside the label section");
+ form.destroy();
+ });
+
});
});
});
diff --git a/addons/web/static/tests/helpers/mock_server.js b/addons/web/static/tests/helpers/mock_server.js
index 3cf69b323b8..5b559529371 100644
--- a/addons/web/static/tests/helpers/mock_server.js
+++ b/addons/web/static/tests/helpers/mock_server.js
@@ -255,6 +255,10 @@ var MockServer = Class.extend({
var relModel, relFields;
_.each(fieldNodes, function (node, name) {
var field = fields[name];
+ if (field.type === "many2one" || field.type === "many2many") {
+ node.attrs.can_create = node.attrs.can_create || "true";
+ node.attrs.can_write = node.attrs.can_write || "true";
+ }
if (field.type === "one2many" || field.type === "many2many") {
field.views = {};
_.each(node.children, function (children) {
diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js
index f070a6928a2..e2ec975f0f0 100644
--- a/addons/web/static/tests/views/kanban_tests.js
+++ b/addons/web/static/tests/views/kanban_tests.js
@@ -662,6 +662,48 @@ QUnit.module('Views', {
kanban.destroy();
});
+ QUnit.test('drag and drop a record, grouped by selection', function (assert) {
+ assert.expect(6);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '<kanban class="o_kanban_test" on_create="quick_create">' +
+ '<templates>' +
+ '<t t-name="kanban-box">' +
+ '<div><field name="state"/></div>' +
+ '</t>' +
+ '</templates>' +
+ '</kanban>',
+ groupBy: ['state'],
+ mockRPC: function (route, args) {
+ if (route === '/web/dataset/resequence') {
+ assert.ok(true, "should call resequence");
+ return $.when(true);
+ }
+ if (args.model === 'partner' && args.method === 'write') {
+ assert.deepEqual(args.args[1], {state: 'def'});
+ }
+ return this._super(route, args);
+ },
+ });
+ assert.strictEqual(kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record').length, 1,
+ "column should contain 1 record(s)");
+ assert.strictEqual(kanban.$('.o_kanban_group:nth-child(2) .o_kanban_record').length, 1,
+ "column should contain 1 record(s)");
+
+ var $record = kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record:first');
+ var $group = kanban.$('.o_kanban_group:nth-child(2)');
+ testUtils.dragAndDrop($record, $group);
+
+ assert.strictEqual(kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record').length, 0,
+ "column should now contain 0 record(s)");
+ assert.strictEqual(kanban.$('.o_kanban_group:nth-child(2) .o_kanban_record').length, 2,
+ "column should contain 2 record(s)");
+ kanban.destroy();
+ });
+
QUnit.test('kanban view with default_group_by', function (assert) {
assert.expect(7);
this.data.partner.records.product_id = 1;
@@ -1970,6 +2012,45 @@ QUnit.module('Views', {
"counter should display the sum of int_field values");
kanban.destroy();
});
+
+ QUnit.test('keep adding quickcreate in first column after a record from this column was moved', function (assert) {
+ assert.expect(2);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch:
+ '<kanban on_create="quick_create">' +
+ '<field name="int_field"/>' +
+ '<templates><t t-name="kanban-box">' +
+ '<div><field name="foo"/></div>' +
+ '</t></templates>' +
+ '</kanban>',
+ groupBy: ['int_field'],
+ mockRPC: function (route, args) {
+ if (route === '/web/dataset/resequence') {
+ return $.when(true);
+ }
+ return this._super(route, args);
+ },
+ });
+
+ var $quickCreateGroup;
+ var $groups;
+ _quickCreateAndTest();
+ testUtils.dragAndDrop($groups.first().find('.o_kanban_record:first'), $groups.eq(1));
+ _quickCreateAndTest();
+ kanban.destroy();
+
+ function _quickCreateAndTest() {
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ $quickCreateGroup = kanban.$('.o_kanban_quick_create').closest('.o_kanban_group');
+ $groups = kanban.$('.o_kanban_group');
+ assert.strictEqual($quickCreateGroup[0], $groups[0],
+ "quick create should have been added in the first column");
+ }
+ });
});
});
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 9585f154b80..f16194026dd 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -2275,6 +2275,55 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('skip buttons when navigating list view with TAB (end)', function (assert) {
+ assert.expect(2);
+
+ var list = createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '<tree editable="bottom">' +
+ '<field name="foo"/>' +
+ '<button name="kikou" string="Kikou" type="object"/>' +
+ '</tree>',
+ res_id: 1,
+ });
+
+ list.$('tbody tr:eq(2) td:eq(1)').click();
+ assert.strictEqual(list.$('tbody tr:eq(2) input[name="foo"]')[0], document.activeElement,
+ "foo should be focused");
+ list.$('tbody tr:eq(2) input[name="foo"]').trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
+ assert.strictEqual(list.$('tbody tr:eq(3) input[name="foo"]')[0], document.activeElement,
+ "next line should be selected");
+
+ list.destroy();
+ });
+
+ QUnit.test('skip buttons when navigating list view with TAB (middle)', function (assert) {
+ assert.expect(2);
+
+ var list = createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '<tree editable="bottom">' +
+ '<field name="foo"/>' +
+ '<button name="kikou" string="Kikou" type="object"/>' +
+ '<field name="int_field"/>' +
+ '</tree>',
+ res_id: 1,
+ });
+
+ list.$('tbody tr:eq(2) td:eq(1)').click();
+ assert.strictEqual(list.$('tbody tr:eq(2) input[name="foo"]')[0], document.activeElement,
+ "foo should be focused");
+ list.$('tbody tr:eq(2) input[name="foo"]').trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
+ assert.strictEqual(list.$('tbody tr:eq(2) input[name="int_field"]')[0], document.activeElement,
+ "int_field should be focused");
+
+ list.destroy();
+ });
+
QUnit.test('navigation: moving down with keydown', function (assert) {
assert.expect(2);
diff --git a/addons/website_customer/security/ir.model.access.csv b/addons/website_customer/security/ir.model.access.csv
index 1615f7348a6..06d30ba469a 100644
--- a/addons/website_customer/security/ir.model.access.csv
+++ b/addons/website_customer/security/ir.model.access.csv
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
res_partner_tag_sale_manager,res.partner.tag.sale.manager,model_res_partner_tag,,1,0,0,0
-res_partner_tag_sale_manager_edition,res.partner.tag.sale.manager.edition,model_res_partner_tag,sales_team.group_sale_manager,1,1,1,1 \ No newline at end of file
+res_partner_tag_sale_manager_edition,res.partner.tag.sale.manager.edition,model_res_partner_tag,sales_team.group_sale_manager,1,1,1,1
+res_partner_industry_all,res_partner_industry all,base.model_res_partner_industry,,1,0,0,0
diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js
index 5ceb1fbfb9a..8ac46658da9 100644
--- a/addons/website_sale/static/src/js/website_sale_payment.js
+++ b/addons/website_sale/static/src/js/website_sale_payment.js
@@ -4,9 +4,10 @@ odoo.define('website_sale.payment', function (require) {
$(document).ready(function () {
// If option is enable
if ($("#checkbox_cgv").length) {
- $("#checkbox_cgv").click(function() {
+ var enabling_button = function() {
$("button#o_payment_form_pay").prop("disabled", !this.checked);
- });
+ };
+ $("#checkbox_cgv").click(enabling_button).each(enabling_button);
}
});
diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py
index 73f1aa10ec2..891d95e5230 100644
--- a/odoo/addons/base/ir/ir_model.py
+++ b/odoo/addons/base/ir/ir_model.py
@@ -279,9 +279,9 @@ class IrModel(models.Model):
def _add_manual_models(self):
""" Add extra models to the registry. """
# clean up registry first
- for name, model_class in self.pool.items():
- if model_class._custom:
- del self.pool.models[name]
+ custom_models = [name for name, model_class in self.pool.items() if model_class._custom]
+ for name in custom_models:
+ del self.pool.models[name]
# add manual models
cr = self.env.cr
cr.execute('SELECT * FROM ir_model WHERE state=%s', ['manual'])
diff --git a/odoo/modules/migration.py b/odoo/modules/migration.py
index 8edc9586415..130b4ab1bb4 100644
--- a/odoo/modules/migration.py
+++ b/odoo/modules/migration.py
@@ -5,7 +5,6 @@
from collections import defaultdict
import glob
-import imp
import logging
import os
from os.path import join as opj
@@ -14,6 +13,37 @@ from odoo.modules.module import get_resource_path
import odoo.release as release
import odoo.tools as tools
from odoo.tools.parse_version import parse_version
+from odoo.tools import pycompat
+
+if pycompat.PY2:
+ import imp
+ def load_script(path, module_name):
+ fp, fname = tools.file_open(path, pathinfo=True)
+ fp2 = None
+
+ if not isinstance(fp, file): # pylint: disable=file-builtin
+ # imp.load_source need a real file object, so we create
+ # one from the file-like object we get from file_open
+ fp2 = os.tmpfile()
+ fp2.write(fp.read())
+ fp2.seek(0)
+
+ try:
+ return imp.load_source(module_name, fname, fp2 or fp)
+ finally:
+ if fp:
+ fp.close()
+ if fp2:
+ fp2.close()
+
+else:
+ import importlib.util
+ def load_script(path, module_name):
+ full_path = get_resource_path(*path.split(os.path.sep))
+ spec = importlib.util.spec_from_file_location(module_name, full_path)
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
_logger = logging.getLogger(__name__)
@@ -132,32 +162,18 @@ class MigrationManager(object):
name, ext = os.path.splitext(os.path.basename(pyfile))
if ext.lower() != '.py':
continue
- mod = fp = fp2 = None
+ mod = None
try:
- fp, fname = tools.file_open(pyfile, pathinfo=True)
-
- # FIXME: imp.load_source removed in P3, and so is the ``file`` object...
- if not isinstance(fp, file):# pylint: disable=file-builtin
- # imp.load_source need a real file object, so we create
- # one from the file-like object we get from file_open
- fp2 = os.tmpfile()
- fp2.write(fp.read())
- fp2.seek(0)
- try:
- mod = imp.load_source(name, fname, fp2 or fp)
- _logger.info('module %(addon)s: Running migration %(version)s %(name)s' % dict(strfmt, name=mod.__name__))
- migrate = mod.migrate
- except ImportError:
- _logger.exception('module %(addon)s: Unable to load %(stage)s-migration file %(file)s' % dict(strfmt, file=pyfile))
- raise
- except AttributeError:
- _logger.error('module %(addon)s: Each %(stage)s-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
- else:
- migrate(self.cr, pkg.installed_version)
+ mod = load_script(pyfile, name)
+ _logger.info('module %(addon)s: Running migration %(version)s %(name)s' % dict(strfmt, name=mod.__name__))
+ migrate = mod.migrate
+ except ImportError:
+ _logger.exception('module %(addon)s: Unable to load %(stage)s-migration file %(file)s' % dict(strfmt, file=pyfile))
+ raise
+ except AttributeError:
+ _logger.error('module %(addon)s: Each %(stage)s-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
+ else:
+ migrate(self.cr, pkg.installed_version)
finally:
- if fp:
- fp.close()
- if fp2:
- fp2.close()
if mod:
del mod
diff --git a/odoo/service/model.py b/odoo/service/model.py
index 47eeeab1af1..e263a581be2 100644
--- a/odoo/service/model.py
+++ b/odoo/service/model.py
@@ -115,8 +115,8 @@ def check(f):
except IntegrityError as inst:
registry = odoo.registry(dbname)
for key in registry._sql_error.keys():
- if key in inst[0]:
- raise ValidationError(tr(registry._sql_error[key], 'sql_constraint') or inst[0])
+ if key in inst.pgerror:
+ raise ValidationError(tr(registry._sql_error[key], 'sql_constraint') or inst.pgerror)
if inst.pgcode in (errorcodes.NOT_NULL_VIOLATION, errorcodes.FOREIGN_KEY_VIOLATION, errorcodes.RESTRICT_VIOLATION):
msg = _('The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set')
_logger.debug("IntegrityError", exc_info=True)