Skip to content

Commit

Permalink
Merge remote-tracking branch 'odoo/11.0' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OCA-git-bot committed Oct 3, 2019
2 parents 463822c + feda44d commit 0b937b2
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 38 deletions.
3 changes: 1 addition & 2 deletions addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,7 @@ def _prepare_refund(self, invoice, date_invoice=None, date=None, description=Non

values['type'] = TYPE2REFUND[invoice['type']]
values['date_invoice'] = date_invoice or fields.Date.context_today(invoice)
if values.get('date_due', False) and values['date_invoice'] > values['date_due']:
values['date_due'] = values['date_invoice']
values['date_due'] = values['date_invoice']
values['state'] = 'draft'
values['number'] = False
values['origin'] = invoice.number
Expand Down
4 changes: 2 additions & 2 deletions addons/account/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,10 @@
<field name="tax_line_id" readonly="1" attrs="{'invisible': [('tax_line_id','=',False)]}"/>
<field name="tax_ids" widget="many2many_tags" readonly="1" attrs="{'invisible': [('tax_ids','=',[])]}"/>
</group>
<group string="Matching" attrs="{'invisible':[('full_reconcile_id','=',False), ('matched_debit_ids', '=', []),('matched_credit_ids', '=', [])]}">
<group string="Matching" attrs="{'invisible':[('matched_debit_ids', '=', []),('matched_credit_ids', '=', [])]}">
<label for="full_reconcile_id"/>
<div>
<field name="full_reconcile_id"/>
<field name="full_reconcile_id" attrs="{'invisible':[('full_reconcile_id','=',False)]}"/>
<field name="matched_debit_ids" invisible="1"/>
<field name="matched_credit_ids" invisible="1"/>
<button name="open_reconcile_view"
Expand Down
2 changes: 1 addition & 1 deletion addons/account/views/report_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<div class="clearfix">
<div id="total" class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed" style="min-width: 250px;max-width: 400px;">
<table class="table table-condensed" style="min-width: 250px;max-width: 400px;page-break-inside: avoid;">
<tr class="border-black" style="border-bottom:1px solid #dddddd;">
<td><strong>Subtotal</strong></td>
<td class="text-right">
Expand Down
4 changes: 2 additions & 2 deletions addons/account/views/report_journal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</div>
<div class="col-xs-3">
<strong>Entries Sorted By:</strong>
<p t-if="data['form'].get('sort_selection') != 'l.date'">Journal Entry Number</p>
<p t-if="data['form'].get('sort_selection') == 'l.date'">Date</p>
<p t-if="data['form'].get('sort_selection') == 'move_name'">Journal Entry Number</p>
<p t-if="data['form'].get('sort_selection') == 'date'">Date</p>
</div>
<div class="col-xs-3">
<strong>Target Moves:</strong>
Expand Down
50 changes: 24 additions & 26 deletions addons/hr_holidays/models/hr_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,18 @@ def _remove_resource_leave(self):

@api.multi
def action_draft(self):
for holiday in self:
if not holiday.can_reset:
raise UserError(_('Only an HR Manager or the concerned employee can reset to draft.'))
if holiday.state not in ['confirm', 'refuse']:
raise UserError(_('Leave request state must be "Refused" or "To Approve" in order to reset to Draft.'))
holiday.write({
'state': 'draft',
'first_approver_id': False,
'second_approver_id': False,
})
linked_requests = holiday.mapped('linked_request_ids')
for linked_request in linked_requests:
linked_request.action_draft()
if any(not holiday.can_reset for holiday in self):
raise UserError(_('Only an HR Manager or the concerned employee can reset to draft.'))
if any(holiday.state not in ['confirm', 'refuse'] for holiday in self):
raise UserError(_('Leave request state must be "Refused" or "To Approve" in order to reset to Draft.'))
self.write({
'state': 'draft',
'first_approver_id': False,
'second_approver_id': False,
})
linked_requests = self.mapped('linked_request_ids')
if linked_requests:
linked_requests.action_draft()
linked_requests.unlink()
return True

Expand Down Expand Up @@ -538,19 +537,18 @@ def action_refuse(self):
self._check_security_action_refuse()

current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
for holiday in self:
if holiday.state not in ['confirm', 'validate', 'validate1']:
raise UserError(_('Leave request must be confirmed or validated in order to refuse it.'))

if holiday.state == 'validate1':
holiday.write({'state': 'refuse', 'first_approver_id': current_employee.id})
else:
holiday.write({'state': 'refuse', 'second_approver_id': current_employee.id})
# Delete the meeting
if holiday.meeting_id:
holiday.meeting_id.unlink()
# If a category that created several holidays, cancel all related
holiday.linked_request_ids.action_refuse()
if any(holiday.state not in ['confirm', 'validate', 'validate1'] for holiday in self):
raise UserError(_('Leave request must be confirmed or validated in order to refuse it.'))

validated_holidays = self.filtered(lambda hol: hol.state == 'validate1')
validated_holidays.write({'state': 'refuse', 'first_approver_id': current_employee.id})
(self - validated_holidays).write({'state': 'refuse', 'second_approver_id': current_employee.id})
# Delete the meeting
self.mapped('meeting_id').unlink()
# If a category that created several holidays, cancel all related
linked_requests = self.mapped('linked_request_ids')
if linked_requests:
linked_requests.action_refuse()
self._remove_resource_leave()
return True

Expand Down
2 changes: 1 addition & 1 deletion addons/mail/models/mail_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):
# `datas` (binary field) could bloat the browse cache, triggerring
# soft/hard mem limits with temporary data.
attachments = [(a['datas_fname'], base64.b64decode(a['datas']), a['mimetype'])
for a in mail.attachment_ids.sudo().read(['datas_fname', 'datas', 'mimetype'])]
for a in mail.attachment_ids.sudo().read(['datas_fname', 'datas', 'mimetype']) if a['datas'] is not False]

