diff --git a/addons/account_followup/tests/test_account_followup.py b/addons/account_followup/tests/test_account_followup.py index 9e70430c518..47c55b45d7c 100644 --- a/addons/account_followup/tests/test_account_followup.py +++ b/addons/account_followup/tests/test_account_followup.py @@ -1,9 +1,8 @@ - - import datetime from openerp import tools from openerp.tests.common import TransactionCase +from openerp.osv import fields class TestAccountFollowup(TransactionCase): def setUp(self): @@ -45,14 +44,15 @@ class TestAccountFollowup(TransactionCase): self.registry('account.invoice').signal_invoice_open(cr, uid, [self.invoice_id]) self.voucher = self.registry("account.voucher") + + self.current_date = datetime.datetime.strptime(fields.date.context_today(self.user, cr, uid, context={}), tools.DEFAULT_SERVER_DATE_FORMAT) def test_00_send_followup_after_3_days(self): """ Send follow up after 3 days and check nothing is done (as first follow-up level is only after 15 days)""" cr, uid = self.cr, self.uid - current_date = datetime.datetime.utcnow() delta = datetime.timedelta(days=3) - result = current_date + delta + result = self.current_date + delta self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT), 'followup_id': self.followup_id }, context={"followup_id": self.followup_id}) @@ -62,33 +62,32 @@ class TestAccountFollowup(TransactionCase): def run_wizard_three_times(self): cr, uid = self.cr, self.uid - current_date = datetime.datetime.utcnow() delta = datetime.timedelta(days=40) - result = current_date + delta + result = self.current_date + delta + result = self.current_date + delta self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT), 'followup_id': self.followup_id }, context={"followup_id": self.followup_id}) - self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id, 'tz':'UTC'}) + self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id}) self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT), 'followup_id': self.followup_id }, context={"followup_id": self.followup_id}) - self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id, 'tz':'UTC'}) + self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id}) self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT), 'followup_id': self.followup_id, }, context={"followup_id": self.followup_id}) - self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id, 'tz':'UTC'}) + self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id}) def test_01_send_followup_later_for_upgrade(self): """ Send one follow-up after 15 days to check it upgrades to level 1""" cr, uid = self.cr, self.uid - current_date = datetime.datetime.utcnow() delta = datetime.timedelta(days=15) - result = current_date + delta + result = self.current_date + delta self.wizard_id = self.wizard.create(cr, uid, { 'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT), 'followup_id': self.followup_id }, context={"followup_id": self.followup_id}) - self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id, 'tz':'UTC'}) + self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id}) self.assertEqual(self.partner.browse(cr, uid, self.partner_id).latest_followup_level_id.id, self.first_followup_line_id, "Not updated to the correct follow-up level") @@ -99,7 +98,7 @@ class TestAccountFollowup(TransactionCase): self.assertEqual(self.partner.browse(cr, uid, self.partner_id).payment_next_action, "Call the customer on the phone! ", "Manual action not set") self.assertEqual(self.partner.browse(cr, uid, self.partner_id).payment_next_action_date, - datetime.datetime.utcnow().strftime(tools.DEFAULT_SERVER_DATE_FORMAT)) + self.current_date.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)) def test_03_filter_on_credit(self): """ Check the partners can be filtered on having credits """ @@ -136,9 +135,8 @@ class TestAccountFollowup(TransactionCase): """Run wizard until manual action, pay the invoice and check that partner has no follow-up level anymore and after running the wizard the action is empty""" cr, uid = self.cr, self.uid self.test_02_check_manual_action() - current_date = datetime.datetime.utcnow() delta = datetime.timedelta(days=1) - result = current_date + delta + result = self.current_date + delta self.invoice.pay_and_reconcile(cr, uid, [self.invoice_id], 1000.0, self.pay_account_id, self.period_id, self.journal_id, self.pay_account_id, self.period_id, self.journal_id, diff --git a/addons/project_timesheet/test/work_timesheet.yml b/addons/project_timesheet/test/work_timesheet.yml index d8367e9f7d8..9c28ec3a76f 100644 --- a/addons/project_timesheet/test/work_timesheet.yml +++ b/addons/project_timesheet/test/work_timesheet.yml @@ -12,8 +12,8 @@ I check Timesheet line for employee in current Timesheet - !python {model: hr.analytic.timesheet}: | - import datetime - start = (datetime.date.today().strftime('%Y-%m-%d')) + from openerp.osv import fields + start = fields.date.context_today(self, cr, uid, context=context) task_work = self.search(cr, uid, [("name","=","Social network integration: Test Timesheet records")],context)[0] task_ids = self.browse(cr, uid, task_work, context) assert task_ids.user_id.id == ref("base.user_demo"), 'Error, The User in Timesheet is not Correct' diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 0039399e378..bd273d2779d 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -148,19 +148,6 @@ class purchase_order(osv.osv): limit=1) return res and res[0] or False - def _has_non_stockable_item(self, cr, uid, ids, *args): - res = dict.fromkeys(ids, False) - for order in self.browse(cr, uid, ids): - for order_line in order.order_line: - if ( - not order_line.product_id - or - order_line.product_id - and order_line.product_id.type not in ('product', 'consu') - ): - res[order.id] = True - return res - STATE_SELECTION = [ ('draft', 'Draft PO'), ('sent', 'RFQ Sent'), @@ -237,7 +224,6 @@ class purchase_order(osv.osv): 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), - 'has_non_stockable_item': fields.function(_has_non_stockable_item, method=True, type='boolean', string='Contains a non-stockable item'), } _defaults = { 'date_order': fields.date.context_today, @@ -488,10 +474,10 @@ class purchase_order(osv.osv): for po in self.browse(cr, uid, ids, context=context): if not po.order_line: raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase order line.')) - if po.invoice_method == 'picking' and po.has_non_stockable_item is True: + if po.invoice_method == 'picking' and not any([l.product_id and l.product_id.type in ('product', 'consu') for l in po.order_line]): raise osv.except_osv( _('Error!'), - _("You cannot confirm a purchase order with Invoice Control Method 'Based on incoming shipments' that contains non-stockable items.")) + _("You cannot confirm a purchase order with Invoice Control Method 'Based on incoming shipments' that doesn't contain any stockable item.")) for line in po.order_line: if line.state=='draft': todo.append(line.id) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 35cc52ad1dd..321611dd398 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4097,8 +4097,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ this.records .bind('add', this.proxy("changed_records")) - .bind('edit', this.proxy("changed_records")) .bind('remove', this.proxy("changed_records")); + this.on('save:after', this, this.proxy("changed_records")); }, start: function () { var ret = this._super(); @@ -4115,7 +4115,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ if (!this.fields_view || !this.editable()){ return true; } - var r; if (_.isEmpty(this.records.records)){ return true; } @@ -4126,9 +4125,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ current_values[field.name] = field.get('value'); }); var valid = _.every(this.records.records, function(record){ - r = record; _.each(self.editor.form.fields, function(field){ - field.set_value(r.attributes[field.name]); + field.set_value(record.attributes[field.name]); }); return _.every(self.editor.form.fields, function(field){ field.process_modifiers();