[MERGE] forward port of branch saas-3 up to 7ab4137
This commit is contained in:
commit
d9e48bae42
|
@ -1153,6 +1153,19 @@ class account_move(osv.osv):
|
|||
_description = "Account Entry"
|
||||
_order = 'id desc'
|
||||
|
||||
def account_assert_balanced(self, cr, uid, context=None):
|
||||
cr.execute("""\
|
||||
SELECT move_id
|
||||
FROM account_move_line
|
||||
WHERE state = 'valid'
|
||||
GROUP BY move_id
|
||||
HAVING abs(sum(debit) - sum(credit)) > 0.00001
|
||||
""")
|
||||
assert len(cr.fetchall()) == 0, \
|
||||
"For all Journal Items, the state is valid implies that the sum " \
|
||||
"of credits equals the sum of debits"
|
||||
return True
|
||||
|
||||
def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_id=False, context=None):
|
||||
'''
|
||||
Prepares and returns a dictionary of values, ready to be passed to create() based on the parameters received.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<assert model="account.move" search="[]" string="For all Journal Items, the state is valid implies that the sum of credits equals the sum of debits">
|
||||
<test expr="not len(line_id) or line_id[0].state != 'valid' or (sum([l.debit - l.credit for l in line_id]) <= 0.00001)"/>
|
||||
</assert>
|
||||
<function name="account_assert_balanced" model="account.move"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
<div class="oe_suggested_item_content">
|
||||
<a class="oe_suggestion_item_name" t-attf-href="#model=hr.employee&id=#{result.id}"><t t-esc="result.name"/></a>
|
||||
<a class="oe_suggestion_remove_item oe_suggestion_employee oe_e" t-attf-id="{result.id}">X</a>
|
||||
<a class="oe_suggestion_remove_item oe_suggestion_employee oe_e" t-att-id="result.id">X</a>
|
||||
<br/>
|
||||
<button class="oe_suggestion_follow" t-att-id="result.id">Follow</button>
|
||||
</div>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<div class="oe_suggested_item_content">
|
||||
<a class="oe_suggestion_item_name" t-attf-href="#model=mail.group&id=#{result.id}"><t t-esc="result.name"/></a>
|
||||
<a class="oe_suggestion_remove_item oe_suggestion_group oe_e" t-attf-id="{result.id}">X</a>
|
||||
<a class="oe_suggestion_remove_item oe_suggestion_group oe_e" t-att-id="result.id">X</a>
|
||||
<br/>
|
||||
<button t-att-id="result.id" class="oe_suggestion_join">Join Group</button>
|
||||
</div>
|
||||
|
|
|
@ -334,6 +334,11 @@ class mrp_bom(osv.osv):
|
|||
res['value'].update({'product_uom': product.uom_id.id})
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
if self.pool['mrp.production'].search(cr, uid, [('bom_id', 'in', ids), ('state', 'not in', ['done', 'cancel'])], context=context):
|
||||
raise osv.except_osv(_('Warning!'), _('You can not delete a Bill of Material with running manufacturing orders.\nPlease close or cancel it first.'))
|
||||
return super(mrp_bom, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def onchange_product_tmpl_id(self, cr, uid, ids, product_tmpl_id, product_qty=0, context=None):
|
||||
""" Changes UoM and name if product_id changes.
|
||||
@param product_id: Changed product_id
|
||||
|
|
|
@ -25,5 +25,11 @@
|
|||
<field name="global" eval="True" />
|
||||
<field name="domain_force">[('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
<record id="rule_pos_order_report_multi_company" model="ir.rule">
|
||||
<field name="name">Point Of Sale Order Analysis multi-company</field>
|
||||
<field name="model_id" ref="model_report_pos_order"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1067,7 +1067,7 @@ class product_product(osv.osv):
|
|||
if not limit or len(ids) < limit:
|
||||
# we may underrun the limit because of dupes in the results, that's fine
|
||||
limit2 = (limit - len(ids)) if limit else False
|
||||
ids.update(self.search(cr, user, args + [('name', operator, name)], limit=limit2, context=context))
|
||||
ids.update(self.search(cr, user, args + [('name', operator, name), ('id', 'not in', list(ids))], limit=limit2, context=context))
|
||||
ids = list(ids)
|
||||
elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||
ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context)
|
||||
|
|
|
@ -103,28 +103,30 @@ class project_work(osv.osv):
|
|||
res['product_uom_id'] = emp.product_id.uom_id.id
|
||||
return res
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
timesheet_obj = self.pool.get('hr.analytic.timesheet')
|
||||
task_obj = self.pool.get('project.task')
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
def _create_analytic_entries(self, cr, uid, vals, context):
|
||||
"""Create the hr analytic timesheet from project task work"""
|
||||
timesheet_obj = self.pool['hr.analytic.timesheet']
|
||||
task_obj = self.pool['project.task']
|
||||
|
||||
vals_line = {}
|
||||
context = kwargs.get('context', {})
|
||||
if not context.get('no_analytic_entry',False):
|
||||
task_obj = task_obj.browse(cr, uid, vals['task_id'])
|
||||
timeline_id = False
|
||||
acc_id = False
|
||||
|
||||
task_obj = task_obj.browse(cr, uid, vals['task_id'], context=context)
|
||||
result = self.get_user_related_details(cr, uid, vals.get('user_id', uid))
|
||||
vals_line['name'] = '%s: %s' % (tools.ustr(task_obj.name), tools.ustr(vals['name'] or '/'))
|
||||
vals_line['user_id'] = vals['user_id']
|
||||
vals_line['product_id'] = result['product_id']
|
||||
if vals.get('date'):
|
||||
vals_line['date' ] = vals['date'][:10]
|
||||
|
||||
# Calculate quantity based on employee's product's uom
|
||||
vals_line['unit_amount'] = vals['hours']
|
||||
|
||||
default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id
|
||||
default_uom = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.project_time_mode_id.id
|
||||
if result['product_uom_id'] != default_uom:
|
||||
vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id'])
|
||||
acc_id = task_obj.project_id and task_obj.project_id.analytic_account_id.id or False
|
||||
vals_line['unit_amount'] = self.pool['product.uom']._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id'])
|
||||
acc_id = task_obj.project_id and task_obj.project_id.analytic_account_id.id or acc_id
|
||||
if acc_id:
|
||||
vals_line['account_id'] = acc_id
|
||||
res = timesheet_obj.on_change_account_id(cr, uid, False, acc_id)
|
||||
|
@ -137,8 +139,7 @@ class project_work(osv.osv):
|
|||
amount = vals_line['unit_amount']
|
||||
prod_id = vals_line['product_id']
|
||||
unit = False
|
||||
context = dict(context, recompute=True)
|
||||
timeline_id = timesheet_obj.create(cr, uid, vals_line, context=context)
|
||||
timeline_id = timesheet_obj.create(cr, uid, vals=vals_line, context=context)
|
||||
|
||||
# Compute based on pricetype
|
||||
amount_unit = timesheet_obj.on_change_unit_amount(cr, uid, timeline_id,
|
||||
|
@ -146,7 +147,13 @@ class project_work(osv.osv):
|
|||
if amount_unit and 'amount' in amount_unit.get('value',{}):
|
||||
updv = { 'amount': amount_unit['value']['amount'] }
|
||||
timesheet_obj.write(cr, uid, [timeline_id], updv, context=context)
|
||||
vals['hr_analytic_timesheet_id'] = timeline_id
|
||||
|
||||
return timeline_id
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
context = kwargs.get('context', {})
|
||||
if not context.get('no_analytic_entry',False):
|
||||
vals['hr_analytic_timesheet_id'] = self._create_analytic_entries(cr, uid, vals, context=context)
|
||||
return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
|
@ -234,6 +241,10 @@ class task(osv.osv):
|
|||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
task_work_obj = self.pool['project.task.work']
|
||||
acc_id = False
|
||||
missing_analytic_entries = {}
|
||||
|
||||
if vals.get('project_id',False) or vals.get('name',False):
|
||||
vals_line = {}
|
||||
hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet')
|
||||
|
@ -245,6 +256,16 @@ class task(osv.osv):
|
|||
if len(task_obj.work_ids):
|
||||
for task_work in task_obj.work_ids:
|
||||
if not task_work.hr_analytic_timesheet_id:
|
||||
if acc_id :
|
||||
# missing timesheet activities to generate
|
||||
missing_analytic_entries[task_work.id] = {
|
||||
'name' : task_work.name,
|
||||
'user_id' : task_work.user_id.id,
|
||||
'date' : task_work.date and task_work.date[:10] or False,
|
||||
'account_id': acc_id,
|
||||
'hours' : task_work.hours,
|
||||
'task_id' : task_obj.id
|
||||
}
|
||||
continue
|
||||
line_id = task_work.hr_analytic_timesheet_id.id
|
||||
if vals.get('project_id',False):
|
||||
|
@ -252,7 +273,14 @@ class task(osv.osv):
|
|||
if vals.get('name',False):
|
||||
vals_line['name'] = '%s: %s' % (tools.ustr(vals['name']), tools.ustr(task_work.name) or '/')
|
||||
hr_anlytic_timesheet.write(cr, uid, [line_id], vals_line, {})
|
||||
return super(task,self).write(cr, uid, ids, vals, context)
|
||||
|
||||
res = super(task,self).write(cr, uid, ids, vals, context)
|
||||
|
||||
for task_work_id, analytic_entry in missing_analytic_entries.items():
|
||||
timeline_id = task_work_obj._create_analytic_entries(cr, uid, analytic_entry, context=context)
|
||||
task_work_obj.write(cr, uid, task_work_id, {'hr_analytic_timesheet_id' : timeline_id}, context=context)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
class res_partner(osv.osv):
|
||||
|
|
|
@ -1572,7 +1572,11 @@ instance.web.search.DateField = instance.web.search.Field.extend(/** @lends inst
|
|||
return instance.web.date_to_str(facetValue.get('value'));
|
||||
},
|
||||
complete: function (needle) {
|
||||
var d = Date.parse(needle);
|
||||
try {
|
||||
var d = instance.web.str_to_date(instance.web.parse_value(needle, {'widget': 'date'}));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
if (!d) { return $.when(null); }
|
||||
var date_string = instance.web.format_value(d, this.attrs);
|
||||
var label = _.str.sprintf(_.str.escapeHTML(
|
||||
|
|
|
@ -4393,7 +4393,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
|||
if (!this.fields_view || !this.editable()){
|
||||
return true;
|
||||
}
|
||||
this.o2m._dirty_flag = true;
|
||||
var r;
|
||||
return _.every(this.records.records, function(record){
|
||||
r = record;
|
||||
|
|
Loading…
Reference in New Issue