[MERGE] Sync with trunk, to benefit from freshly forward-ported 7.0 bugfixes.
bzr revid: tde@openerp.com-20130411082704-qce7e1moyo2sxz0c bzr revid: tde@openerp.com-20130411141158-lk7lsf2haqbjit1u
This commit is contained in:
commit
f35246e81c
|
@ -1384,6 +1384,7 @@ class account_move(osv.osv):
|
|||
'ref':False,
|
||||
'balance':False,
|
||||
'account_tax_id':False,
|
||||
'statement_id': False,
|
||||
})
|
||||
|
||||
if 'journal_id' in vals and vals.get('journal_id', False):
|
||||
|
@ -1420,6 +1421,7 @@ class account_move(osv.osv):
|
|||
context = {} if context is None else context.copy()
|
||||
default.update({
|
||||
'state':'draft',
|
||||
'ref': False,
|
||||
'name':'/',
|
||||
})
|
||||
context.update({
|
||||
|
@ -3401,7 +3403,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
try:
|
||||
tmp2 = obj_data.get_object_reference(cr, uid, *ref)
|
||||
if tmp2:
|
||||
self.pool.get(tmp2[0]).write(cr, uid, tmp2[1], {
|
||||
self.pool[tmp2[0]].write(cr, uid, tmp2[1], {
|
||||
'currency_id': obj_wizard.currency_id.id
|
||||
})
|
||||
except ValueError, e:
|
||||
|
|
|
@ -313,7 +313,7 @@ class account_invoice(osv.osv):
|
|||
context = {}
|
||||
|
||||
if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']:
|
||||
partner = self.pool.get(context['active_model']).read(cr, uid, context['active_ids'], ['supplier','customer'])[0]
|
||||
partner = self.pool[context['active_model']].read(cr, uid, context['active_ids'], ['supplier','customer'])[0]
|
||||
if not view_type:
|
||||
view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')])
|
||||
view_type = 'tree'
|
||||
|
@ -367,18 +367,6 @@ class account_invoice(osv.osv):
|
|||
context['view_id'] = view_id
|
||||
return context
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
try:
|
||||
return super(account_invoice, self).create(cr, uid, vals, context)
|
||||
except Exception, e:
|
||||
if '"journal_id" viol' in e.args[0]:
|
||||
raise orm.except_orm(_('Configuration Error!'),
|
||||
_('There is no Sale/Purchase Journal(s) defined.'))
|
||||
else:
|
||||
raise orm.except_orm(_('Unknown Error!'), str(e))
|
||||
|
||||
def invoice_print(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
This function prints the invoice and mark it as sent, so that we can see more easily the next step of the workflow
|
||||
|
|
|
@ -21,7 +21,7 @@ class CashBox(osv.osv_memory):
|
|||
active_model = context.get('active_model', False) or False
|
||||
active_ids = context.get('active_ids', []) or []
|
||||
|
||||
records = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)
|
||||
records = self.pool[active_model].browse(cr, uid, active_ids, context=context)
|
||||
|
||||
return self._run(cr, uid, ids, records, context=None)
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ class one2many_mod2(fields.one2many):
|
|||
plan = journal.plan_id
|
||||
if plan and len(plan.plan_ids) > pnum:
|
||||
acc_id = plan.plan_ids[pnum].root_analytic_id.id
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit)
|
||||
ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit)
|
||||
if ids2 is None:
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
|
||||
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
|
||||
for r in obj.pool[self._obj]._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
res[r[self._fields_id]].append( r['id'] )
|
||||
return res
|
||||
|
||||
|
|
|
@ -64,30 +64,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Replace analytic_id with analytics_id in account.invoice.line -->
|
||||
|
||||
<record model="ir.ui.view" id="view_invoice_line_form_inherit">
|
||||
<field name="name">account.invoice.line.form.inherit</field>
|
||||
<field name="model">account.invoice.line</field>
|
||||
<field name="inherit_id" ref="account.view_invoice_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_analytic_id" position="replace">
|
||||
<field name="analytics_id" context="{'journal_id':parent.journal_id}" domain="[('plan_id','<>',False)]" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="invoice_supplier_form_inherit">
|
||||
<field name="name">account.invoice.supplier.form.inherit</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="priority">2</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_analytic_id" position="replace">
|
||||
<field name="analytics_id" domain="[('plan_id','<>',False)]" context="{'journal_id':parent.journal_id}" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- views for account.analytic.plan.instance -->
|
||||
<record model="ir.ui.view" id="account_analytic_plan_instance_form">
|
||||
|
|
|
@ -80,7 +80,7 @@ class account_asset_asset(osv.osv):
|
|||
for asset in self.browse(cr, uid, ids, context=context):
|
||||
if asset.account_move_line_ids:
|
||||
raise osv.except_osv(_('Error!'), _('You cannot delete an asset that contains posted depreciation lines.'))
|
||||
return super(account_account, self).unlink(cr, uid, ids, context=context)
|
||||
return super(account_asset_asset, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def _get_period(self, cr, uid, context=None):
|
||||
periods = self.pool.get('account.period').find(cr, uid)
|
||||
|
|
|
@ -253,10 +253,10 @@
|
|||
<para style="terp_default_Centre_9">[[ get_invoice_name(line.ml_inv_ref.id) or '-' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Centre_9">[[line.date=='False' and '-' or formatLang(line.date,date=True) ]]</para>
|
||||
<para style="terp_default_Centre_9">[[not line.date and '-' or formatLang(line.date,date=True) ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9">[[ formatLang(line.amount or '-', currency_obj=line.company_currency) ]] </para>
|
||||
<para style="terp_default_Right_9">[[ formatLang(line.amount or 0.0, currency_obj=line.company_currency) ]] </para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9">[[ formatLang(line.amount_currency, currency_obj=line.currency) ]] </para>
|
||||
|
|
|
@ -171,9 +171,9 @@ class account_analytic_account(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Account/Contract Name', size=128, required=True),
|
||||
'name': fields.char('Account/Contract Name', size=128, required=True, track_visibility='onchange'),
|
||||
'complete_name': fields.function(_get_full_name, type='char', string='Full Name'),
|
||||
'code': fields.char('Reference', select=True),
|
||||
'code': fields.char('Reference', select=True, track_visibility='onchange'),
|
||||
'type': fields.selection([('view','Analytic View'), ('normal','Analytic Account'),('contract','Contract or Project'),('template','Template of Contract')], 'Type of Account', required=True,
|
||||
help="If you select the View Type, it means you won\'t allow to create journal entries using that account.\n"\
|
||||
"The type 'Analytic account' stands for usual accounts that you only want to use in accounting.\n"\
|
||||
|
@ -191,10 +191,10 @@ class account_analytic_account(osv.osv):
|
|||
'quantity': fields.function(_debit_credit_bal_qtty, type='float', string='Quantity', multi='debit_credit_bal_qtty'),
|
||||
'quantity_max': fields.float('Prepaid Service Units', help='Sets the higher limit of time to work on the contract, based on the timesheet. (for instance, number of hours in a limited support contract.)'),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer'),
|
||||
'user_id': fields.many2one('res.users', 'Project Manager'),
|
||||
'manager_id': fields.many2one('res.users', 'Account Manager'),
|
||||
'user_id': fields.many2one('res.users', 'Project Manager', track_visibility='onchange'),
|
||||
'manager_id': fields.many2one('res.users', 'Account Manager', track_visibility='onchange'),
|
||||
'date_start': fields.date('Start Date'),
|
||||
'date': fields.date('End Date', select=True),
|
||||
'date': fields.date('End Date', select=True, track_visibility='onchange'),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=False), #not required because we want to allow different companies to use the same chart of account, except for leaf accounts.
|
||||
'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'),('pending','To Renew'),('close','Closed'),('cancelled', 'Cancelled')], 'Status', required=True, track_visibility='onchange'),
|
||||
'currency_id': fields.function(_currency, fnct_inv=_set_company_currency, #the currency_id field is readonly except if it's a view account and if there is no company
|
||||
|
|
|
@ -411,7 +411,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
|||
model_name = field.model_id.model
|
||||
field_name = field.field_id.name
|
||||
field_type = field.field_id.ttype
|
||||
table_name = self.pool.get(model_name)._table
|
||||
table_name = self.pool[model_name]._table
|
||||
|
||||
# get the current value
|
||||
sql = "select id, %s from %s" % (field_name, table_name)
|
||||
|
@ -543,7 +543,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
|
|||
fixes = group(fixes, ('model_name', 'field_name'))
|
||||
|
||||
for line in data:
|
||||
table_name = self.pool.get(line['model_id'])._table if self.pool.get(line['model_id']) else None
|
||||
table_name = self.pool[line['model_id']]._table if line['model_id'] in self.pool else None
|
||||
|
||||
# check if custom sql exists:
|
||||
key = (line['model_id'], line['field_id'])
|
||||
|
|
|
@ -70,8 +70,7 @@ class audittrail_rule(osv.osv):
|
|||
obj_model = self.pool.get('ir.model.data')
|
||||
#start Loop
|
||||
for thisrule in self.browse(cr, uid, ids):
|
||||
obj = self.pool.get(thisrule.object_id.model)
|
||||
if not obj:
|
||||
if thisrule.object_id.model not in self.pool:
|
||||
raise osv.except_osv(
|
||||
_('WARNING: audittrail is not part of the pool'),
|
||||
_('Change audittrail depends -- Setting rule as DRAFT'))
|
||||
|
@ -131,7 +130,7 @@ class audittrail_log(osv.osv):
|
|||
model_object = resname.object_id
|
||||
res_id = resname.res_id
|
||||
if model_object and res_id:
|
||||
model_pool = self.pool.get(model_object.model)
|
||||
model_pool = self.pool[model_object.model]
|
||||
res = model_pool.read(cr, uid, res_id, ['name'])
|
||||
data[resname.id] = res['name']
|
||||
else:
|
||||
|
@ -190,7 +189,7 @@ def get_value_text(cr, uid, pool, resource_pool, method, field, value):
|
|||
|
||||
field_obj = (resource_pool._all_columns.get(field)).column
|
||||
if field_obj._type in ('one2many','many2many'):
|
||||
data = pool.get(field_obj._obj).name_get(cr, uid, value)
|
||||
data = pool[field_obj._obj].name_get(cr, uid, value)
|
||||
#return the modifications on x2many fields as a list of names
|
||||
res = map(lambda x:x[1], data)
|
||||
elif field_obj._type == 'many2one':
|
||||
|
@ -212,7 +211,7 @@ def create_log_line(cr, uid, log_id, model, lines=None):
|
|||
if lines is None:
|
||||
lines = []
|
||||
pool = openerp.registry(cr.dbname)
|
||||
obj_pool = pool.get(model.model)
|
||||
obj_pool = pool[model.model]
|
||||
model_pool = pool.get('ir.model')
|
||||
field_pool = pool.get('ir.model.fields')
|
||||
log_line_pool = pool.get('audittrail.log.line')
|
||||
|
@ -251,7 +250,7 @@ def log_fct(cr, uid_orig, model, method, fct_src, *args, **kw):
|
|||
@return: Returns result as per method of Object proxy
|
||||
"""
|
||||
pool = openerp.registry(cr.dbname)
|
||||
resource_pool = pool.get(model)
|
||||
resource_pool = pool[model]
|
||||
model_pool = pool.get('ir.model')
|
||||
model_ids = model_pool.search(cr, SUPERUSER_ID, [('model', '=', model)])
|
||||
model_id = model_ids and model_ids[0] or False
|
||||
|
@ -321,7 +320,7 @@ def get_data(cr, uid, pool, res_ids, model, method):
|
|||
}
|
||||
"""
|
||||
data = {}
|
||||
resource_pool = pool.get(model.model)
|
||||
resource_pool = pool[model.model]
|
||||
# read all the fields of the given resources in super admin mode
|
||||
for resource in resource_pool.read(cr, SUPERUSER_ID, res_ids):
|
||||
values = {}
|
||||
|
@ -390,7 +389,7 @@ def prepare_audittrail_log_line(cr, uid, pool, model, resource_id, method, old_v
|
|||
key: []
|
||||
}
|
||||
# loop on all the fields
|
||||
for field_name, field_definition in pool.get(model.model)._all_columns.items():
|
||||
for field_name, field_definition in pool[model.model]._all_columns.items():
|
||||
if field_name in ('__last_update', 'id'):
|
||||
continue
|
||||
#if the field_list param is given, skip all the fields not in that list
|
||||
|
@ -457,7 +456,7 @@ def process_data(cr, uid, pool, res_ids, model, method, old_values=None, new_val
|
|||
|
||||
# if at least one modification has been found
|
||||
for model_id, resource_id in lines:
|
||||
name = pool.get(model.model).name_get(cr, uid, [resource_id])[0][1]
|
||||
name = pool[model.model].name_get(cr, uid, [resource_id])[0][1]
|
||||
vals = {
|
||||
'method': method,
|
||||
'object_id': model_id,
|
||||
|
|
|
@ -96,7 +96,7 @@ class base_action_rule(osv.osv):
|
|||
""" filter the list record_ids that satisfy the action filter """
|
||||
if record_ids and action_filter:
|
||||
assert action.model == action_filter.model_id, "Filter model different from action rule model"
|
||||
model = self.pool.get(action_filter.model_id)
|
||||
model = self.pool[action_filter.model_id]
|
||||
domain = [('id', 'in', record_ids)] + eval(action_filter.domain)
|
||||
ctx = dict(context or {})
|
||||
ctx.update(eval(action_filter.context))
|
||||
|
@ -106,7 +106,7 @@ class base_action_rule(osv.osv):
|
|||
def _process(self, cr, uid, action, record_ids, context=None):
|
||||
""" process the given action on the records """
|
||||
# execute server actions
|
||||
model = self.pool.get(action.model_id.model)
|
||||
model = self.pool[action.model_id.model]
|
||||
if action.server_action_ids:
|
||||
server_action_ids = map(int, action.server_action_ids)
|
||||
for record in model.browse(cr, uid, record_ids, context):
|
||||
|
@ -195,7 +195,7 @@ class base_action_rule(osv.osv):
|
|||
ids = self.search(cr, SUPERUSER_ID, [])
|
||||
for action_rule in self.browse(cr, SUPERUSER_ID, ids):
|
||||
model = action_rule.model_id.model
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj = self.pool[model]
|
||||
if not hasattr(model_obj, 'base_action_ruled'):
|
||||
model_obj.create = self._wrap_create(model_obj.create, model)
|
||||
model_obj.write = self._wrap_write(model_obj.write, model)
|
||||
|
@ -232,7 +232,7 @@ class base_action_rule(osv.osv):
|
|||
last_run = get_datetime(action.last_run) if action.last_run else False
|
||||
|
||||
# retrieve all the records that satisfy the action's condition
|
||||
model = self.pool.get(action.model_id.model)
|
||||
model = self.pool[action.model_id.model]
|
||||
domain = []
|
||||
ctx = dict(context)
|
||||
if action.filter_id:
|
||||
|
|
|
@ -591,7 +591,7 @@ property or property parameter."),
|
|||
|
||||
for vals in self.browse(cr, uid, ids, context=context):
|
||||
if vals.ref and vals.ref.user_id:
|
||||
mod_obj = self.pool.get(vals.ref._name)
|
||||
mod_obj = self.pool[vals.ref._name]
|
||||
res=mod_obj.read(cr,uid,[vals.ref.id],['duration','class'],context)
|
||||
defaults = {'user_id': vals.user_id.id, 'organizer_id': vals.ref.user_id.id,'duration':res[0]['duration'],'class':res[0]['class']}
|
||||
mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context)
|
||||
|
@ -684,7 +684,7 @@ true, it will allow you to hide the event alarm information without removing it.
|
|||
ir_obj = self.pool.get('ir.model')
|
||||
model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
|
||||
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj = self.pool[model]
|
||||
for data in model_obj.browse(cr, uid, ids, context=context):
|
||||
|
||||
basic_alarm = data.alarm_id
|
||||
|
@ -754,7 +754,7 @@ true, it will allow you to hide the event alarm information without removing it.
|
|||
alarm_obj = self.pool.get('calendar.alarm')
|
||||
ir_obj = self.pool.get('ir.model')
|
||||
model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj = self.pool[model]
|
||||
for data in model_obj.browse(cr, uid, ids, context=context):
|
||||
alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', data.id)])
|
||||
if alarm_ids:
|
||||
|
@ -853,13 +853,15 @@ class calendar_alarm(osv.osv):
|
|||
for alarm in self.browse(cr, uid, alarm_ids, context=context):
|
||||
next_trigger_date = None
|
||||
update_vals = {}
|
||||
model_obj = self.pool.get(alarm.model_id.model)
|
||||
model_obj = self.pool[alarm.model_id.model]
|
||||
res_obj = model_obj.browse(cr, uid, alarm.res_id, context=context)
|
||||
re_dates = []
|
||||
|
||||
if hasattr(res_obj, 'rrule') and res_obj.rrule:
|
||||
event_date = datetime.strptime(res_obj.date, '%Y-%m-%d %H:%M:%S')
|
||||
recurrent_dates = get_recurrent_dates(res_obj.rrule, res_obj.exdate, event_date, res_obj.exrule)
|
||||
#exdate is a string and we need a list
|
||||
exdate = res_obj.exdate and res_obj.exdate.split(',') or []
|
||||
recurrent_dates = get_recurrent_dates(res_obj.rrule, exdate, event_date, res_obj.exrule)
|
||||
|
||||
trigger_interval = alarm.trigger_interval
|
||||
if trigger_interval == 'days':
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
<field name="name">Run Event Reminder</field>
|
||||
<field eval="True" name="active" />
|
||||
<field name="user_id" ref="base.user_root" />
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_number">5</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
|
|
|
@ -135,7 +135,7 @@ class mail_message(osv.osv):
|
|||
|
||||
def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None):
|
||||
if doc_model == 'crm.meeting':
|
||||
for virtual_id in self.pool.get(doc_model).get_recurrent_ids(cr, uid, doc_dict.keys(), [], context=context):
|
||||
for virtual_id in self.pool[doc_model].get_recurrent_ids(cr, uid, doc_dict.keys(), [], context=context):
|
||||
doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)])
|
||||
return super(mail_message, self)._find_allowed_model_wise(cr, uid, doc_model, doc_dict, context=context)
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@
|
|||
<xsl:value-of select="$size" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<seq id="{../../@text:style-name}"/>.</bullet>
|
||||
<seq id="{../../@text:style-name}"/></bullet>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
|
|
|
@ -414,7 +414,7 @@
|
|||
<xsl:value-of select="$size" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<seq id="{../../@text:style-name}"/>.</bullet>
|
||||
<seq id="{../../@text:style-name}"/></bullet>
|
||||
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
|
|
@ -92,15 +92,6 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
context['empty_list_help_document_name'] = _("leads")
|
||||
return super(crm_lead, self).get_empty_list_help(cr, uid, help, context=context)
|
||||
|
||||
def onchange_user_id(self, cr, uid, ids, section_id, user_id, context=None):
|
||||
""" When changing the user, also set a section_id or restrict section id
|
||||
to the ones user_id is member of. """
|
||||
if user_id:
|
||||
section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
|
||||
if len(section_ids) > 0 and section_id not in section_ids:
|
||||
section_id = section_ids[0]
|
||||
return {'value': {'section_id': section_id}}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
@ -372,6 +363,16 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
}
|
||||
return {'value' : values}
|
||||
|
||||
def on_change_user(self, cr, uid, ids, user_id, context=None):
|
||||
""" When changing the user, also set a section_id or restrict section id
|
||||
to the ones user_id is member of. """
|
||||
section_id = False
|
||||
if user_id:
|
||||
section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
|
||||
if section_ids:
|
||||
section_id = section_ids[0]
|
||||
return {'value': {'section_id': section_id}}
|
||||
|
||||
def _check(self, cr, uid, ids=False, context=None):
|
||||
""" Override of the base.stage method.
|
||||
Function called by the scheduler to process cases for date actions
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
-->
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_id" on_change="onchange_user_id(section_id, user_id)"
|
||||
<field name="user_id" on_change="on_change_user(user_id, context)"
|
||||
context="{'default_groups_ref': ['base.group_user', 'base.group_sale_salesman_all_leads'] }"/>
|
||||
<label for="section_id" groups="base.group_multi_salesteams"/>
|
||||
<div groups="base.group_multi_salesteams">
|
||||
|
@ -429,7 +429,7 @@
|
|||
</group>
|
||||
|
||||
<group>
|
||||
<field name="user_id" on_change="onchange_user_id(section_id, user_id)" context="{'default_groups_ref': ['base.group_user', 'base.group_sale_salesman_all_leads']}"/>
|
||||
<field name="user_id" on_change="on_change_user(user_id, context)" context="{'default_groups_ref': ['base.group_user', 'base.group_sale_salesman_all_leads']}"/>
|
||||
<label for="section_id" groups="base.group_multi_salesteams"/>
|
||||
<div groups="base.group_multi_salesteams">
|
||||
<field name="section_id" widget="selection"/>
|
||||
|
|
|
@ -86,7 +86,7 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
if context is None:
|
||||
context = {}
|
||||
if model and model == 'crm.lead' and res_id:
|
||||
lead = self.pool.get(model).browse(cr, uid, res_id, context=context)
|
||||
lead = self.pool[model].browse(cr, uid, res_id, context=context)
|
||||
context['history_mode'] = history_mode
|
||||
body = self.get_record_data(cr, uid, 'crm.lead', res_id, context=context)['body']
|
||||
return {'value': {'body': body}}
|
||||
|
@ -110,7 +110,7 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
if wizard.model not in ('crm.lead'):
|
||||
return res
|
||||
|
||||
lead = self.pool.get(wizard.model)
|
||||
lead = self.pool[wizard.model]
|
||||
lead_ids = wizard.res_id and [wizard.res_id] or []
|
||||
|
||||
if wizard.composition_mode == 'mass_mail':
|
||||
|
|
|
@ -61,7 +61,7 @@ class open_questionnaire(osv.osv_memory):
|
|||
for d in data.question_ans_ids:
|
||||
if d.answer_id:
|
||||
answers.append(d.answer_id.id)
|
||||
self.pool.get(model)._questionnaire_compute(cr, uid, answers, context=context)
|
||||
self.pool[model]._questionnaire_compute(cr, uid, answers, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class document_file(osv.osv):
|
|||
It is a hack that will try to discover if the mentioned record is
|
||||
clearly associated with a partner record.
|
||||
"""
|
||||
obj_model = self.pool.get(res_model)
|
||||
obj_model = self.pool[res_model]
|
||||
if obj_model._name == 'res.partner':
|
||||
return res_id
|
||||
elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner':
|
||||
|
@ -422,7 +422,6 @@ class document_directory_content(osv.osv):
|
|||
tname = ''
|
||||
if content.include_name:
|
||||
record_name = node.displayname or ''
|
||||
# obj = node.context._dirobj.pool.get(model)
|
||||
if record_name:
|
||||
tname = (content.prefix or '') + record_name + (content.suffix or '') + (content.extension or '')
|
||||
else:
|
||||
|
@ -1296,9 +1295,9 @@ class node_res_dir(node_class):
|
|||
Note that many objects use NULL for a name, so we should
|
||||
better call the name_search(),name_get() set of methods
|
||||
"""
|
||||
obj = self.context._dirobj.pool.get(self.res_model)
|
||||
if not obj:
|
||||
if self.res_model not in self.context._dirobj.pool:
|
||||
return []
|
||||
obj = self.context._dirobj.pool[self.res_model]
|
||||
dirobj = self.context._dirobj
|
||||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
|
@ -1333,7 +1332,7 @@ class node_res_dir(node_class):
|
|||
if self.ressource_tree:
|
||||
object2 = False
|
||||
if self.resm_id:
|
||||
object2 = dirobj.pool.get(self.res_model).browse(cr, uid, self.resm_id) or False
|
||||
object2 = dirobj.pool[self.res_model].browse(cr, uid, self.resm_id) or False
|
||||
if obj._parent_name in obj.fields_get(cr, uid):
|
||||
where.append((obj._parent_name,'=',object2 and object2.id or False))
|
||||
|
||||
|
@ -1504,7 +1503,7 @@ class node_res_obj(node_class):
|
|||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
directory = dirobj.browse(cr, uid, self.dir_id)
|
||||
obj = dirobj.pool.get(self.res_model)
|
||||
obj = dirobj.pool[self.res_model]
|
||||
where = []
|
||||
res = []
|
||||
if name:
|
||||
|
@ -1590,7 +1589,7 @@ class node_res_obj(node_class):
|
|||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
res_obj = dirobj.pool.get(self.res_model)
|
||||
res_obj = dirobj.pool[self.res_model]
|
||||
|
||||
object2 = res_obj.browse(cr, uid, self.res_id) or False
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class node_acl_mixin(object):
|
|||
"""
|
||||
ret = par_class.get_dav_props(self, cr)
|
||||
if prop_model:
|
||||
propobj = self.context._dirobj.pool.get(prop_model)
|
||||
propobj = self.context._dirobj.pool[prop_model]
|
||||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
|
@ -105,7 +105,7 @@ class node_acl_mixin(object):
|
|||
if ret is not None:
|
||||
return ret
|
||||
if prop_model:
|
||||
propobj = self.context._dirobj.pool.get(prop_model)
|
||||
propobj = self.context._dirobj.pool[prop_model]
|
||||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
|
@ -151,7 +151,7 @@ class node_acl_mixin(object):
|
|||
assert prop_model
|
||||
assert res_id
|
||||
assert isinstance(lock_data, dict), '%r' % lock_data
|
||||
propobj = self.context._dirobj.pool.get(prop_model)
|
||||
propobj = self.context._dirobj.pool[prop_model]
|
||||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
|
|
|
@ -106,8 +106,8 @@ class edi(osv.AbstractModel):
|
|||
"""
|
||||
edi_list = []
|
||||
for record in records:
|
||||
record_model_obj = self.pool.get(record._name)
|
||||
edi_list += record_model_obj.edi_export(cr, uid, [record], context=context)
|
||||
record_model = record._model
|
||||
edi_list += record_model.edi_export(cr, uid, [record], context=context)
|
||||
return self.serialize(edi_list)
|
||||
|
||||
def load_edi(self, cr, uid, edi_documents, context=None):
|
||||
|
@ -131,9 +131,9 @@ class edi(osv.AbstractModel):
|
|||
"You can install it by connecting as the administrator and opening the configuration assistant.")%(module,))
|
||||
model = edi_document.get('__import_model') or edi_document.get('__model')
|
||||
assert model, 'a `__model` or `__import_model` attribute is required in each EDI document.'
|
||||
model_obj = self.pool.get(model)
|
||||
assert model_obj, 'model `%s` cannot be found, despite module `%s` being available - '\
|
||||
assert model in self.pool, 'model `%s` cannot be found, despite module `%s` being available - '\
|
||||
'this EDI document seems invalid or unsupported.' % (model,module)
|
||||
model_obj = self.pool[model]
|
||||
record_id = model_obj.edi_import(cr, uid, edi_document, context=context)
|
||||
record_action = model_obj._edi_record_display_action(cr, uid, record_id, context=context)
|
||||
res.append((model, record_id, record_action))
|
||||
|
@ -400,7 +400,7 @@ class EDIMixin(object):
|
|||
return results
|
||||
|
||||
def _edi_get_object_by_name(self, cr, uid, name, model_name, context=None):
|
||||
model = self.pool.get(model_name)
|
||||
model = self.pool[model_name]
|
||||
search_results = model.name_search(cr, uid, name, operator='=', context=context)
|
||||
if len(search_results) == 1:
|
||||
return model.browse(cr, uid, search_results[0][0], context=context)
|
||||
|
@ -483,7 +483,7 @@ class EDIMixin(object):
|
|||
('name','=',ext_id),
|
||||
('module','in',modules)])
|
||||
if data_ids:
|
||||
model = self.pool.get(model)
|
||||
model = self.pool[model]
|
||||
data = ir_model_data.browse(cr, uid, data_ids[0], context=context)
|
||||
if model.exists(cr, uid, [data.res_id]):
|
||||
return model.browse(cr, uid, data.res_id, context=context)
|
||||
|
@ -519,7 +519,7 @@ class EDIMixin(object):
|
|||
_logger.debug("%s: Importing EDI relationship [%r,%r] - name not found, creating it.",
|
||||
self._name, external_id, value)
|
||||
# also need_new_ext_id here, but already been set above
|
||||
model = self.pool.get(model)
|
||||
model = self.pool[model]
|
||||
res_id, _ = model.name_create(cr, uid, value, context=context)
|
||||
target = model.browse(cr, uid, res_id, context=context)
|
||||
else:
|
||||
|
@ -592,7 +592,7 @@ class EDIMixin(object):
|
|||
# process o2m values, connecting them to their parent on-the-fly
|
||||
for o2m_field, o2m_value in o2m_todo.iteritems():
|
||||
field = self._all_columns[o2m_field].column
|
||||
dest_model = self.pool.get(field._obj)
|
||||
dest_model = self.pool[field._obj]
|
||||
for o2m_line in o2m_value:
|
||||
# link to parent record: expects an (ext_id, name) pair
|
||||
o2m_line[field._fields_id] = (ext_id_members['full'], record_display[1])
|
||||
|
|
|
@ -89,7 +89,7 @@ class email_template(osv.osv):
|
|||
template = tools.ustr(template)
|
||||
record = None
|
||||
if res_id:
|
||||
record = self.pool.get(model).browse(cr, uid, res_id, context=context)
|
||||
record = self.pool[model].browse(cr, uid, res_id, context=context)
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
variables = {
|
||||
'object': record,
|
||||
|
@ -297,8 +297,7 @@ class email_template(osv.osv):
|
|||
'copyvalue': self.build_expression(field_value.name, False, null_value or False),
|
||||
'null_value': null_value or False
|
||||
})
|
||||
return {'value':result}
|
||||
|
||||
return {'value': result}
|
||||
|
||||
def generate_email(self, cr, uid, template_id, res_id, context=None):
|
||||
"""Generates an email from the template for given (model, res_id) pair.
|
||||
|
@ -350,11 +349,13 @@ class email_template(osv.osv):
|
|||
report_name += ext
|
||||
attachments.append((report_name, result))
|
||||
|
||||
attachment_ids = []
|
||||
# Add template attachments
|
||||
for attach in template.attachment_ids:
|
||||
attachments.append((attach.datas_fname, attach.datas))
|
||||
attachment_ids.append(attach.id)
|
||||
|
||||
values['attachments'] = attachments
|
||||
values['attachment_ids'] = attachment_ids
|
||||
return values
|
||||
|
||||
def send_mail(self, cr, uid, template_id, res_id, force_send=False, context=None):
|
||||
|
@ -369,28 +370,34 @@ class email_template(osv.osv):
|
|||
was executed for this message only.
|
||||
:returns: id of the mail.message that was created
|
||||
"""
|
||||
if context is None: context = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
mail_mail = self.pool.get('mail.mail')
|
||||
ir_attachment = self.pool.get('ir.attachment')
|
||||
|
||||
# create a mail_mail based on values, without attachments
|
||||
values = self.generate_email(cr, uid, template_id, res_id, context=context)
|
||||
assert 'email_from' in values, 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
|
||||
attachments = values.pop('attachments') or {}
|
||||
del values['partner_to'] # TODO Properly use them.
|
||||
assert values.get('email_from'), 'email_from is missing or empty after template rendering, send_mail() cannot proceed'
|
||||
del values['partner_to'] # TODO Properly use them.
|
||||
attachment_ids = values.pop('attachment_ids', [])
|
||||
attachments = values.pop('attachments', [])
|
||||
msg_id = mail_mail.create(cr, uid, values, context=context)
|
||||
# link attachments
|
||||
attachment_ids = []
|
||||
for fname, fcontent in attachments.iteritems():
|
||||
|
||||
# manage attachments
|
||||
for attachment in attachments:
|
||||
attachment_data = {
|
||||
'name': fname,
|
||||
'datas_fname': fname,
|
||||
'datas': fcontent,
|
||||
'res_model': mail_mail._name,
|
||||
'name': attachment[0],
|
||||
'datas_fname': attachment[0],
|
||||
'datas': attachment[1],
|
||||
'res_model': 'mail.message',
|
||||
'res_id': msg_id,
|
||||
}
|
||||
context.pop('default_type', None)
|
||||
attachment_ids.append(ir_attachment.create(cr, uid, attachment_data, context=context))
|
||||
if attachment_ids:
|
||||
values['attachment_ids'] = [(6, 0, attachment_ids)]
|
||||
mail_mail.write(cr, uid, msg_id, {'attachment_ids': [(6, 0, attachment_ids)]}, context=context)
|
||||
|
||||
if force_send:
|
||||
mail_mail.send(cr, uid, [msg_id], context=context)
|
||||
return msg_id
|
||||
|
|
|
@ -48,8 +48,8 @@ class test_message_compose(TestMailBase):
|
|||
_body_html1 = 'Fans of Pigs, unite !'
|
||||
_body_html2 = 'I am angry !'
|
||||
_attachments = [
|
||||
{'name': 'First', 'datas_fname': 'first.txt', 'datas': base64.b64encode('My first attachment')},
|
||||
{'name': 'Second', 'datas_fname': 'second.txt', 'datas': base64.b64encode('My second attachment')}
|
||||
{'name': 'First', 'datas_fname': 'first.txt', 'datas': base64.b64encode('My first attachment'), 'res_model': 'res.partner', 'res_id': self.partner_admin_id},
|
||||
{'name': 'Second', 'datas_fname': 'second.txt', 'datas': base64.b64encode('My second attachment'), 'res_model': 'res.partner', 'res_id': self.partner_admin_id},
|
||||
]
|
||||
_attachments_test = [('first.txt', 'My first attachment'), ('second.txt', 'My second attachment')]
|
||||
|
||||
|
@ -115,12 +115,20 @@ class test_message_compose(TestMailBase):
|
|||
self.assertEqual(compose.subject, _subject1, 'mail.compose.message subject incorrect')
|
||||
self.assertIn(_body_html1, compose.body, 'mail.compose.message body incorrect')
|
||||
self.assertEqual(set(message_pids), set(partner_ids), 'mail.compose.message partner_ids incorrect')
|
||||
# Test: mail.compose.message: attachments
|
||||
# Test: mail.message: attachments
|
||||
# Test: mail.compose.message: attachments (owner has not been modified)
|
||||
for attach in compose.attachment_ids:
|
||||
self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect')
|
||||
self.assertEqual(attach.res_id, self.group_pigs_id, 'mail.message attachment res_id incorrect')
|
||||
self.assertIn((attach.name, base64.b64decode(attach.datas)), _attachments_test,
|
||||
self.assertEqual(attach.res_model, 'res.partner', 'mail.compose.message attachment res_model through templat was overriden')
|
||||
self.assertEqual(attach.res_id, self.partner_admin_id, 'mail.compose.message attachment res_id incorrect')
|
||||
self.assertIn((attach.datas_fname, base64.b64decode(attach.datas)), _attachments_test,
|
||||
'mail.message attachment name / data incorrect')
|
||||
# Test: mail.message: attachments
|
||||
mail_compose.send_mail(cr, uid, [compose_id])
|
||||
group_pigs.refresh()
|
||||
message_pigs = group_pigs.message_ids[0]
|
||||
for attach in message_pigs.attachment_ids:
|
||||
self.assertEqual(attach.res_model, 'mail.group', 'mail.compose.message attachment res_model through templat was overriden')
|
||||
self.assertEqual(attach.res_id, self.group_pigs_id, 'mail.compose.message attachment res_id incorrect')
|
||||
self.assertIn((attach.datas_fname, base64.b64decode(attach.datas)), _attachments_test,
|
||||
'mail.message attachment name / data incorrect')
|
||||
|
||||
# ----------------------------------------
|
||||
|
|
|
@ -40,7 +40,7 @@ class email_template_preview(osv.osv_memory):
|
|||
email_template = self.pool.get('email.template')
|
||||
template = email_template.browse(cr, uid, int(template_id), context=context)
|
||||
template_object = template.model_id
|
||||
model = self.pool.get(template_object.model)
|
||||
model = self.pool[template_object.model]
|
||||
record_ids = model.search(cr, uid, [], 0, 10, 'id', context=context)
|
||||
default_id = context.get('default_res_id')
|
||||
|
||||
|
|
|
@ -49,26 +49,44 @@ class mail_compose_message(osv.TransientModel):
|
|||
help="Carbon copy recipients (placeholders may be used here)"),
|
||||
}
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
""" Override of send_mail to duplicate attachments linked to the email.template.
|
||||
Indeed, basic mail.compose.message wizard duplicates attachments in mass
|
||||
mailing mode. But in 'single post' mode, attachments of an email template
|
||||
also have to be duplicated to avoid changing their ownership. """
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id:
|
||||
continue
|
||||
template = self.pool.get('email.template').browse(cr, uid, wizard.template_id.id, context=context)
|
||||
new_attachment_ids = []
|
||||
for attachment in wizard.attachment_ids:
|
||||
if attachment in template.attachment_ids:
|
||||
new_attachment_ids.append(self.pool.get('ir.attachment').copy(cr, uid, attachment.id, {'res_model': 'mail.compose.message', 'res_id': wizard.id}, context=context))
|
||||
else:
|
||||
new_attachment_ids.append(attachment.id)
|
||||
self.write(cr, uid, wizard.id, {'attachment_ids': [(6, 0, new_attachment_ids)]}, context=context)
|
||||
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
|
||||
|
||||
def onchange_template_id(self, cr, uid, ids, template_id, composition_mode, model, res_id, context=None):
|
||||
""" - mass_mailing: we cannot render, so return the template values
|
||||
- normal mode: return rendered values """
|
||||
if template_id and composition_mode == 'mass_mail':
|
||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to']
|
||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids']
|
||||
template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context)
|
||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||
elif template_id:
|
||||
# FIXME odo: change the mail generation to avoid attachment duplication
|
||||
values = self.generate_email_for_composer(cr, uid, template_id, res_id, context=context)
|
||||
# transform attachments into attachment_ids
|
||||
values['attachment_ids'] = []
|
||||
# transform attachments into attachment_ids; not attached to the document because this will
|
||||
# be done further in the posting process, allowing to clean database if email not send
|
||||
values['attachment_ids'] = values.pop('attachment_ids', [])
|
||||
ir_attach_obj = self.pool.get('ir.attachment')
|
||||
for attach_fname, attach_datas in values.pop('attachments', []):
|
||||
data_attach = {
|
||||
'name': attach_fname,
|
||||
'datas': attach_datas,
|
||||
'datas_fname': attach_fname,
|
||||
'res_model': model,
|
||||
'res_id': res_id,
|
||||
'res_model': 'mail.compose.message',
|
||||
'res_id': 0,
|
||||
'type': 'binary', # override default_type from context, possibly meant for another model!
|
||||
}
|
||||
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
|
||||
|
@ -128,7 +146,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
mail.compose.message, transform email_cc and email_to into partner_ids """
|
||||
template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
# filter template values
|
||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachments']
|
||||
fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments']
|
||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||
values['body'] = values.pop('body_html', '')
|
||||
|
||||
|
@ -145,9 +163,11 @@ class mail_compose_message(osv.TransientModel):
|
|||
""" Override to handle templates. """
|
||||
# generate the composer email
|
||||
if wizard.template_id:
|
||||
values = self.generate_email_for_composer(cr, uid, wizard.template_id, res_id, context=context)
|
||||
values = self.generate_email_for_composer(cr, uid, wizard.template_id.id, res_id, context=context)
|
||||
else:
|
||||
values = {}
|
||||
# remove attachments as they should not be rendered
|
||||
values.pop('attachment_ids', None)
|
||||
# get values to return
|
||||
email_dict = super(mail_compose_message, self).render_message(cr, uid, wizard, res_id, context)
|
||||
# those values are not managed; they are readonly
|
||||
|
|
|
@ -89,7 +89,6 @@ class fetchmail_server(osv.osv):
|
|||
'script': '/mail/static/scripts/openerp_mailgate.py',
|
||||
}
|
||||
|
||||
|
||||
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False, object_id=False):
|
||||
port = 0
|
||||
values = {}
|
||||
|
@ -175,13 +174,14 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
|
|||
|
||||
def _fetch_mails(self, cr, uid, ids=False, context=None):
|
||||
if not ids:
|
||||
ids = self.search(cr, uid, [('state','=','done')])
|
||||
ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
|
||||
return self.fetch_mail(cr, uid, ids, context=context)
|
||||
|
||||
def fetch_mail(self, cr, uid, ids, context=None):
|
||||
"""WARNING: meant for cron usage only - will commit() after each email!"""
|
||||
if context is None:
|
||||
context = {}
|
||||
context['fetchmail_cron_running'] = True
|
||||
mail_thread = self.pool.get('mail.thread')
|
||||
action_pool = self.pool.get('ir.actions.server')
|
||||
for server in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -240,6 +240,29 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
|
|||
server.write({'date': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)})
|
||||
return True
|
||||
|
||||
def cron_update(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not context.get('fetchmail_cron_running'):
|
||||
# Enabled/Disable cron based on the number of 'done' server of type pop or imap
|
||||
ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
|
||||
try:
|
||||
cron_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'fetchmail', 'ir_cron_mail_gateway_action')[1]
|
||||
self.pool.get('ir.cron').write(cr, 1, [cron_id], {'active': bool(ids)})
|
||||
except ValueError:
|
||||
# Nevermind if default cron cannot be found
|
||||
pass
|
||||
|
||||
def create(self, cr, uid, values, context=None):
|
||||
res = super(fetchmail_server, self).create(cr, uid, values, context=context)
|
||||
self.cron_update(cr, uid, context=context)
|
||||
return res
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
res = super(fetchmail_server, self).write(cr, uid, ids, values, context=context)
|
||||
self.cron_update(cr, uid, context=context)
|
||||
return res
|
||||
|
||||
class mail_mail(osv.osv):
|
||||
_inherit = "mail.mail"
|
||||
_columns = {
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<field name="model">fetchmail.server</field>
|
||||
<field name="function">_fetch_mails</field>
|
||||
<field name="args">()</field>
|
||||
<!-- Active flag is set on fetchmail_server.create/write -->
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -155,7 +155,7 @@ class google_docs_ir_attachment(osv.osv):
|
|||
pool_ir_attachment = self.pool.get('ir.attachment')
|
||||
pool_gdoc_config = self.pool.get('google.docs.config')
|
||||
name_gdocs = ''
|
||||
model_fields_dic = self.pool.get(res_model).read(cr, uid, res_id, [], context=context)
|
||||
model_fields_dic = self.pool[res_model].read(cr, uid, res_id, [], context=context)
|
||||
|
||||
# check if a model is configured with a template
|
||||
google_docs_config = pool_gdoc_config.search(cr, uid, [('model_id', '=', res_model)], context=context)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -321,7 +321,7 @@ class hr_expense_expense(osv.osv):
|
|||
'price_unit': tax['price_unit'],
|
||||
'quantity': 1,
|
||||
'price': tax['amount'] * tax['base_sign'] or 0.0,
|
||||
'account_id': tax['account_collected_id'],
|
||||
'account_id': tax['account_collected_id'] or mres['account_id'],
|
||||
'tax_code_id': tax['tax_code_id'],
|
||||
'tax_amount': tax['amount'] * tax['base_sign'],
|
||||
}
|
||||
|
|
|
@ -202,8 +202,8 @@ class one2many_mod2(fields.one2many):
|
|||
res = {}
|
||||
for id in ids:
|
||||
res[id] = []
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids), ('appears_on_payslip', '=', True)], limit=self._limit)
|
||||
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids), ('appears_on_payslip', '=', True)], limit=self._limit)
|
||||
for r in obj.pool[self._obj]._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
res[r[self._fields_id]].append( r['id'] )
|
||||
return res
|
||||
|
||||
|
|
|
@ -389,7 +389,7 @@ class account_coda_import(osv.osv_memory):
|
|||
if statement['coda_note'] != '':
|
||||
self.pool.get('account.bank.statement').write(cr, uid, [statement['id']], {'coda_note': statement['coda_note']}, context=context)
|
||||
model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')
|
||||
action = self.pool.get(model).browse(cr, uid, action_id, context=context)
|
||||
action = self.pool[model].browse(cr, uid, action_id, context=context)
|
||||
return {
|
||||
'name': action.name,
|
||||
'view_type': action.view_type,
|
||||
|
|
|
@ -78,7 +78,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
else:
|
||||
#replace the value in the destination object only if it's the user lang
|
||||
if context.get('lang') == lang:
|
||||
self.pool.get(out_obj._name).write(cr, uid, out_ids[j], {in_field: value[in_id]})
|
||||
self.pool[out_obj._name].write(cr, uid, out_ids[j], {in_field: value[in_id]})
|
||||
else:
|
||||
_logger.info('Language: %s. Translation from template: there is no translation available for %s!' %(lang, src[in_id]))#out_obj._name))
|
||||
return True
|
||||
|
|
|
@ -27,6 +27,19 @@
|
|||
<field name="priority">1000</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_cron_mail_garbage_collect_attachments" model="ir.cron">
|
||||
<field name="name">Garbage Collect Mail Attachments</field>
|
||||
<field eval="True" name="active" />
|
||||
<field name="user_id" ref="base.user_root" />
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">weeks</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
<field name="model">mail.thread</field>
|
||||
<field name="function">_garbage_collect_attachments</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
<!-- Discussion subtype for messaging / Chatter -->
|
||||
<record id="mt_comment" model="mail.message.subtype">
|
||||
<field name="name">Discussions</field>
|
||||
|
|
|
@ -172,8 +172,8 @@ class mail_alias(osv.Model):
|
|||
|
||||
registry = RegistryManager.get(cr.dbname)
|
||||
mail_alias = registry.get('mail.alias')
|
||||
child_class_model = registry.get(child_model_name)
|
||||
no_alias_ids = child_class_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)], context={'active_test': False})
|
||||
child_class_model = registry[child_model_name]
|
||||
no_alias_ids = child_class_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)], context={'active_test':False})
|
||||
# Use read() not browse(), to avoid prefetching uninitialized inherited fields
|
||||
for obj_data in child_class_model.read(cr, SUPERUSER_ID, no_alias_ids, [alias_key]):
|
||||
alias_vals = {'alias_name': False}
|
||||
|
|
|
@ -108,8 +108,8 @@ class mail_mail(osv.Model):
|
|||
res_id = message.res_id
|
||||
|
||||
# if model and res_id: try to use ``message_get_reply_to`` that returns the document alias
|
||||
if model and res_id and hasattr(self.pool.get(model), 'message_get_reply_to'):
|
||||
email_reply_to = self.pool.get(model).message_get_reply_to(cr, uid, [res_id], context=context)[0]
|
||||
if model and res_id and hasattr(self.pool[model], 'message_get_reply_to'):
|
||||
email_reply_to = self.pool[model].message_get_reply_to(cr, uid, [res_id], context=context)[0]
|
||||
# no alias reply_to -> reply_to will be the email_from, only the email part
|
||||
if not email_reply_to and values.get('email_from'):
|
||||
emails = tools.email_split(values.get('email_from'))
|
||||
|
@ -118,7 +118,7 @@ class mail_mail(osv.Model):
|
|||
|
||||
# format 'Document name <email_address>'
|
||||
if email_reply_to and model and res_id:
|
||||
document_name = self.pool.get(model).name_get(cr, SUPERUSER_ID, [res_id], context=context)[0]
|
||||
document_name = self.pool[model].name_get(cr, SUPERUSER_ID, [res_id], context=context)[0]
|
||||
if document_name:
|
||||
# sanitize document name
|
||||
sanitized_doc_name = re.sub(r'[^\w+.]+', '-', document_name[1])
|
||||
|
@ -217,7 +217,7 @@ class mail_mail(osv.Model):
|
|||
and self.check_access_rights(cr, partner.user_ids[0].id, 'read', raise_exception=False):
|
||||
related_user = partner.user_ids[0]
|
||||
try:
|
||||
self.pool.get(mail.model).check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context)
|
||||
self.pool[mail.model].check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context)
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
# the parameters to encode for the query and fragment part of url
|
||||
query = {'db': cr.dbname}
|
||||
|
|
|
@ -76,9 +76,9 @@ class mail_message(osv.Model):
|
|||
# TDE note: regroup by model/ids, to have less queries to perform
|
||||
result = dict.fromkeys(ids, False)
|
||||
for message in self.read(cr, uid, ids, ['model', 'res_id'], context=context):
|
||||
if not message.get('model') or not message.get('res_id') or not self.pool.get(message['model']):
|
||||
if not message.get('model') or not message.get('res_id') or message['model'] not in self.pool:
|
||||
continue
|
||||
result[message['id']] = self.pool.get(message['model']).name_get(cr, SUPERUSER_ID, [message['res_id']], context=context)[0][1]
|
||||
result[message['id']] = self.pool[message['model']].name_get(cr, SUPERUSER_ID, [message['res_id']], context=context)[0][1]
|
||||
return result
|
||||
|
||||
def _get_to_read(self, cr, uid, ids, name, arg, context=None):
|
||||
|
@ -369,6 +369,7 @@ class mail_message(osv.Model):
|
|||
|
||||
return {'id': message.id,
|
||||
'type': message.type,
|
||||
'subtype': message.subtype_id.name if message.subtype_id else False,
|
||||
'body': body_html,
|
||||
'model': message.model,
|
||||
'res_id': message.res_id,
|
||||
|
@ -569,7 +570,7 @@ class mail_message(osv.Model):
|
|||
|
||||
def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None):
|
||||
doc_ids = doc_dict.keys()
|
||||
allowed_doc_ids = self.pool.get(doc_model).search(cr, uid, [('id', 'in', doc_ids)], context=context)
|
||||
allowed_doc_ids = self.pool[doc_model].search(cr, uid, [('id', 'in', doc_ids)], context=context)
|
||||
return set([message_id for allowed_doc_id in allowed_doc_ids for message_id in doc_dict[allowed_doc_id]])
|
||||
|
||||
def _find_allowed_doc_ids(self, cr, uid, model_ids, context=None):
|
||||
|
@ -717,7 +718,7 @@ class mail_message(osv.Model):
|
|||
model_record_ids = _generate_model_record_ids(message_values, other_ids)
|
||||
document_related_ids = []
|
||||
for model, doc_dict in model_record_ids.items():
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj = self.pool[model]
|
||||
mids = model_obj.exists(cr, uid, doc_dict.keys())
|
||||
if operation in ['create', 'write', 'unlink']:
|
||||
model_obj.check_access_rights(cr, uid, 'write')
|
||||
|
@ -773,7 +774,7 @@ class mail_message(osv.Model):
|
|||
attachments_to_delete = []
|
||||
for message in self.browse(cr, uid, ids, context=context):
|
||||
for attach in message.attachment_ids:
|
||||
if attach.res_model == self._name and attach.res_id == message.id:
|
||||
if attach.res_model == self._name and (attach.res_id == message.id or attach.res_id == 0):
|
||||
attachments_to_delete.append(attach.id)
|
||||
if attachments_to_delete:
|
||||
self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context)
|
||||
|
|
|
@ -408,7 +408,7 @@ class mail_thread(osv.AbstractModel):
|
|||
posted = False
|
||||
for subtype in subtypes:
|
||||
try:
|
||||
subtype_rec = self.pool.get('ir.model.data').get_object(cr, uid, subtype.split('.')[0], subtype.split('.')[1])
|
||||
subtype_rec = self.pool.get('ir.model.data').get_object(cr, uid, subtype.split('.')[0], subtype.split('.')[1], context=context)
|
||||
except ValueError, e:
|
||||
_logger.debug('subtype %s not found, giving error "%s"' % (subtype, e))
|
||||
continue
|
||||
|
@ -429,6 +429,26 @@ class mail_thread(osv.AbstractModel):
|
|||
return [('message_unread', '=', True)]
|
||||
return []
|
||||
|
||||
def _garbage_collect_attachments(self, cr, uid, context=None):
|
||||
""" Garbage collect lost mail attachments. Those are attachments
|
||||
- linked to res_model 'mail.compose.message', the composer wizard
|
||||
- with res_id 0, because they were created outside of an existing
|
||||
wizard (typically user input through Chatter or reports
|
||||
created on-the-fly by the templates)
|
||||
- unused since at least one day (create_date and write_date)
|
||||
"""
|
||||
limit_date = datetime.datetime.utcnow() - datetime.timedelta(days=1)
|
||||
limit_date_str = datetime.datetime.strftime(limit_date, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
ir_attachment_obj = self.pool.get('ir.attachment')
|
||||
attach_ids = ir_attachment_obj.search(cr, uid, [
|
||||
('res_model', '=', 'mail.compose.message'),
|
||||
('res_id', '=', 0),
|
||||
('create_date', '<', limit_date_str),
|
||||
('write_date', '<', limit_date_str),
|
||||
], context=context)
|
||||
ir_attachment_obj.unlink(cr, uid, attach_ids, context=context)
|
||||
return True
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email specific
|
||||
#------------------------------------------------------
|
||||
|
@ -449,13 +469,15 @@ class mail_thread(osv.AbstractModel):
|
|||
""" Used by the plugin addon, based for plugin_outlook and others. """
|
||||
ret_dict = {}
|
||||
for model_name in self.pool.obj_list():
|
||||
model = self.pool.get(model_name)
|
||||
model = self.pool[model_name]
|
||||
if 'mail.thread' in getattr(model, '_inherit', []):
|
||||
ret_dict[model_name] = model._description
|
||||
return ret_dict
|
||||
|
||||
def _message_find_partners(self, cr, uid, message, header_fields=['From'], context=None):
|
||||
""" Find partners related to some header fields of the message. """
|
||||
""" Find partners related to some header fields of the message.
|
||||
|
||||
TDE TODO: merge me with other partner finding methods in 8.0 """
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
partner_ids = []
|
||||
s = ', '.join([decode(message.get(h)) for h in header_fields if message.get(h)])
|
||||
|
@ -467,6 +489,7 @@ class mail_thread(osv.AbstractModel):
|
|||
return partner_ids
|
||||
|
||||
def _message_find_user_id(self, cr, uid, message, context=None):
|
||||
""" TDE TODO: check and maybe merge me with other user finding methods in 8.0 """
|
||||
from_local_part = tools.email_split(decode(message.get('From')))[0]
|
||||
# FP Note: canonification required, the minimu: .lower()
|
||||
user_ids = self.pool.get('res.users').search(cr, uid, ['|',
|
||||
|
@ -520,12 +543,12 @@ class mail_thread(osv.AbstractModel):
|
|||
if ref_match:
|
||||
thread_id = int(ref_match.group(1))
|
||||
model = ref_match.group(2) or model
|
||||
model_pool = self.pool.get(model)
|
||||
if thread_id and model and model_pool and model_pool.exists(cr, uid, thread_id) \
|
||||
and hasattr(model_pool, 'message_update'):
|
||||
_logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to model: %s, thread_id: %s, custom_values: %s, uid: %s',
|
||||
email_from, email_to, message_id, model, thread_id, custom_values, uid)
|
||||
return [(model, thread_id, custom_values, uid)]
|
||||
if thread_id and model in self.pool:
|
||||
model_obj = self.pool[model]
|
||||
if model_obj.exists(cr, uid, thread_id) and hasattr(model_obj, 'message_update'):
|
||||
_logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to model: %s, thread_id: %s, custom_values: %s, uid: %s',
|
||||
email_from, email_to, message_id, model, thread_id, custom_values, uid)
|
||||
return [(model, thread_id, custom_values, uid)]
|
||||
|
||||
# Verify whether this is a reply to a private message
|
||||
if in_reply_to:
|
||||
|
@ -683,7 +706,7 @@ class mail_thread(osv.AbstractModel):
|
|||
if self._name == 'mail.thread':
|
||||
context.update({'thread_model': model})
|
||||
if model:
|
||||
model_pool = self.pool.get(model)
|
||||
model_pool = self.pool[model]
|
||||
assert thread_id and hasattr(model_pool, 'message_update') or hasattr(model_pool, 'message_new'), \
|
||||
"Undeliverable mail with Message-Id %s, model %s does not accept incoming emails" % \
|
||||
(msg['message_id'], model)
|
||||
|
@ -737,7 +760,7 @@ class mail_thread(osv.AbstractModel):
|
|||
if isinstance(custom_values, dict):
|
||||
data = custom_values.copy()
|
||||
model = context.get('thread_model') or self._name
|
||||
model_pool = self.pool.get(model)
|
||||
model_pool = self.pool[model]
|
||||
fields = model_pool.fields_get(cr, uid, context=context)
|
||||
if 'name' in fields and not data.get('name'):
|
||||
data['name'] = msg_dict.get('subject', '')
|
||||
|
@ -909,7 +932,8 @@ class mail_thread(osv.AbstractModel):
|
|||
recipient in the result dictionary. The form is :
|
||||
partner_id, partner_name<partner_email> or partner_name, reason """
|
||||
if email and not partner:
|
||||
partner_info = self.message_get_partner_info_from_emails(cr, uid, [email], context=context)[0]
|
||||
# get partner info from email
|
||||
partner_info = self.message_get_partner_info_from_emails(cr, uid, [email], context=context, res_id=obj.id)[0]
|
||||
if partner_info.get('partner_id'):
|
||||
partner = self.pool.get('res.partner').browse(cr, SUPERUSER_ID, [partner_info.get('partner_id')], context=context)[0]
|
||||
if email and email in [val[1] for val in result[obj.id]]: # already existing email -> skip
|
||||
|
@ -937,29 +961,49 @@ class mail_thread(osv.AbstractModel):
|
|||
self._message_add_suggested_recipient(cr, uid, result, obj, partner=obj.user_id.partner_id, reason=self._all_columns['user_id'].column.string, context=context)
|
||||
return result
|
||||
|
||||
def message_get_partner_info_from_emails(self, cr, uid, emails, link_mail=False, context=None):
|
||||
def message_get_partner_info_from_emails(self, cr, uid, emails, link_mail=False, context=None, res_id=None):
|
||||
""" Wrapper with weird order parameter because of 7.0 fix.
|
||||
|
||||
TDE TODO: remove me in 8.0 """
|
||||
return self.message_find_partner_from_emails(cr, uid, res_id, emails, link_mail=link_mail, context=context)
|
||||
|
||||
def message_find_partner_from_emails(self, cr, uid, id, emails, link_mail=False, context=None):
|
||||
""" Convert a list of emails into a list partner_ids and a list
|
||||
new_partner_ids. The return value is non conventional because
|
||||
it is meant to be used by the mail widget.
|
||||
|
||||
:return dict: partner_ids and new_partner_ids
|
||||
"""
|
||||
|
||||
TDE TODO: merge me with other partner finding methods in 8.0 """
|
||||
mail_message_obj = self.pool.get('mail.message')
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
result = list()
|
||||
if id and self._name != 'mail.thread':
|
||||
obj = self.browse(cr, SUPERUSER_ID, id, context=context)
|
||||
else:
|
||||
obj = None
|
||||
for email in emails:
|
||||
partner_info = {'full_name': email, 'partner_id': False}
|
||||
m = re.search(r"((.+?)\s*<)?([^<>]+@[^<>]+)>?", email, re.IGNORECASE | re.DOTALL)
|
||||
if not m:
|
||||
continue
|
||||
email_address = m.group(3)
|
||||
ids = partner_obj.search(cr, SUPERUSER_ID, [('email', '=', email_address)], context=context)
|
||||
if ids:
|
||||
partner_info['partner_id'] = ids[0]
|
||||
# first try: check in document's followers
|
||||
if obj:
|
||||
for follower in obj.message_follower_ids:
|
||||
if follower.email == email_address:
|
||||
partner_info['partner_id'] = follower.id
|
||||
# second try: check in partners
|
||||
if not partner_info.get('partner_id'):
|
||||
ids = partner_obj.search(cr, SUPERUSER_ID, [('email', 'ilike', email_address), ('user_ids', '!=', False)], limit=1, context=context)
|
||||
if not ids:
|
||||
ids = partner_obj.search(cr, SUPERUSER_ID, [('email', 'ilike', email_address)], limit=1, context=context)
|
||||
if ids:
|
||||
partner_info['partner_id'] = ids[0]
|
||||
result.append(partner_info)
|
||||
|
||||
# link mail with this from mail to the new partner id
|
||||
if link_mail and ids:
|
||||
if link_mail and partner_info['partner_id']:
|
||||
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, [
|
||||
'|',
|
||||
('email_from', '=', email),
|
||||
|
@ -967,7 +1011,7 @@ class mail_thread(osv.AbstractModel):
|
|||
('author_id', '=', False)
|
||||
], context=context)
|
||||
if message_ids:
|
||||
mail_message_obj.write(cr, SUPERUSER_ID, message_ids, {'author_id': ids[0]}, context=context)
|
||||
mail_message_obj.write(cr, SUPERUSER_ID, message_ids, {'author_id': partner_info['partner_id']}, context=context)
|
||||
return result
|
||||
|
||||
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification',
|
||||
|
@ -1014,7 +1058,7 @@ class mail_thread(osv.AbstractModel):
|
|||
model = context.get('thread_model', self._name) if self._name == 'mail.thread' else self._name
|
||||
if model != self._name:
|
||||
del context['thread_model']
|
||||
return self.pool.get(model).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
|
||||
return self.pool[model].message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
|
||||
|
||||
# 0: Parse email-from, try to find a better author_id based on document's followers for incoming emails
|
||||
email_from = kwargs.get('email_from')
|
||||
|
@ -1063,7 +1107,6 @@ class mail_thread(osv.AbstractModel):
|
|||
if attachment_ids:
|
||||
filtered_attachment_ids = ir_attachment.search(cr, SUPERUSER_ID, [
|
||||
('res_model', '=', 'mail.compose.message'),
|
||||
('res_id', '=', 0),
|
||||
('create_uid', '=', uid),
|
||||
('id', 'in', attachment_ids)], context=context)
|
||||
if filtered_attachment_ids:
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
.openerp .oe_mail .oe_msg.oe_msg_nobody{
|
||||
background: #F8F8F8;
|
||||
}
|
||||
.openerp .oe_mail .oe_msg.oe_msg_notification{
|
||||
background: #F8F8F8;
|
||||
}
|
||||
.openerp .oe_mail .oe_msg .oe_msg_left{
|
||||
position: absolute;
|
||||
left:0; top: 0; bottom: 0; width: 40px;
|
||||
|
|
|
@ -217,6 +217,7 @@ openerp.mail = function (session) {
|
|||
this.res_id = datasets.res_id || this.context.default_res_id || false,
|
||||
this.parent_id = datasets.parent_id || false,
|
||||
this.type = datasets.type || false,
|
||||
this.subtype = datasets.subtype || false,
|
||||
this.is_author = datasets.is_author || false,
|
||||
this.is_private = datasets.is_private || false,
|
||||
this.subject = datasets.subject || false,
|
||||
|
@ -619,7 +620,10 @@ openerp.mail = function (session) {
|
|||
// have unknown names -> call message_get_partner_info_from_emails to try to find partner_id
|
||||
var find_done = $.Deferred();
|
||||
if (names_to_find.length > 0) {
|
||||
find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [names_to_find]);
|
||||
var values = {
|
||||
'res_id': this.context.default_res_id,
|
||||
}
|
||||
find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [names_to_find], values);
|
||||
}
|
||||
else {
|
||||
find_done.resolve([]);
|
||||
|
@ -665,7 +669,11 @@ openerp.mail = function (session) {
|
|||
var new_names_to_find = _.difference(names_to_find, names_to_remove);
|
||||
find_done = $.Deferred();
|
||||
if (new_names_to_find.length > 0) {
|
||||
find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [new_names_to_find, true]);
|
||||
var values = {
|
||||
'link_mail': true,
|
||||
'res_id': self.context.default_res_id,
|
||||
}
|
||||
find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [new_names_to_find], values);
|
||||
}
|
||||
else {
|
||||
find_done.resolve([]);
|
||||
|
|
|
@ -148,8 +148,6 @@ openerp_mail_followers = function(session, mail) {
|
|||
}).then(self.proxy('display_generic'));
|
||||
},
|
||||
_format_followers: function(count){
|
||||
// TDE note: why redefining _t ?
|
||||
function _t(str) { return str; }
|
||||
var str = '';
|
||||
if(count <= 0){
|
||||
str = _t('No followers');
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
|
||||
<!-- default layout -->
|
||||
<t t-name="mail.thread.message">
|
||||
<div t-attf-class="oe_msg #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} #{widget.partner_ids.length == 0 ? 'oe_msg_nobody' : ''} oe_msg_#{widget.type}">
|
||||
<div t-attf-class="oe_msg #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} #{widget.subtype ? '' : 'oe_msg_nobody'} oe_msg_#{widget.type}">
|
||||
|
||||
<div class='oe_msg_left'>
|
||||
<a t-if="widget.options.show_link" t-attf-href="#model=res.partner&id=#{widget.author_id[0]}" t-att-title="widget.author_id[1]">
|
||||
|
@ -263,13 +263,23 @@
|
|||
</t>
|
||||
<a t-if="widget.author_id and widget.options.show_link and widget.author_id[0]" t-attf-href="#model=res.partner&id=#{widget.author_id[0]}"><t t-raw="widget.author_id[2]"/></a>
|
||||
<span t-if="widget.author_id and (!widget.options.show_link or !widget.author_id[0])"><t t-raw="widget.author_id[2]"/></span>
|
||||
<t t-if="widget.partner_ids.length == 0">
|
||||
<t t-if="widget.type == 'notification'">
|
||||
updated document
|
||||
<t t-if="widget.partner_ids.length > 0">
|
||||
<span class='oe_subtle'>•</span>
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="widget.type == 'comment' and ! widget.subtype">
|
||||
logged a note
|
||||
</t>
|
||||
<t t-if="widget.partner_ids.length > 0">
|
||||
<t t-if="(widget.type == 'comment' or widget.type == 'email') and widget.subtype">
|
||||
to
|
||||
<t t-if="widget.partner_ids.length == 0">
|
||||
nobody
|
||||
</t>
|
||||
</t>
|
||||
<t t-foreach="widget.partner_ids.slice(0, 3)" t-as="partner">
|
||||
<t t-if="widget.type == 'notification' or ( (widget.type == 'email' or widget.type == 'comment') and widget.subtype)"
|
||||
t-foreach="widget.partner_ids.slice(0, 3)" t-as="partner">
|
||||
<span t-attf-class="oe_partner_follower">
|
||||
<a t-if="widget.options.show_link" t-attf-href="#model=res.partner&id=#{partner[0]}"><t t-raw="partner[1]"/></a>
|
||||
<t t-if="!widget.options.show_link" t-raw="partner[1]"/>
|
||||
|
@ -279,6 +289,9 @@
|
|||
<t t-if="widget.partner_ids.length > 3">
|
||||
<span t-att-title="widget.extra_partners_str">and <t t-raw="widget.extra_partners_nbr"/> more</span>
|
||||
</t>
|
||||
<t t-if="widget.type == 'notification' and widget.partner_ids.length > 0">
|
||||
notified
|
||||
</t>
|
||||
<span class='oe_subtle'>•</span>
|
||||
<span t-att-title="widget.date"><t t-if="widget.timerelative" t-raw="widget.timerelative"/><t t-if="!widget.timerelative" t-raw="widget.date"/></span>
|
||||
<span t-if="!widget.options.readonly" class='oe_subtle'>•</span>
|
||||
|
|
|
@ -83,7 +83,47 @@ Sylvie
|
|||
|
||||
class TestMailgateway(TestMailBase):
|
||||
|
||||
def test_00_message_process(self):
|
||||
def test_00_partner_find_from_email(self):
|
||||
""" Tests designed for partner fetch based on emails. """
|
||||
cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs
|
||||
|
||||
# --------------------------------------------------
|
||||
# Data creation
|
||||
# --------------------------------------------------
|
||||
# 1 - Partner ARaoul
|
||||
p_a_id = self.res_partner.create(cr, uid, {'name': 'ARaoul', 'email': 'test@test.fr'})
|
||||
|
||||
# --------------------------------------------------
|
||||
# CASE1: without object
|
||||
# --------------------------------------------------
|
||||
|
||||
# Do: find partner with email -> first partner should be found
|
||||
partner_info = self.mail_thread.message_find_partner_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0]
|
||||
self.assertEqual(partner_info['full_name'], 'Maybe Raoul <test@test.fr>',
|
||||
'mail_thread: message_find_partner_from_emails did not handle email')
|
||||
self.assertEqual(partner_info['partner_id'], p_a_id,
|
||||
'mail_thread: message_find_partner_from_emails wrong partner found')
|
||||
|
||||
# Data: add some data about partners
|
||||
# 2 - User BRaoul
|
||||
p_b_id = self.res_partner.create(cr, uid, {'name': 'BRaoul', 'email': 'test@test.fr', 'user_ids': [(4, user_raoul.id)]})
|
||||
|
||||
# Do: find partner with email -> first user should be found
|
||||
partner_info = self.mail_thread.message_find_partner_from_emails(cr, uid, None, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0]
|
||||
self.assertEqual(partner_info['partner_id'], p_b_id,
|
||||
'mail_thread: message_find_partner_from_emails wrong partner found')
|
||||
|
||||
# --------------------------------------------------
|
||||
# CASE1: with object
|
||||
# --------------------------------------------------
|
||||
|
||||
# Do: find partner in group where there is a follower with the email -> should be taken
|
||||
self.mail_group.message_subscribe(cr, uid, [group_pigs.id], [p_b_id])
|
||||
partner_info = self.mail_group.message_find_partner_from_emails(cr, uid, group_pigs.id, ['Maybe Raoul <test@test.fr>'], link_mail=False)[0]
|
||||
self.assertEqual(partner_info['partner_id'], p_b_id,
|
||||
'mail_thread: message_find_partner_from_emails wrong partner found')
|
||||
|
||||
def test_10_message_process(self):
|
||||
""" Testing incoming emails processing. """
|
||||
cr, uid, user_raoul = self.cr, self.uid, self.user_raoul
|
||||
|
||||
|
@ -341,7 +381,7 @@ class TestMailgateway(TestMailBase):
|
|||
self.assertEqual(msg.body, '<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>',
|
||||
'message_process: plaintext incoming email incorrectly parsed')
|
||||
|
||||
def test_10_thread_parent_resolution(self):
|
||||
def test_20_thread_parent_resolution(self):
|
||||
""" Testing parent/child relationships are correctly established when processing incoming mails """
|
||||
cr, uid = self.cr, self.uid
|
||||
|
||||
|
@ -386,7 +426,7 @@ class TestMailgateway(TestMailBase):
|
|||
self.assertEqual(6, len(group_pigs.message_ids), 'message_process: group should contain 6 messages')
|
||||
self.assertEqual(3, len(msg1.child_ids), 'message_process: msg1 should have 3 children now')
|
||||
|
||||
def test_20_private_discussion(self):
|
||||
def test_30_private_discussion(self):
|
||||
""" Testing private discussion between partners. """
|
||||
cr, uid = self.cr, self.uid
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ class invite_wizard(osv.osv_memory):
|
|||
res_id = result.get('res_id')
|
||||
if 'message' in fields and model and res_id:
|
||||
ir_model = self.pool.get('ir.model')
|
||||
model_ids = ir_model.search(cr, uid, [('model', '=', self.pool.get(model)._name)], context=context)
|
||||
model_ids = ir_model.search(cr, uid, [('model', '=', self.pool[model]._name)], context=context)
|
||||
model_name = ir_model.name_get(cr, uid, model_ids, context=context)[0][1]
|
||||
|
||||
document_name = self.pool.get(model).name_get(cr, uid, [res_id], context=context)[0][1]
|
||||
document_name = self.pool[model].name_get(cr, uid, [res_id], context=context)[0][1]
|
||||
message = _('<div><p>Hello,</p><p>%s invited you to follow %s document: %s.<p></div>') % (user_name, model_name, document_name)
|
||||
result['message'] = message
|
||||
elif 'message' in fields:
|
||||
|
@ -63,7 +63,7 @@ class invite_wizard(osv.osv_memory):
|
|||
|
||||
def add_followers(self, cr, uid, ids, context=None):
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
model_obj = self.pool.get(wizard.res_model)
|
||||
model_obj = self.pool[wizard.res_model]
|
||||
document = model_obj.browse(cr, uid, wizard.res_id, context=context)
|
||||
|
||||
# filter partner_ids to get the new followers, to avoid sending email to already following partners
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import base64
|
||||
import re
|
||||
from openerp import tools
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import osv
|
||||
from openerp.osv import fields
|
||||
|
@ -174,7 +172,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
related to.
|
||||
:param int res_id: id of the document record this mail is related to
|
||||
"""
|
||||
doc_name_get = self.pool.get(model).name_get(cr, uid, [res_id], context=context)
|
||||
doc_name_get = self.pool[model].name_get(cr, uid, [res_id], context=context)
|
||||
record_name = False
|
||||
if doc_name_get:
|
||||
record_name = doc_name_get[0][1]
|
||||
|
@ -230,33 +228,35 @@ class mail_compose_message(osv.TransientModel):
|
|||
email(s), rendering any template patterns on the fly if needed. """
|
||||
if context is None:
|
||||
context = {}
|
||||
ir_attachment_obj = self.pool.get('ir.attachment')
|
||||
active_ids = context.get('active_ids')
|
||||
is_log = context.get('mail_compose_log', False)
|
||||
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
mass_mail_mode = wizard.composition_mode == 'mass_mail'
|
||||
if mass_mail_mode: # mass mail: avoid any auto subscription because this could lead to people being follower of plenty of documents
|
||||
context['mail_create_nosubscribe'] = True
|
||||
active_model_pool = self.pool.get(wizard.model if wizard.model else 'mail.thread')
|
||||
active_model_pool = self.pool[wizard.model if wizard.model else 'mail.thread']
|
||||
|
||||
# wizard works in batch mode: [res_id] or active_ids
|
||||
res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id]
|
||||
for res_id in res_ids:
|
||||
# default values, according to the wizard options
|
||||
# mail.message values, according to the wizard options
|
||||
post_values = {
|
||||
'subject': wizard.subject,
|
||||
'body': wizard.body,
|
||||
'parent_id': wizard.parent_id and wizard.parent_id.id,
|
||||
'partner_ids': [partner.id for partner in wizard.partner_ids],
|
||||
'attachments': [(attach.datas_fname or attach.name, base64.b64decode(attach.datas)) for attach in wizard.attachment_ids],
|
||||
'attachment_ids': [attach.id for attach in wizard.attachment_ids],
|
||||
}
|
||||
# mass mailing: render and override default values
|
||||
if mass_mail_mode and wizard.model:
|
||||
email_dict = self.render_message(cr, uid, wizard, res_id, context=context)
|
||||
new_partner_ids = email_dict.pop('partner_ids', [])
|
||||
post_values['partner_ids'] += new_partner_ids
|
||||
new_attachments = email_dict.pop('attachments', [])
|
||||
post_values['attachments'] += new_attachments
|
||||
post_values['partner_ids'] += email_dict.pop('partner_ids', [])
|
||||
post_values['attachments'] = email_dict.pop('attachments', [])
|
||||
attachment_ids = []
|
||||
for attach_id in post_values.pop('attachment_ids'):
|
||||
new_attach_id = ir_attachment_obj.copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context)
|
||||
attachment_ids.append(new_attach_id)
|
||||
post_values['attachment_ids'] = attachment_ids
|
||||
post_values.update(email_dict)
|
||||
# email_from: mass mailing only can specify another email_from
|
||||
if email_dict.get('email_from'):
|
||||
|
@ -319,7 +319,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
exp = str(match.group()[2:-1]).strip()
|
||||
result = eval(exp, {
|
||||
'user': self.pool.get('res.users').browse(cr, uid, uid, context=context),
|
||||
'object': self.pool.get(model).browse(cr, uid, res_id, context=context),
|
||||
'object': self.pool[model].browse(cr, uid, res_id, context=context),
|
||||
'context': dict(context), # copy context to prevent side-effects of eval
|
||||
})
|
||||
return result and tools.ustr(result) or ''
|
||||
|
|
|
@ -165,7 +165,7 @@ Normal - the campaign runs normally and automatically sends all emails and repor
|
|||
|
||||
# dead code
|
||||
def signal(self, cr, uid, model, res_id, signal, run_existing=True, context=None):
|
||||
record = self.pool.get(model).browse(cr, uid, res_id, context)
|
||||
record = self.pool[model].browse(cr, uid, res_id, context)
|
||||
return self._signal(cr, uid, record, signal, run_existing, context)
|
||||
|
||||
#dead code
|
||||
|
@ -228,7 +228,7 @@ Normal - the campaign runs normally and automatically sends all emails and repor
|
|||
if unique_value:
|
||||
if unique_field.ttype == 'many2one':
|
||||
unique_value = unique_value.id
|
||||
similar_res_ids = self.pool.get(campaign_rec.object_id.model).search(cr, uid,
|
||||
similar_res_ids = self.pool[campaign_rec.object_id.model].search(cr, uid,
|
||||
[(unique_field.name, '=', unique_value)], context=context)
|
||||
if similar_res_ids:
|
||||
duplicate_workitem_domain = [('res_id','in', similar_res_ids),
|
||||
|
@ -349,7 +349,7 @@ class marketing_campaign_segment(osv.osv):
|
|||
act_ids = self.pool.get('marketing.campaign.activity').search(cr,
|
||||
uid, [('start', '=', True), ('campaign_id', '=', segment.campaign_id.id)], context=context)
|
||||
|
||||
model_obj = self.pool.get(segment.object_id.model)
|
||||
model_obj = self.pool[segment.object_id.model]
|
||||
criteria = []
|
||||
if segment.sync_last_date and segment.sync_mode != 'all':
|
||||
criteria += [(segment.sync_mode, '>', segment.sync_last_date)]
|
||||
|
@ -594,7 +594,7 @@ class marketing_campaign_workitem(osv.osv):
|
|||
if not wi.res_id:
|
||||
continue
|
||||
|
||||
proxy = self.pool.get(wi.object_id.model)
|
||||
proxy = self.pool[wi.object_id.model]
|
||||
if not proxy.exists(cr, uid, [wi.res_id]):
|
||||
continue
|
||||
ng = proxy.name_get(cr, uid, [wi.res_id], context=context)
|
||||
|
@ -628,7 +628,7 @@ class marketing_campaign_workitem(osv.osv):
|
|||
for id, res_id, model in res:
|
||||
workitem_map.setdefault(model,{}).setdefault(res_id,set()).add(id)
|
||||
for model, id_map in workitem_map.iteritems():
|
||||
model_pool = self.pool.get(model)
|
||||
model_pool = self.pool[model]
|
||||
condition_name[0] = model_pool._rec_name
|
||||
condition = [('id', 'in', id_map.keys()), condition_name]
|
||||
for res_id in model_pool.search(cr, uid, condition, context=context):
|
||||
|
@ -676,7 +676,7 @@ class marketing_campaign_workitem(osv.osv):
|
|||
return False
|
||||
|
||||
activity = workitem.activity_id
|
||||
proxy = self.pool.get(workitem.object_id.model)
|
||||
proxy = self.pool[workitem.object_id.model]
|
||||
object_id = proxy.browse(cr, uid, workitem.res_id, context=context)
|
||||
|
||||
eval_context = {
|
||||
|
|
|
@ -42,7 +42,7 @@ class pad_common(osv.osv_memory):
|
|||
myPad.createPad(path)
|
||||
|
||||
#get attr on the field model
|
||||
model = self.pool.get(context["model"])
|
||||
model = self.pool[context["model"]]
|
||||
field = model._all_columns[context['field_name']]
|
||||
real_field = field.column.pad_content_field
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class plugin_handler(osv.osv_memory):
|
|||
res_id = msg.res_id
|
||||
model = msg.model
|
||||
url = self._make_url(cr, uid, res_id, model)
|
||||
name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1]
|
||||
name = self.pool[model].name_get(cr, uid, [res_id])[0][1]
|
||||
return (model, res_id, url, name)
|
||||
|
||||
def document_type(self, cr, uid, context=None):
|
||||
|
@ -82,7 +82,7 @@ class plugin_handler(osv.osv_memory):
|
|||
@return : the result of name_search a list of tuple
|
||||
[(id, 'name')]
|
||||
"""
|
||||
return self.pool.get(model).name_search(cr, uid, name)
|
||||
return self.pool[model].name_search(cr, uid, name)
|
||||
|
||||
def push_message(self, cr, uid, model, email, res_id=0):
|
||||
"""
|
||||
|
@ -92,7 +92,7 @@ class plugin_handler(osv.osv_memory):
|
|||
@return Dictionary which contain model , url and resource id.
|
||||
"""
|
||||
mail_message = self.pool.get('mail.message')
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj = self.pool[model]
|
||||
msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
|
||||
message_id = msg.get('message-id')
|
||||
mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
|
||||
|
|
|
@ -50,7 +50,7 @@ class pos_config(osv.osv):
|
|||
required=True, help="An internal identification of the point of sale"),
|
||||
'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel',
|
||||
'pos_config_id', 'journal_id', 'Available Payment Methods',
|
||||
domain="[('journal_user', '=', True )]",),
|
||||
domain="[('journal_user', '=', True ), ('type', 'in', ['bank', 'cash'])]",),
|
||||
'shop_id' : fields.many2one('sale.shop', 'Shop',
|
||||
required=True),
|
||||
'journal_id' : fields.many2one('account.journal', 'Sale Journal',
|
||||
|
@ -408,6 +408,9 @@ class pos_session(osv.osv):
|
|||
if not self.pool.get('ir.model.access').check_groups(cr, uid, "point_of_sale.group_pos_manager"):
|
||||
raise osv.except_osv( _('Error!'),
|
||||
_("Your ending balance is too different from the theorical cash closing (%.2f), the maximum allowed is: %.2f. You can contact your manager to force it.") % (st.difference, st.journal_id.amount_authorized_diff))
|
||||
if (st.journal_id.type not in ['bank', 'cash']):
|
||||
raise osv.except_osv(_('Error!'),
|
||||
_("The type of the journal for your payment method should be bank or cash "))
|
||||
if st.difference and st.journal_id.cash_control == True:
|
||||
if st.difference > 0.0:
|
||||
name= _('Point of Sale Profit')
|
||||
|
@ -428,7 +431,6 @@ class pos_session(osv.osv):
|
|||
|
||||
if st.journal_id.type == 'bank':
|
||||
st.write({'balance_end_real' : st.balance_end})
|
||||
|
||||
getattr(st, 'button_confirm_%s' % st.journal_id.type)(context=context)
|
||||
self._confirm_orders(cr, uid, ids, context=context)
|
||||
self.write(cr, uid, ids, {'state' : 'closed'}, context=context)
|
||||
|
@ -522,6 +524,24 @@ class pos_order(osv.osv):
|
|||
self.signal_paid(cr, uid, [order_id])
|
||||
return order_ids
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
res = super(pos_order, self).write(cr, uid, ids, vals, context=context)
|
||||
#If you change the partner of the PoS order, change also the partner of the associated bank statement lines
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
bsl_obj = self.pool.get("account.bank.statement.line")
|
||||
if 'partner_id' in vals:
|
||||
for posorder in self.browse(cr, uid, ids, context=context):
|
||||
if posorder.invoice_id:
|
||||
raise osv.except_osv( _('Error!'), _("You cannot change the partner of a POS order for which an invoice has already been issued."))
|
||||
if vals['partner_id']:
|
||||
p_id = partner_obj.browse(cr, uid, vals['partner_id'], context=context)
|
||||
part_id = partner_obj._find_accounting_partner(p_id).id
|
||||
else:
|
||||
part_id = False
|
||||
bsl_ids = [x.id for x in posorder.statement_ids]
|
||||
bsl_obj.write(cr, uid, bsl_ids, {'partner_id': part_id}, context=context)
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
for rec in self.browse(cr, uid, ids, context=context):
|
||||
if rec.state not in ('draft','cancel'):
|
||||
|
@ -948,9 +968,9 @@ class pos_order(osv.osv):
|
|||
})
|
||||
|
||||
if data_type == 'product':
|
||||
key = ('product', values['product_id'],)
|
||||
key = ('product', values['partner_id'], values['product_id'])
|
||||
elif data_type == 'tax':
|
||||
key = ('tax', values['tax_code_id'],)
|
||||
key = ('tax', values['partner_id'], values['tax_code_id'],)
|
||||
elif data_type == 'counter_part':
|
||||
key = ('counter_part', values['partner_id'], values['account_id'])
|
||||
else:
|
||||
|
@ -1026,7 +1046,7 @@ class pos_order(osv.osv):
|
|||
'debit': ((amount<0) and -amount) or 0.0,
|
||||
'tax_code_id': tax_code_id,
|
||||
'tax_amount': tax_amount,
|
||||
'partner_id': order.partner_id and order.partner_id.id or False
|
||||
'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False
|
||||
})
|
||||
|
||||
# For each remaining tax with a code, whe create a move line
|
||||
|
@ -1044,6 +1064,7 @@ class pos_order(osv.osv):
|
|||
'debit': 0.0,
|
||||
'tax_code_id': tax_code_id,
|
||||
'tax_amount': tax_amount,
|
||||
'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False
|
||||
})
|
||||
|
||||
# Create a move for each tax group
|
||||
|
@ -1060,6 +1081,7 @@ class pos_order(osv.osv):
|
|||
'debit': ((tax_amount<0) and -tax_amount) or 0.0,
|
||||
'tax_code_id': key[tax_code_pos],
|
||||
'tax_amount': tax_amount,
|
||||
'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False
|
||||
})
|
||||
|
||||
# counterpart
|
||||
|
@ -1068,14 +1090,17 @@ class pos_order(osv.osv):
|
|||
'account_id': order_account,
|
||||
'credit': ((order.amount_total < 0) and -order.amount_total) or 0.0,
|
||||
'debit': ((order.amount_total > 0) and order.amount_total) or 0.0,
|
||||
'partner_id': order.partner_id and order.partner_id.id or False
|
||||
'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False
|
||||
})
|
||||
|
||||
order.write({'state':'done', 'account_move': move_id})
|
||||
|
||||
all_lines = []
|
||||
for group_key, group_data in grouped_data.iteritems():
|
||||
for value in group_data:
|
||||
account_move_line_obj.create(cr, uid, value, context=context)
|
||||
all_lines.append((0, 0, value),)
|
||||
if move_id: #In case no order was changed
|
||||
self.pool.get("account.move").write(cr, uid, [move_id], {'line_id':all_lines}, context=context)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -1279,7 +1304,7 @@ class ean_wizard(osv.osv_memory):
|
|||
ean13 = openerp.addons.product.product.sanitize_ean13(r.ean13_pattern)
|
||||
m = context.get('active_model')
|
||||
m_id = context.get('active_id')
|
||||
self.pool.get(m).write(cr,uid,[m_id],{'ean13':ean13})
|
||||
self.pool[m].write(cr,uid,[m_id],{'ean13':ean13})
|
||||
return { 'type' : 'ir.actions.act_window_close' }
|
||||
|
||||
class product_product(osv.osv):
|
||||
|
|
|
@ -430,6 +430,7 @@
|
|||
<field name="available_in_pos">True</field>
|
||||
<field name="list_price">1.49</field>
|
||||
<field name="name">Coca-Cola Regular 1L</field>
|
||||
<field name="ean13">5449000054227</field>
|
||||
<field name="pos_categ_id" ref="coke"/>
|
||||
<field name="image">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</field>
|
||||
</record>
|
||||
|
@ -716,6 +717,7 @@
|
|||
<record id="chaudfontaine_50cl" model="product.product">
|
||||
<field name="available_in_pos">True</field>
|
||||
<field name="list_price">0.44</field>
|
||||
<field name="ean13">5449000111715</field>
|
||||
<field name="name">Chaudfontaine 50cl</field>
|
||||
<field name="pos_categ_id" ref="plain_water"/>
|
||||
<field name="image">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</field>
|
||||
|
@ -830,6 +832,7 @@
|
|||
<record id="jupiler_33cl" model="product.product">
|
||||
<field name="available_in_pos">True</field>
|
||||
<field name="list_price">0.77</field>
|
||||
<field name="ean13">5410228142027</field>
|
||||
<field name="name">Jupiler 33cl</field>
|
||||
<field name="pos_categ_id" ref="pils"/>
|
||||
<field name="image">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</field>
|
||||
|
|
|
@ -16,7 +16,7 @@ class PosBox(CashBox):
|
|||
active_ids = context.get('active_ids', []) or []
|
||||
|
||||
if active_model == 'pos.session':
|
||||
records = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)
|
||||
records = self.pool[active_model].browse(cr, uid, active_ids, context=context)
|
||||
bank_statements = [record.cash_register_id for record in records if record.cash_register_id]
|
||||
|
||||
if not bank_statements:
|
||||
|
@ -41,7 +41,7 @@ class PosBoxIn(PosBox):
|
|||
active_ids = context.get('active_ids', []) or []
|
||||
|
||||
if active_model == 'pos.session':
|
||||
session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0]
|
||||
session = self.pool[active_model].browse(cr, uid, active_ids, context=context)[0]
|
||||
values['ref'] = session.name
|
||||
|
||||
return values
|
||||
|
@ -57,7 +57,7 @@ class PosBoxOut(PosBox):
|
|||
active_ids = context.get('active_ids', []) or []
|
||||
|
||||
if active_model == 'pos.session':
|
||||
session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0]
|
||||
session = self.pool[active_model].browse(cr, uid, active_ids, context=context)[0]
|
||||
values['ref'] = session.name
|
||||
|
||||
return values
|
||||
|
|
|
@ -45,7 +45,7 @@ class mail_mail(osv.Model):
|
|||
and self.check_access_rights(cr, partner.user_ids[0].id, 'read', raise_exception=False):
|
||||
related_user = partner.user_ids[0]
|
||||
try:
|
||||
self.pool.get(mail.model).check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context)
|
||||
self.pool[mail.model].check_access_rule(cr, related_user.id, [mail.res_id], 'read', context=context)
|
||||
url = partner_obj._get_signup_url_for_action(cr, related_user.id, [partner.id], action='', res_id=mail.res_id, model=mail.model, context=context)[partner.id]
|
||||
text = _("""<small>Access this document <a style='color:inherit' href="%s">directly in OpenERP</a></small>""") % url
|
||||
except except_orm, e:
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Russian translation for openobject-addons
|
||||
# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
|
||||
# This file is distributed under the same license as the openobject-addons package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: openobject-addons\n"
|
||||
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"POT-Creation-Date: 2012-12-21 17:05+0000\n"
|
||||
"PO-Revision-Date: 2013-04-09 13:04+0000\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Launchpad-Export-Date: 2013-04-10 05:21+0000\n"
|
||||
"X-Generator: Launchpad (build 16550)\n"
|
||||
|
||||
#. module: portal_anonymous
|
||||
#. openerp-web
|
||||
#: code:addons/portal_anonymous/static/src/xml/portal_anonymous.xml:8
|
||||
#, python-format
|
||||
msgid "Login"
|
||||
msgstr "Вход"
|
|
@ -17,19 +17,5 @@
|
|||
<field name="groups" eval="[(4, ref('portal.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="portal_stock_move_user_rule" model="ir.rule">
|
||||
<field name="name">Portal Personal Stock Moves</field>
|
||||
<field name="model_id" ref="stock.model_stock_move"/>
|
||||
<field name="domain_force">[('message_follower_ids','in',[user.partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('portal.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="portal_stock_warehouse_orderpoint_user_rule" model="ir.rule">
|
||||
<field name="name">Portal Personal Stock Warehouse Orderpoints</field>
|
||||
<field name="model_id" ref="procurement.model_stock_warehouse_orderpoint"/>
|
||||
<field name="domain_force">[('message_follower_ids','in',[user.partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('portal.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -155,7 +155,7 @@ class procurement_order(osv.osv):
|
|||
warehouse_obj = self.pool.get('stock.warehouse')
|
||||
|
||||
warehouse_ids = warehouse_obj.search(cr, uid, [], context=context)
|
||||
products_ids = product_obj.search(cr, uid, [('purchase_ok', '=', True)], order='id', context=context)
|
||||
products_ids = product_obj.search(cr, uid, [], order='id', context=context)
|
||||
|
||||
for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context):
|
||||
context['warehouse'] = warehouse
|
||||
|
|
|
@ -125,7 +125,7 @@ class project_task_delegate(osv.osv_memory):
|
|||
action_model, action_id = models_data.get_object_reference(cr, uid, 'project', 'action_view_task')
|
||||
view_model, task_view_form_id = models_data.get_object_reference(cr, uid, 'project', 'view_task_form2')
|
||||
view_model, task_view_tree_id = models_data.get_object_reference(cr, uid, 'project', 'view_task_tree2')
|
||||
action = self.pool.get(action_model).read(cr, uid, action_id, context=context)
|
||||
action = self.pool[action_model].read(cr, uid, action_id, context=context)
|
||||
action['res_id'] = delegated_tasks[task_id]
|
||||
action['view_id'] = False
|
||||
action['views'] = [(task_view_form_id, 'form'), (task_view_tree_id, 'tree')]
|
||||
|
|
|
@ -283,9 +283,11 @@ class account_analytic_account(osv.osv):
|
|||
res['value']['use_phases'] = template.use_phases
|
||||
return res
|
||||
|
||||
|
||||
def _trigger_project_creation(self, cr, uid, vals, context=None):
|
||||
res= super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)
|
||||
return res or vals.get('use_phases')
|
||||
if context is None: context = {}
|
||||
res = super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)
|
||||
return res or (vals.get('use_phases') and not 'project_creation_in_progress' in context)
|
||||
|
||||
account_analytic_account()
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
assert (not project and not account) or project.analytic_account_id == account, "Project does not correspond."
|
||||
planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context)
|
||||
assert task.planned_hours == planned_hours, 'Planned Hours do not correspond.'
|
||||
assert datetime.strptime(task.date_deadline, '%Y-%m-%d') == datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S'), 'Deadline does not correspond.'
|
||||
assert datetime.strptime(task.date_deadline, '%Y-%m-%d') == datetime.strptime(procurement.date_planned[:10], '%Y-%m-%d'), 'Deadline does not correspond.'
|
||||
if procurement.product_id.product_manager:
|
||||
assert task.user_id.id == procurement.product_id.product_manager.id, 'Allocated Person does not correspond with Service Product Manager.'
|
||||
-
|
||||
|
|
|
@ -24,8 +24,12 @@ from openerp.osv import osv,fields
|
|||
class company(osv.osv):
|
||||
_inherit = 'res.company'
|
||||
_columns = {
|
||||
'po_lead': fields.float('Purchase Lead Time', required=True,
|
||||
help="This is the leads/security time for each purchase order."),
|
||||
'po_lead': fields.float(
|
||||
'Purchase Lead Time', required=True,
|
||||
help="Margin of error for supplier lead times. When the system"\
|
||||
"generates Purchase Orders for procuring products,"\
|
||||
"they will be scheduled that many days earlier "\
|
||||
"to cope with unexpected supplier delays."),
|
||||
}
|
||||
_defaults = {
|
||||
'po_lead': lambda *a: 1.0,
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import pytz
|
||||
from openerp import SUPERUSER_ID
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from operator import attrgetter
|
||||
|
@ -371,7 +373,7 @@ class purchase_order(osv.osv):
|
|||
pick_ids += [picking.id for picking in po.picking_ids]
|
||||
|
||||
action_model, action_id = tuple(mod_obj.get_object_reference(cr, uid, 'stock', 'action_picking_tree4'))
|
||||
action = self.pool.get(action_model).read(cr, uid, action_id, context=context)
|
||||
action = self.pool[action_model].read(cr, uid, action_id, context=context)
|
||||
ctx = eval(action['context'])
|
||||
ctx.update({
|
||||
'search_default_purchase_id': ids[0]
|
||||
|
@ -592,11 +594,34 @@ class purchase_order(osv.osv):
|
|||
self.signal_purchase_cancel(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def date_to_datetime(self, cr, uid, userdate, context=None):
|
||||
""" Convert date values expressed in user's timezone to
|
||||
server-side UTC timestamp, assuming a default arbitrary
|
||||
time of 12:00 AM - because a time is needed.
|
||||
|
||||
:param str userdate: date string in in user time zone
|
||||
:return: UTC datetime string for server-side use
|
||||
"""
|
||||
# TODO: move to fields.datetime in server after 7.0
|
||||
user_date = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT)
|
||||
if context and context.get('tz'):
|
||||
tz_name = context['tz']
|
||||
else:
|
||||
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
||||
if tz_name:
|
||||
utc = pytz.timezone('UTC')
|
||||
context_tz = pytz.timezone(tz_name)
|
||||
user_datetime = user_date + relativedelta(hours=12.0)
|
||||
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
||||
user_datetime = local_timestamp.astimezone(utc)
|
||||
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return user_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||
return {
|
||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
|
||||
'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
|
||||
'date': order.date_order,
|
||||
'date': self.date_to_datetime(cr, uid, order.date_order, context),
|
||||
'partner_id': order.dest_address_id.id or order.partner_id.id,
|
||||
'invoice_state': '2binvoiced' if order.invoice_method == 'picking' else 'none',
|
||||
'type': 'in',
|
||||
|
@ -614,8 +639,8 @@ class purchase_order(osv.osv):
|
|||
'product_uos_qty': order_line.product_qty,
|
||||
'product_uom': order_line.product_uom.id,
|
||||
'product_uos': order_line.product_uom.id,
|
||||
'date': order_line.date_planned,
|
||||
'date_expected': order_line.date_planned,
|
||||
'date': self.date_to_datetime(cr, uid, order.date_order, context),
|
||||
'date_expected': self.date_to_datetime(cr, uid, order.date_order, context),
|
||||
'location_id': order.partner_id.property_stock_supplier.id,
|
||||
'location_dest_id': order.location_id.id,
|
||||
'picking_id': picking_id,
|
||||
|
|
|
@ -38,5 +38,22 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<!-- Replace analytic_id with analytics_id in account.invoice.line -->
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="invoice_supplier_form_inherit">
|
||||
<field name="name">account.invoice.supplier.form.inherit</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="priority">2</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_analytic_id" position="replace">
|
||||
<field name="analytics_id" domain="[('plan_id','<>',False)]" context="{'journal_id':parent.journal_id}" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -211,8 +211,7 @@ class sale_order(osv.osv):
|
|||
'order_policy': fields.selection([
|
||||
('manual', 'On Demand'),
|
||||
], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
|
||||
help="""This field controls how invoice and delivery operations are synchronized.
|
||||
- With 'Before Delivery', a draft invoice is created, and it must be paid before delivery."""),
|
||||
help="""This field controls how invoice and delivery operations are synchronized."""),
|
||||
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."),
|
||||
'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=True, required=True),
|
||||
'project_id': fields.many2one('account.analytic.account', 'Contract / Analytic', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."),
|
||||
|
|
|
@ -38,5 +38,19 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Replace analytic_id with analytics_id in account.invoice.line -->
|
||||
|
||||
<record model="ir.ui.view" id="view_invoice_line_form_inherit">
|
||||
<field name="name">account.invoice.line.form.inherit</field>
|
||||
<field name="model">account.invoice.line</field>
|
||||
<field name="inherit_id" ref="account.view_invoice_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_analytic_id" position="replace">
|
||||
<field name="analytics_id" context="{'journal_id':parent.journal_id}" domain="[('plan_id','<>',False)]" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -68,6 +68,21 @@ class res_users(osv.Model):
|
|||
}
|
||||
|
||||
|
||||
class sale_crm_lead(osv.Model):
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
def on_change_user(self, cr, uid, ids, user_id, context=None):
|
||||
""" Override of on change user_id on lead/opportunity; when having sale
|
||||
the new logic is :
|
||||
- use user.default_section_id
|
||||
- or fallback on previous behavior """
|
||||
if user_id:
|
||||
user = self.pool.get('res.users').browse(cr, uid, user_id, context=context)
|
||||
if user.default_section_id and user.default_section_id.id:
|
||||
return {'value': {'section_id': user.default_section_id.id}}
|
||||
return super(sale_crm_lead, self).on_change_user(cr, uid, ids, user_id, context=context)
|
||||
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
_inherit = 'account.invoice'
|
||||
_columns = {
|
||||
|
|
|
@ -24,9 +24,12 @@ from openerp.osv import fields, osv
|
|||
class company(osv.osv):
|
||||
_inherit = 'res.company'
|
||||
_columns = {
|
||||
'security_lead': fields.float('Security Days', required=True,
|
||||
help="This is the days added to what you promise to customers "\
|
||||
"for security purpose"),
|
||||
'security_lead': fields.float(
|
||||
'Security Days', required=True,
|
||||
help="Margin of error for dates promised to customers. "\
|
||||
"Products will be scheduled for procurement and delivery "\
|
||||
"that many days earlier than the actual promised date, to "\
|
||||
"cope with unexpected delays in the supply chain."),
|
||||
}
|
||||
_defaults = {
|
||||
'security_lead': 0.0,
|
||||
|
|
|
@ -64,17 +64,6 @@
|
|||
</record>
|
||||
|
||||
|
||||
<!--
|
||||
Process Condition
|
||||
-->
|
||||
|
||||
<record id="process_condition_conditionafterdelivery0" model="process.condition">
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="node_id" ref="process_node_invoiceafterdelivery0"/>
|
||||
<field eval=""""object.order_policy=='postpaid'"""" name="model_states"/>
|
||||
<field eval=""""condition_after_delivery"""" name="name"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Process Transition
|
||||
-->
|
||||
|
@ -106,7 +95,7 @@
|
|||
<record id="process_transition_invoiceafterdelivery0" model="process.transition">
|
||||
<field eval="[(6,0,[])]" name="transition_ids"/>
|
||||
<field eval=""""Create Invoice"""" name="name"/>
|
||||
<field eval=""""The invoice is created automatically if the shipping policy is 'Invoice from pick' or 'Invoice on order after delivery'."""" name="note"/>
|
||||
<field eval=""""If the sale order was set to create the invoice 'On Delivery Order', then an invoice is automatically created based on what you delivered. If you rather want to create your invoice based on your sale order, you can set the sale order to create invoice 'On Demand', then track and process the sales order that have been fully delivered and invoice them from there."""" name="note"/>
|
||||
<field model="process.node" name="target_node_id" ref="process_node_invoiceafterdelivery0"/>
|
||||
<field model="process.node" name="source_node_id" ref="process_node_packinglist0"/>
|
||||
</record>
|
||||
|
|
|
@ -24,6 +24,8 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FO
|
|||
from dateutil.relativedelta import relativedelta
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
import pytz
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
class sale_shop(osv.osv):
|
||||
_inherit = "sale.shop"
|
||||
|
@ -229,6 +231,29 @@ class sale_order(osv.osv):
|
|||
res.append(line.procurement_id.id)
|
||||
return res
|
||||
|
||||
def date_to_datetime(self, cr, uid, userdate, context=None):
|
||||
""" Convert date values expressed in user's timezone to
|
||||
server-side UTC timestamp, assuming a default arbitrary
|
||||
time of 12:00 AM - because a time is needed.
|
||||
|
||||
:param str userdate: date string in in user time zone
|
||||
:return: UTC datetime string for server-side use
|
||||
"""
|
||||
# TODO: move to fields.datetime in server after 7.0
|
||||
user_date = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT)
|
||||
if context and context.get('tz'):
|
||||
tz_name = context['tz']
|
||||
else:
|
||||
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
||||
if tz_name:
|
||||
utc = pytz.timezone('UTC')
|
||||
context_tz = pytz.timezone(tz_name)
|
||||
user_datetime = user_date + relativedelta(hours=12.0)
|
||||
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
||||
user_datetime = local_timestamp.astimezone(utc)
|
||||
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return user_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
# if mode == 'finished':
|
||||
# returns True if all lines are done, False otherwise
|
||||
# if mode == 'canceled':
|
||||
|
@ -311,7 +336,7 @@ class sale_order(osv.osv):
|
|||
return {
|
||||
'name': pick_name,
|
||||
'origin': order.name,
|
||||
'date': order.date_order,
|
||||
'date': self.date_to_datetime(cr, uid, order.date_order, context),
|
||||
'type': 'out',
|
||||
'state': 'auto',
|
||||
'move_type': order.picking_policy,
|
||||
|
@ -345,7 +370,8 @@ class sale_order(osv.osv):
|
|||
return True
|
||||
|
||||
def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
|
||||
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
|
||||
start_date = self.date_to_datetime(cr, uid, start_date, context)
|
||||
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=line.delay or 0.0)
|
||||
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return date_planned
|
||||
|
||||
|
@ -605,11 +631,6 @@ class sale_advance_payment_inv(osv.osv_memory):
|
|||
sale_line_obj = self.pool.get('sale.order.line')
|
||||
wizard = self.browse(cr, uid, [result], context)
|
||||
sale = sale_obj.browse(cr, uid, sale_id, context=context)
|
||||
if sale.order_policy == 'postpaid':
|
||||
raise osv.except_osv(
|
||||
_('Error!'),
|
||||
_("You cannot make an advance on a sales order \
|
||||
that is defined as 'Automatic Invoice after delivery'."))
|
||||
|
||||
# If invoice on picking: add the cost on the SO
|
||||
# If not, the advance will be deduced when generating the final invoice
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
order = self.browse(cr, uid, ref("sale.sale_order_6"))
|
||||
for order_line in order.order_line:
|
||||
procurement = order_line.procurement_id
|
||||
date_planned = datetime.strptime(order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=order_line.delay or 0.0)
|
||||
sale_order_date = self.date_to_datetime(cr, uid, order.date_order, context)
|
||||
date_planned = datetime.strptime(sale_order_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
|
||||
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
assert procurement.date_planned == date_planned, "Scheduled date is not correspond."
|
||||
assert procurement.product_id.id == order_line.product_id.id, "Product is not correspond."
|
||||
|
@ -60,7 +61,8 @@
|
|||
output_id = sale_order.shop_id.warehouse_id.lot_output_id.id
|
||||
for move in picking.move_lines:
|
||||
order_line = move.sale_line_id
|
||||
date_planned = datetime.strptime(sale_order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=order_line.delay or 0.0)
|
||||
sale_order_date = self.date_to_datetime(cr, uid, sale_order.date_order, context)
|
||||
date_planned = datetime.strptime(sale_order_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
|
||||
date_planned = (date_planned - timedelta(days=sale_order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
assert datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) == datetime.strptime(date_planned, DEFAULT_SERVER_DATETIME_FORMAT), "Excepted Date is not correspond with Planned Date."
|
||||
assert move.product_id.id == order_line.product_id.id,"Product is not correspond."
|
||||
|
|
|
@ -205,7 +205,7 @@ class share_wizard(osv.TransientModel):
|
|||
raise osv.except_osv(_('No email address configured'),
|
||||
_('You must configure your email address in the user preferences before using the Share button.'))
|
||||
model, res_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'share', 'action_share_wizard_step1')
|
||||
action = self.pool.get(model).read(cr, uid, res_id, context=context)
|
||||
action = self.pool[model].read(cr, uid, res_id, context=context)
|
||||
action['res_id'] = ids[0]
|
||||
action.pop('context', '')
|
||||
return action
|
||||
|
@ -404,7 +404,7 @@ class share_wizard(osv.TransientModel):
|
|||
local_rel_fields = []
|
||||
models = [x[1].model for x in relation_fields]
|
||||
model_obj = self.pool.get('ir.model')
|
||||
model_osv = self.pool.get(model.model)
|
||||
model_osv = self.pool[model.model]
|
||||
for colinfo in model_osv._all_columns.itervalues():
|
||||
coldef = colinfo.column
|
||||
coltype = coldef._type
|
||||
|
@ -412,7 +412,7 @@ class share_wizard(osv.TransientModel):
|
|||
if coltype in ttypes and colinfo.column._obj not in models:
|
||||
relation_model_id = model_obj.search(cr, UID_ROOT, [('model','=',coldef._obj)])[0]
|
||||
relation_model_browse = model_obj.browse(cr, UID_ROOT, relation_model_id, context=context)
|
||||
relation_osv = self.pool.get(coldef._obj)
|
||||
relation_osv = self.pool[coldef._obj]
|
||||
if coltype == 'one2many':
|
||||
# don't record reverse path if it's not a real m2o (that happens, but rarely)
|
||||
dest_model_ci = relation_osv._all_columns
|
||||
|
@ -422,7 +422,7 @@ class share_wizard(osv.TransientModel):
|
|||
local_rel_fields.append((relation_field, relation_model_browse))
|
||||
for parent in relation_osv._inherits:
|
||||
if parent not in models:
|
||||
parent_model = self.pool.get(parent)
|
||||
parent_model = self.pool[parent]
|
||||
parent_colinfos = parent_model._all_columns
|
||||
parent_model_browse = model_obj.browse(cr, UID_ROOT,
|
||||
model_obj.search(cr, UID_ROOT, [('model','=',parent)]))[0]
|
||||
|
@ -458,7 +458,7 @@ class share_wizard(osv.TransientModel):
|
|||
"""
|
||||
# obj0 class and its parents
|
||||
obj0 = [(None, model)]
|
||||
model_obj = self.pool.get(model.model)
|
||||
model_obj = self.pool[model.model]
|
||||
ir_model_obj = self.pool.get('ir.model')
|
||||
for parent in model_obj._inherits:
|
||||
parent_model_browse = ir_model_obj.browse(cr, UID_ROOT,
|
||||
|
@ -777,7 +777,7 @@ class share_wizard(osv.TransientModel):
|
|||
# Record id not found: issue
|
||||
if res_id <= 0:
|
||||
raise osv.except_osv(_('Record id not found'), _('The share engine has not been able to fetch a record_id for your invitation.'))
|
||||
self.pool.get(model.model).message_subscribe(cr, uid, [res_id], new_ids + existing_ids, context=context)
|
||||
self.pool[model.model].message_subscribe(cr, uid, [res_id], new_ids + existing_ids, context=context)
|
||||
# self.send_invite_email(cr, uid, wizard_data, context=context)
|
||||
# self.send_invite_note(cr, uid, model.model, res_id, wizard_data, context=context)
|
||||
|
||||
|
@ -823,7 +823,7 @@ class share_wizard(osv.TransientModel):
|
|||
elif tmp_idx == len(wizard_data.result_line_ids)-2:
|
||||
body += ' and'
|
||||
body += '.'
|
||||
return self.pool.get(model_name).message_post(cr, uid, [res_id], body=body, context=context)
|
||||
return self.pool[model_name].message_post(cr, uid, [res_id], body=body, context=context)
|
||||
|
||||
def send_invite_email(self, cr, uid, wizard_data, context=None):
|
||||
# TDE Note: not updated because will disappear
|
||||
|
|
|
@ -30,6 +30,7 @@ from openerp.report.render import render
|
|||
|
||||
import stock_graph
|
||||
import StringIO
|
||||
import unicodedata
|
||||
|
||||
class external_pdf(render):
|
||||
def __init__(self, pdf):
|
||||
|
@ -107,7 +108,12 @@ class report_stock(report_int):
|
|||
io = StringIO.StringIO()
|
||||
gt = stock_graph.stock_graph(io)
|
||||
for prod_id in products:
|
||||
gt.add(prod_id, names.get(prod_id, 'Unknown'), products[prod_id])
|
||||
prod_name = names.get(prod_id,'Unknown')
|
||||
if isinstance(prod_name, str):
|
||||
prod_name = prod_name.decode('utf-8')
|
||||
prod_name = unicodedata.normalize('NFKD',prod_name)
|
||||
prod_name = prod_name.encode('ascii','replace')
|
||||
gt.add(prod_id, prod_name, products[prod_id])
|
||||
gt.draw()
|
||||
gt.close()
|
||||
self.obj = external_pdf(io.getvalue())
|
||||
|
|
|
@ -193,6 +193,7 @@ CREATE OR REPLACE view report_stock_inventory AS (
|
|||
LEFT JOIN product_uom pu2 ON (m.product_uom=pu2.id)
|
||||
LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
||||
LEFT JOIN stock_location l ON (m.location_id=l.id)
|
||||
WHERE m.state != 'cancel'
|
||||
GROUP BY
|
||||
m.id, m.product_id, m.product_uom, pt.categ_id, m.partner_id, m.location_id, m.location_dest_id,
|
||||
m.prodlot_id, m.date, m.state, l.usage, l.scrap_location, m.company_id, pt.uom_id, to_char(m.date, 'YYYY'), to_char(m.date, 'MM')
|
||||
|
@ -216,6 +217,7 @@ CREATE OR REPLACE view report_stock_inventory AS (
|
|||
LEFT JOIN product_uom pu2 ON (m.product_uom=pu2.id)
|
||||
LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
||||
LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
|
||||
WHERE m.state != 'cancel'
|
||||
GROUP BY
|
||||
m.id, m.product_id, m.product_uom, pt.categ_id, m.partner_id, m.location_id, m.location_dest_id,
|
||||
m.prodlot_id, m.date, m.state, l.usage, l.scrap_location, m.company_id, pt.uom_id, to_char(m.date, 'YYYY'), to_char(m.date, 'MM')
|
||||
|
|
|
@ -2944,6 +2944,12 @@ class stock_picking_in(osv.osv):
|
|||
_table = "stock_picking"
|
||||
_description = "Incoming Shipments"
|
||||
|
||||
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
return self.pool.get('stock.picking').search(cr, user, args, offset, limit, order, context, count)
|
||||
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
return self.pool.get('stock.picking').read(cr, uid, ids, fields=fields, context=context, load=load)
|
||||
|
||||
def check_access_rights(self, cr, uid, operation, raise_exception=True):
|
||||
#override in order to redirect the check of acces rights on the stock.picking object
|
||||
return self.pool.get('stock.picking').check_access_rights(cr, uid, operation, raise_exception=raise_exception)
|
||||
|
@ -2999,6 +3005,12 @@ class stock_picking_out(osv.osv):
|
|||
_table = "stock_picking"
|
||||
_description = "Delivery Orders"
|
||||
|
||||
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
return self.pool.get('stock.picking').search(cr, user, args, offset, limit, order, context, count)
|
||||
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
return self.pool.get('stock.picking').read(cr, uid, ids, fields=fields, context=context, load=load)
|
||||
|
||||
def check_access_rights(self, cr, uid, operation, raise_exception=True):
|
||||
#override in order to redirect the check of acces rights on the stock.picking object
|
||||
return self.pool.get('stock.picking').check_access_rights(cr, uid, operation, raise_exception=raise_exception)
|
||||
|
|
|
@ -39,7 +39,7 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
if not model or 'stock.picking' not in model:
|
||||
return []
|
||||
|
||||
model_pool = self.pool.get(model)
|
||||
model_pool = self.pool[model]
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
res_ids = context and context.get('active_ids', [])
|
||||
vals = []
|
||||
|
@ -119,7 +119,7 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
elif inv_type == "in_refund":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree4")
|
||||
if action_model:
|
||||
action_pool = self.pool.get(action_model)
|
||||
action_pool = self.pool[action_model]
|
||||
action = action_pool.read(cr, uid, action_id, context=context)
|
||||
action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
|
||||
return action
|
||||
|
|
|
@ -115,7 +115,7 @@ class subscription_subscription(osv.osv):
|
|||
try:
|
||||
(model_name, id) = row['doc_source'].split(',')
|
||||
id = int(id)
|
||||
model = self.pool.get(model_name)
|
||||
model = self.pool[model_name]
|
||||
except:
|
||||
raise osv.except_osv(_('Wrong Source Document !'), _('Please provide another source document.\nThis one does not exist !'))
|
||||
|
||||
|
@ -136,7 +136,7 @@ class subscription_subscription(osv.osv):
|
|||
# the subscription is over and we mark it as being done
|
||||
if remaining == 1:
|
||||
state = 'done'
|
||||
id = self.pool.get(model_name).copy(cr, uid, id, default, context)
|
||||
id = self.pool[model_name].copy(cr, uid, id, default, context)
|
||||
self.pool.get('subscription.subscription.history').create(cr, uid, {'subscription_id': row['id'], 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'document_id': model_name+','+str(id)})
|
||||
self.write(cr, uid, [row['id']], {'state':state})
|
||||
return True
|
||||
|
|
|
@ -402,9 +402,10 @@ class survey_question_wiz(osv.osv_memory):
|
|||
sur_response_obj.write(cr, uid, [sur_name_read.response], {'state' : 'done'})
|
||||
|
||||
# mark the survey request as done; call 'survey_req_done' on its actual model
|
||||
survey_req_obj = self.pool.get(context.get('active_model'))
|
||||
if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'):
|
||||
survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context)
|
||||
if context.get('active_model') in self.pool:
|
||||
survey_req_obj = self.pool[context.get('active_model')]
|
||||
if hasattr(survey_req_obj, 'survey_req_done'):
|
||||
survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context)
|
||||
|
||||
if sur_rec.send_response:
|
||||
survey_data = survey_obj.browse(cr, uid, survey_id)
|
||||
|
@ -609,10 +610,10 @@ class survey_question_wiz(osv.osv_memory):
|
|||
survey_obj.write(cr, uid, survey_id, {'tot_start_survey' : sur_rec['tot_start_survey'] + 1})
|
||||
if context.has_key('cur_id'):
|
||||
if context.has_key('request') and context.get('request',False):
|
||||
self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
|
||||
self.pool.get(context.get('object',False)).survey_req_done(cr, uid, [int(context.get('cur_id'))], context)
|
||||
self.pool[context.get('object')].write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
|
||||
self.pool[context.get('object')].survey_req_done(cr, uid, [int(context.get('cur_id'))], context)
|
||||
else:
|
||||
self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
|
||||
self.pool[context.get('object')].write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
|
||||
if sur_name_read['store_ans'] and type(safe_eval(sur_name_read['store_ans'])) == dict:
|
||||
sur_name_read['store_ans'] = safe_eval(sur_name_read['store_ans'])
|
||||
for key,val in sur_name_read['store_ans'].items():
|
||||
|
|
Loading…
Reference in New Issue