# specific behavior to customize the send email for notified partners
email_list = []
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/js/fields/relational_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -2347,9 +2347,9 @@ var FieldReference = FieldMany2One.extend({
* @private
*/
_reset: function () {
this._super.apply(this, arguments);
var value = this.$('select').val();
this._setState();
this._super.apply(this, arguments);
this.$('select').val(this.value && this.value.model || value);
},
/**
Expand Down
53 changes: 53 additions & 0 deletions addons/web/static/tests/fields/relational_fields_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12929,6 +12929,59 @@ QUnit.module('relational_fields', {
form.destroy();
});

QUnit.test('interact with reference field changed by onchange', function (assert) {
assert.expect(2);
var done = assert.async();

var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;

this.data.partner.onchanges = {
bar: function (obj) {
if (!obj.bar) {
obj.reference = 'partner,1';
}
},
};
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<field name="bar"/>' +
'<field name="reference"/>' +
'</form>',
mockRPC: function (route, args) {
if (args.method === 'create') {
assert.deepEqual(args.args[0], {
bar: false,
reference: 'partner,4',
});
}
return this._super.apply(this, arguments);
},
});

// trigger the onchange to set a value for the reference field
form.$('.o_field_boolean input').click();

assert.strictEqual(form.$('.o_field_widget[name=reference] select').val(), 'partner');

// manually update reference field
var $dropdown = form.$('.o_field_widget[name=reference] input').autocomplete('widget');
form.$('.o_field_widget[name=reference] input').val('aaa').trigger('keydown');
concurrency.delay(0).then(function () {
$dropdown.find('li:first()').click(); // select 'aaa'

// save
form.$buttons.find('.o_form_button_save').click();

relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
done();
form.destroy();
});
});

QUnit.test('default_get and onchange with a reference field', function (assert) {
assert.expect(8);

Expand Down
2 changes: 1 addition & 1 deletion odoo/addons/base/ir/ir_attachment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="public"/>
</group>
<group string="History" groups="base.group_no_one">
<group string="History" groups="base.group_no_one" attrs="{'invisible':[('create_date','=',False)]}">
<label for="create_uid" string="Creation"/>
<div name="creation_div">
<field name="create_uid" readonly="1" class="oe_inline"/> on
Expand Down
4 changes: 2 additions & 2 deletions odoo/sql_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def undecimalize(symb, cr):

from . import tools
from .tools.func import frame_codeinfo
from .tools import pycompat
from .tools import pycompat, ustr

from .tools import parse_version as pv
if pv(psycopg2.__version__) < pv('2.7'):
Expand Down Expand Up @@ -232,7 +232,7 @@ def execute(self, query, params=None, log_exceptions=None):
res = self._obj.execute(query, params)
except Exception as e:
if self._default_log_exceptions if log_exceptions is None else log_exceptions:
_logger.error("bad query: %s\nERROR: %s", self._obj.query or query, e)
_logger.error("bad query: %s\nERROR: %s", ustr(self._obj.query or query), e)
raise

# simple query count is always computed
Expand Down

0 comments on commit 0b937b2

Please sign in to comment.