[MERGE] forward port of branch saas-3 up to f8a9405
This commit is contained in:
commit
c0496ed03a
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp.tests.common import TransactionCase
|
from openerp.tests.common import TransactionCase
|
||||||
|
from openerp.osv import fields
|
||||||
|
|
||||||
class TestAccountFollowup(TransactionCase):
|
class TestAccountFollowup(TransactionCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -46,13 +45,14 @@ class TestAccountFollowup(TransactionCase):
|
||||||
|
|
||||||
self.voucher = self.registry("account.voucher")
|
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):
|
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)"""
|
""" 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
|
cr, uid = self.cr, self.uid
|
||||||
current_date = datetime.datetime.utcnow()
|
|
||||||
delta = datetime.timedelta(days=3)
|
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),
|
self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
||||||
'followup_id': self.followup_id
|
'followup_id': self.followup_id
|
||||||
}, context={"followup_id": self.followup_id})
|
}, context={"followup_id": self.followup_id})
|
||||||
|
@ -61,33 +61,32 @@ class TestAccountFollowup(TransactionCase):
|
||||||
|
|
||||||
def run_wizard_three_times(self):
|
def run_wizard_three_times(self):
|
||||||
cr, uid = self.cr, self.uid
|
cr, uid = self.cr, self.uid
|
||||||
current_date = datetime.datetime.utcnow()
|
|
||||||
delta = datetime.timedelta(days=40)
|
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),
|
self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
||||||
'followup_id': self.followup_id
|
'followup_id': self.followup_id
|
||||||
}, context={"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),
|
self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
||||||
'followup_id': self.followup_id
|
'followup_id': self.followup_id
|
||||||
}, context={"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),
|
self.wizard_id = self.wizard.create(cr, uid, {'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
||||||
'followup_id': self.followup_id,
|
'followup_id': self.followup_id,
|
||||||
}, context={"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):
|
def test_01_send_followup_later_for_upgrade(self):
|
||||||
""" Send one follow-up after 15 days to check it upgrades to level 1"""
|
""" Send one follow-up after 15 days to check it upgrades to level 1"""
|
||||||
cr, uid = self.cr, self.uid
|
cr, uid = self.cr, self.uid
|
||||||
current_date = datetime.datetime.utcnow()
|
|
||||||
delta = datetime.timedelta(days=15)
|
delta = datetime.timedelta(days=15)
|
||||||
result = current_date + delta
|
result = self.current_date + delta
|
||||||
self.wizard_id = self.wizard.create(cr, uid, {
|
self.wizard_id = self.wizard.create(cr, uid, {
|
||||||
'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
'date':result.strftime(tools.DEFAULT_SERVER_DATE_FORMAT),
|
||||||
'followup_id': self.followup_id
|
'followup_id': self.followup_id
|
||||||
}, context={"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,
|
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")
|
"Not updated to the correct follow-up level")
|
||||||
|
|
||||||
|
@ -98,7 +97,7 @@ class TestAccountFollowup(TransactionCase):
|
||||||
self.assertEqual(self.partner.browse(cr, uid, self.partner_id).payment_next_action,
|
self.assertEqual(self.partner.browse(cr, uid, self.partner_id).payment_next_action,
|
||||||
"Call the customer on the phone! ", "Manual action not set")
|
"Call the customer on the phone! ", "Manual action not set")
|
||||||
self.assertEqual(self.partner.browse(cr, uid, self.partner_id).payment_next_action_date,
|
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):
|
def test_03_filter_on_credit(self):
|
||||||
""" Check the partners can be filtered on having credits """
|
""" Check the partners can be filtered on having credits """
|
||||||
|
@ -134,9 +133,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"""
|
"""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
|
cr, uid = self.cr, self.uid
|
||||||
self.test_02_check_manual_action()
|
self.test_02_check_manual_action()
|
||||||
current_date = datetime.datetime.utcnow()
|
|
||||||
delta = datetime.timedelta(days=1)
|
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.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, self.pay_account_id,
|
||||||
self.period_id, self.journal_id,
|
self.period_id, self.journal_id,
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
I check Timesheet line for employee in current Timesheet
|
I check Timesheet line for employee in current Timesheet
|
||||||
-
|
-
|
||||||
!python {model: hr.analytic.timesheet}: |
|
!python {model: hr.analytic.timesheet}: |
|
||||||
import datetime
|
from openerp.osv import fields
|
||||||
start = (datetime.date.today().strftime('%Y-%m-%d'))
|
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_work = self.search(cr, uid, [("name","=","Social network integration: Test Timesheet records")],context)[0]
|
||||||
task_ids = self.browse(cr, uid, task_work, context)
|
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'
|
assert task_ids.user_id.id == ref("base.user_demo"), 'Error, The User in Timesheet is not Correct'
|
||||||
|
|
|
@ -146,19 +146,6 @@ class purchase_order(osv.osv):
|
||||||
limit=1)
|
limit=1)
|
||||||
return res and res[0] or False
|
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
|
|
||||||
|
|
||||||
def _get_picking_in(self, cr, uid, context=None):
|
def _get_picking_in(self, cr, uid, context=None):
|
||||||
obj_data = self.pool.get('ir.model.data')
|
obj_data = self.pool.get('ir.model.data')
|
||||||
type_obj = self.pool.get('stock.picking.type')
|
type_obj = self.pool.get('stock.picking.type')
|
||||||
|
@ -308,7 +295,6 @@ class purchase_order(osv.osv):
|
||||||
'create_uid': fields.many2one('res.users', 'Responsible'),
|
'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)]}),
|
'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'),
|
'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'),
|
|
||||||
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
|
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
|
||||||
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
|
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
|
||||||
'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming shipment", required=True,
|
'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming shipment", required=True,
|
||||||
|
@ -557,10 +543,10 @@ class purchase_order(osv.osv):
|
||||||
for po in self.browse(cr, uid, ids, context=context):
|
for po in self.browse(cr, uid, ids, context=context):
|
||||||
if not po.order_line:
|
if not po.order_line:
|
||||||
raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase 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(
|
raise osv.except_osv(
|
||||||
_('Error!'),
|
_('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:
|
for line in po.order_line:
|
||||||
if line.state=='draft':
|
if line.state=='draft':
|
||||||
todo.append(line.id)
|
todo.append(line.id)
|
||||||
|
|
|
@ -4398,8 +4398,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
|
|
||||||
this.records
|
this.records
|
||||||
.bind('add', this.proxy("changed_records"))
|
.bind('add', this.proxy("changed_records"))
|
||||||
.bind('edit', this.proxy("changed_records"))
|
|
||||||
.bind('remove', this.proxy("changed_records"));
|
.bind('remove', this.proxy("changed_records"));
|
||||||
|
this.on('save:after', this, this.proxy("changed_records"));
|
||||||
},
|
},
|
||||||
start: function () {
|
start: function () {
|
||||||
var ret = this._super();
|
var ret = this._super();
|
||||||
|
@ -4416,7 +4416,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
if (!this.fields_view || !this.editable()){
|
if (!this.fields_view || !this.editable()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var r;
|
|
||||||
if (_.isEmpty(this.records.records)){
|
if (_.isEmpty(this.records.records)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4427,9 +4426,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||||
current_values[field.name] = field.get('value');
|
current_values[field.name] = field.get('value');
|
||||||
});
|
});
|
||||||
var valid = _.every(this.records.records, function(record){
|
var valid = _.every(this.records.records, function(record){
|
||||||
r = record;
|
|
||||||
_.each(self.editor.form.fields, function(field){
|
_.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){
|
return _.every(self.editor.form.fields, function(field){
|
||||||
field.process_modifiers();
|
field.process_modifiers();
|
||||||
|
|
Loading…
Reference in New Issue