[MERGE] forward port of branch saas-3 up to 4a3c471
This commit is contained in:
commit
416f0246ac
|
@ -182,8 +182,10 @@
|
||||||
<field name="date_due"/>
|
<field name="date_due"/>
|
||||||
<field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]"
|
<field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]"
|
||||||
name="account_id" groups="account.group_account_user"/>
|
name="account_id" groups="account.group_account_user"/>
|
||||||
|
<field name="internal_number" invisible="1"/>
|
||||||
<field name="journal_id" groups="account.group_account_user"
|
<field name="journal_id" groups="account.group_account_user"
|
||||||
on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"/>
|
on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"
|
||||||
|
attrs="{'readonly':[('internal_number','!=',False)]}"/>
|
||||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||||
<field name="check_total" groups="account.group_supplier_inv_check_total"/>
|
<field name="check_total" groups="account.group_supplier_inv_check_total"/>
|
||||||
</group>
|
</group>
|
||||||
|
@ -328,8 +330,10 @@
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="date_invoice" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)" />
|
<field name="date_invoice" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)" />
|
||||||
|
<field name="internal_number" invisible="1"/>
|
||||||
<field name="journal_id" groups="account.group_account_user"
|
<field name="journal_id" groups="account.group_account_user"
|
||||||
on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"/>
|
on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"
|
||||||
|
attrs="{'readonly':[('internal_number','!=',False)]}"/>
|
||||||
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]"
|
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]"
|
||||||
name="account_id" groups="account.group_account_user"/>
|
name="account_id" groups="account.group_account_user"/>
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@ class account_move_line(osv.osv):
|
||||||
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
||||||
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
||||||
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
|
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
|
||||||
'move_id': fields.many2one('account.move', 'Journal Entry', ondelete="cascade", help="The move of this entry line.", select=2, required=True),
|
'move_id': fields.many2one('account.move', 'Journal Entry', ondelete="cascade", help="The move of this entry line.", select=2, required=True, auto_join=True),
|
||||||
'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Internal Note'),
|
'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Internal Note'),
|
||||||
'ref': fields.related('move_id', 'ref', string='Reference', type='char', store=True),
|
'ref': fields.related('move_id', 'ref', string='Reference', type='char', store=True),
|
||||||
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1, copy=False),
|
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1, copy=False),
|
||||||
|
|
|
@ -309,6 +309,7 @@ class res_partner(osv.osv):
|
||||||
('reconcile_id', '=', False),
|
('reconcile_id', '=', False),
|
||||||
('state', '!=', 'draft'),
|
('state', '!=', 'draft'),
|
||||||
('company_id', '=', company_id),
|
('company_id', '=', company_id),
|
||||||
|
('date_maturity', '<=', fields.date.context_today(self,cr,uid)),
|
||||||
], context=context):
|
], context=context):
|
||||||
raise osv.except_osv(_('Error!'),_("The partner does not have any accounting entries to print in the overdue report for the current company."))
|
raise osv.except_osv(_('Error!'),_("The partner does not have any accounting entries to print in the overdue report for the current company."))
|
||||||
self.message_post(cr, uid, [ids[0]], body=_('Printed overdue payments report'), context=context)
|
self.message_post(cr, uid, [ids[0]], body=_('Printed overdue payments report'), context=context)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from openerp.osv import osv
|
from openerp.osv import osv, fields
|
||||||
from openerp.report import report_sxw
|
from openerp.report import report_sxw
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class report_rappel(report_sxw.rml_parse):
|
||||||
('reconcile_id', '=', False),
|
('reconcile_id', '=', False),
|
||||||
('state', '!=', 'draft'),
|
('state', '!=', 'draft'),
|
||||||
('company_id', '=', company_id),
|
('company_id', '=', company_id),
|
||||||
|
('date_maturity', '<=', fields.date.context_today(self,self.cr,self.uid)),
|
||||||
])
|
])
|
||||||
|
|
||||||
# lines_per_currency = {currency: [line data, ...], ...}
|
# lines_per_currency = {currency: [line data, ...], ...}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<field name="type" invisible="context.get('default_type', False)"/>
|
<field name="type" invisible="context.get('default_type', False)"/>
|
||||||
<field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
|
<field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/>
|
<field name="parent_id" on_change="on_change_parent(parent_id)" />
|
||||||
<field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/>
|
<field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from openerp import tools
|
from openerp import tools, SUPERUSER_ID
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import fields, osv
|
||||||
|
|
||||||
class board_board(osv.osv):
|
class board_board(osv.osv):
|
||||||
|
@ -143,7 +143,7 @@ class board_create(osv.osv_memory):
|
||||||
''')
|
''')
|
||||||
}, context=context)
|
}, context=context)
|
||||||
|
|
||||||
menu_id = self.pool.get('ir.ui.menu').create(cr, uid, {
|
menu_id = self.pool.get('ir.ui.menu').create(cr, SUPERUSER_ID, {
|
||||||
'name': this.name,
|
'name': this.name,
|
||||||
'parent_id': this.menu_parent_id.id,
|
'parent_id': this.menu_parent_id.id,
|
||||||
'action': 'ir.actions.act_window,%s' % (action_id,)
|
'action': 'ir.actions.act_window,%s' % (action_id,)
|
||||||
|
|
|
@ -313,6 +313,7 @@ class crm_lead(format_address, osv.osv):
|
||||||
values = {
|
values = {
|
||||||
'partner_name': partner.parent_id.name if partner.parent_id else partner.name,
|
'partner_name': partner.parent_id.name if partner.parent_id else partner.name,
|
||||||
'contact_name': partner.name if partner.parent_id else False,
|
'contact_name': partner.name if partner.parent_id else False,
|
||||||
|
'title': partner.title and partner.title.id or False,
|
||||||
'street': partner.street,
|
'street': partner.street,
|
||||||
'street2': partner.street2,
|
'street2': partner.street2,
|
||||||
'city': partner.city,
|
'city': partner.city,
|
||||||
|
@ -323,6 +324,7 @@ class crm_lead(format_address, osv.osv):
|
||||||
'mobile': partner.mobile,
|
'mobile': partner.mobile,
|
||||||
'fax': partner.fax,
|
'fax': partner.fax,
|
||||||
'zip': partner.zip,
|
'zip': partner.zip,
|
||||||
|
'function': partner.function,
|
||||||
}
|
}
|
||||||
return {'value': values}
|
return {'value': values}
|
||||||
|
|
||||||
|
|
|
@ -559,12 +559,13 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
|
||||||
MAX(id) as id,
|
MAX(id) as id,
|
||||||
name,
|
name,
|
||||||
sheet_id,
|
sheet_id,
|
||||||
|
timezone,
|
||||||
SUM(total_timesheet) as total_timesheet,
|
SUM(total_timesheet) as total_timesheet,
|
||||||
CASE WHEN SUM(total_attendance) < 0
|
CASE WHEN SUM(orphan_attendances) != 0
|
||||||
THEN (SUM(total_attendance) +
|
THEN (SUM(total_attendance) +
|
||||||
CASE WHEN current_date <> name
|
CASE WHEN current_date <> name
|
||||||
THEN 1440
|
THEN 1440
|
||||||
ELSE (EXTRACT(hour FROM current_time AT TIME ZONE 'UTC') * 60) + EXTRACT(minute FROM current_time AT TIME ZONE 'UTC')
|
ELSE (EXTRACT(hour FROM current_time AT TIME ZONE 'UTC' AT TIME ZONE coalesce(timezone, 'UTC')) * 60) + EXTRACT(minute FROM current_time AT TIME ZONE 'UTC' AT TIME ZONE coalesce(timezone, 'UTC'))
|
||||||
END
|
END
|
||||||
)
|
)
|
||||||
ELSE SUM(total_attendance)
|
ELSE SUM(total_attendance)
|
||||||
|
@ -573,21 +574,25 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
|
||||||
((
|
((
|
||||||
select
|
select
|
||||||
min(hrt.id) as id,
|
min(hrt.id) as id,
|
||||||
|
'UTC' as timezone,
|
||||||
l.date::date as name,
|
l.date::date as name,
|
||||||
s.id as sheet_id,
|
s.id as sheet_id,
|
||||||
sum(l.unit_amount) as total_timesheet,
|
sum(l.unit_amount) as total_timesheet,
|
||||||
|
0 as orphan_attendances,
|
||||||
0.0 as total_attendance
|
0.0 as total_attendance
|
||||||
from
|
from
|
||||||
hr_analytic_timesheet hrt
|
hr_analytic_timesheet hrt
|
||||||
JOIN account_analytic_line l ON l.id = hrt.line_id
|
JOIN account_analytic_line l ON l.id = hrt.line_id
|
||||||
LEFT JOIN hr_timesheet_sheet_sheet s ON s.id = hrt.sheet_id
|
LEFT JOIN hr_timesheet_sheet_sheet s ON s.id = hrt.sheet_id
|
||||||
group by l.date::date, s.id
|
group by l.date::date, s.id, timezone
|
||||||
) union (
|
) union (
|
||||||
select
|
select
|
||||||
-min(a.id) as id,
|
-min(a.id) as id,
|
||||||
|
p.tz as timezone,
|
||||||
(a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))::date as name,
|
(a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))::date as name,
|
||||||
s.id as sheet_id,
|
s.id as sheet_id,
|
||||||
0.0 as total_timesheet,
|
0.0 as total_timesheet,
|
||||||
|
SUM(CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END) as orphan_attendances,
|
||||||
SUM(((EXTRACT(hour FROM (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))) * 60) + EXTRACT(minute FROM (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC')))) * (CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END)) as total_attendance
|
SUM(((EXTRACT(hour FROM (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))) * 60) + EXTRACT(minute FROM (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC')))) * (CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END)) as total_attendance
|
||||||
from
|
from
|
||||||
hr_attendance a
|
hr_attendance a
|
||||||
|
@ -602,9 +607,9 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
|
||||||
LEFT JOIN res_partner p
|
LEFT JOIN res_partner p
|
||||||
ON u.partner_id = p.id
|
ON u.partner_id = p.id
|
||||||
WHERE action in ('sign_in', 'sign_out')
|
WHERE action in ('sign_in', 'sign_out')
|
||||||
group by (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))::date, s.id
|
group by (a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))::date, s.id, timezone
|
||||||
)) AS foo
|
)) AS foo
|
||||||
GROUP BY name, sheet_id
|
GROUP BY name, sheet_id, timezone
|
||||||
)) AS bar""")
|
)) AS bar""")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ class project(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date'])
|
(_check_dates, 'Error! project start-date must be lower than project end-date.', ['date_start', 'date'])
|
||||||
]
|
]
|
||||||
|
|
||||||
def set_template(self, cr, uid, ids, context=None):
|
def set_template(self, cr, uid, ids, context=None):
|
||||||
|
@ -836,7 +836,7 @@ class task(osv.osv):
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids']),
|
(_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids']),
|
||||||
(_check_dates, 'Error ! Task end-date must be greater then task start-date', ['date_start','date_end'])
|
(_check_dates, 'Error ! Task end-date must be greater than task start-date', ['date_start','date_end'])
|
||||||
]
|
]
|
||||||
|
|
||||||
# Override view according to the company definition
|
# Override view according to the company definition
|
||||||
|
|
|
@ -146,6 +146,19 @@ class purchase_order(osv.osv):
|
||||||
limit=1)
|
limit=1)
|
||||||
return res and res[0] or False
|
return res and res[0] or False
|
||||||
|
|
||||||
|
def _has_non_stockable_item(self, cr, uid, ids, *args):
|
||||||
|
res = dict.fromkeys(ids, False)
|
||||||
|
for order in self.browse(cr, uid, ids):
|
||||||
|
for order_line in order.order_line:
|
||||||
|
if (
|
||||||
|
not order_line.product_id
|
||||||
|
or
|
||||||
|
order_line.product_id
|
||||||
|
and order_line.product_id.type not in ('product', 'consu')
|
||||||
|
):
|
||||||
|
res[order.id] = True
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_picking_in(self, cr, uid, context=None):
|
def _get_picking_in(self, cr, uid, context=None):
|
||||||
obj_data = self.pool.get('ir.model.data')
|
obj_data = self.pool.get('ir.model.data')
|
||||||
type_obj = self.pool.get('stock.picking.type')
|
type_obj = self.pool.get('stock.picking.type')
|
||||||
|
@ -295,6 +308,7 @@ class purchase_order(osv.osv):
|
||||||
'create_uid': fields.many2one('res.users', 'Responsible'),
|
'create_uid': fields.many2one('res.users', 'Responsible'),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, states={'confirmed': [('readonly', True)], 'approved': [('readonly', True)]}),
|
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, states={'confirmed': [('readonly', True)], 'approved': [('readonly', True)]}),
|
||||||
'journal_id': fields.many2one('account.journal', 'Journal'),
|
'journal_id': fields.many2one('account.journal', 'Journal'),
|
||||||
|
'has_non_stockable_item': fields.function(_has_non_stockable_item, method=True, type='boolean', string='Contains a non-stockable item'),
|
||||||
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
|
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
|
||||||
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
|
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
|
||||||
'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming shipment", required=True,
|
'picking_type_id': fields.many2one('stock.picking.type', 'Deliver To', help="This will determine picking type of incoming shipment", required=True,
|
||||||
|
@ -484,6 +498,7 @@ class purchase_order(osv.osv):
|
||||||
action['res_id'] = pick_ids and pick_ids[0] or False
|
action['res_id'] = pick_ids and pick_ids[0] or False
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
def wkf_approve_order(self, cr, uid, ids, context=None):
|
def wkf_approve_order(self, cr, uid, ids, context=None):
|
||||||
self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)})
|
self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)})
|
||||||
return True
|
return True
|
||||||
|
@ -542,6 +557,10 @@ class purchase_order(osv.osv):
|
||||||
for po in self.browse(cr, uid, ids, context=context):
|
for po in self.browse(cr, uid, ids, context=context):
|
||||||
if not po.order_line:
|
if not po.order_line:
|
||||||
raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase order line.'))
|
raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase order line.'))
|
||||||
|
if po.invoice_method == 'picking' and po.has_non_stockable_item is True:
|
||||||
|
raise osv.except_osv(
|
||||||
|
_('Error!'),
|
||||||
|
_("You cannot confirm a purchase order with Invoice Control Method 'Based on incoming shipments' that contains non-stockable items."))
|
||||||
for line in po.order_line:
|
for line in po.order_line:
|
||||||
if line.state=='draft':
|
if line.state=='draft':
|
||||||
todo.append(line.id)
|
todo.append(line.id)
|
||||||
|
|
|
@ -299,6 +299,14 @@ class sale_order_line(osv.osv):
|
||||||
res['value'].update({'product_packaging': False})
|
res['value'].update({'product_packaging': False})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# set product uom in context to get virtual stock in current uom
|
||||||
|
if res.get('value', {}).get('product_uom'):
|
||||||
|
# use the uom changed by super call
|
||||||
|
context.update({'uom': res['value']['product_uom']})
|
||||||
|
elif uom:
|
||||||
|
# fallback on selected
|
||||||
|
context.update({'uom': uom})
|
||||||
|
|
||||||
#update of result obtained in super function
|
#update of result obtained in super function
|
||||||
product_obj = product_obj.browse(cr, uid, product, context=context)
|
product_obj = product_obj.browse(cr, uid, product, context=context)
|
||||||
res['value'].update({'product_tmpl_id': product_obj.product_tmpl_id.id, 'delay': (product_obj.sale_delay or 0.0)})
|
res['value'].update({'product_tmpl_id': product_obj.product_tmpl_id.id, 'delay': (product_obj.sale_delay or 0.0)})
|
||||||
|
|
|
@ -2842,6 +2842,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
||||||
this.$textarea = this.$el.find('textarea');
|
this.$textarea = this.$el.find('textarea');
|
||||||
this.auto_sized = false;
|
this.auto_sized = false;
|
||||||
this.default_height = this.$textarea.css('height');
|
this.default_height = this.$textarea.css('height');
|
||||||
|
if (this.default_height === '0px') this.default_height = '90px';
|
||||||
if (this.get("effective_readonly")) {
|
if (this.get("effective_readonly")) {
|
||||||
this.$textarea.attr('disabled', 'disabled');
|
this.$textarea.attr('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,21 +299,24 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
this.$pager
|
this.$pager
|
||||||
.on('click', 'a[data-pager-action]', function () {
|
.on('click', 'a[data-pager-action]', function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var max_page = Math.floor(self.dataset.size() / self.limit());
|
var max_page_index = Math.ceil(self.dataset.size() / self.limit()) - 1;
|
||||||
switch ($this.data('pager-action')) {
|
switch ($this.data('pager-action')) {
|
||||||
case 'first':
|
case 'first':
|
||||||
self.page = 0; break;
|
self.page = 0;
|
||||||
|
break;
|
||||||
case 'last':
|
case 'last':
|
||||||
self.page = max_page - 1;
|
self.page = max_page_index;
|
||||||
break;
|
break;
|
||||||
case 'next':
|
case 'next':
|
||||||
self.page += 1; break;
|
self.page += 1;
|
||||||
|
break;
|
||||||
case 'previous':
|
case 'previous':
|
||||||
self.page -= 1; break;
|
self.page -= 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (self.page < 0) {
|
if (self.page < 0) {
|
||||||
self.page = max_page;
|
self.page = max_page_index;
|
||||||
} else if (self.page > max_page) {
|
} else if (self.page > max_page_index) {
|
||||||
self.page = 0;
|
self.page = 0;
|
||||||
}
|
}
|
||||||
self.reload_content();
|
self.reload_content();
|
||||||
|
|
|
@ -140,7 +140,9 @@ class ir_attachment(osv.osv):
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
def _file_delete(self, cr, uid, fname):
|
def _file_delete(self, cr, uid, fname):
|
||||||
count = self.search_count(cr, 1, [('store_fname','=',fname)])
|
# using SQL to include files hidden through unlink or due to record rules
|
||||||
|
cr.execute("SELECT COUNT(*) FROM ir_attachment WHERE store_fname = %s", (fname,))
|
||||||
|
count = cr.fetchone()[0]
|
||||||
full_path = self._full_path(cr, uid, fname)
|
full_path = self._full_path(cr, uid, fname)
|
||||||
if not count and os.path.exists(full_path):
|
if not count and os.path.exists(full_path):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -140,13 +140,14 @@ class ir_filters(osv.osv):
|
||||||
]
|
]
|
||||||
|
|
||||||
def _auto_init(self, cr, context=None):
|
def _auto_init(self, cr, context=None):
|
||||||
super(ir_filters, self)._auto_init(cr, context)
|
result = super(ir_filters, self)._auto_init(cr, context)
|
||||||
# Use unique index to implement unique constraint on the lowercase name (not possible using a constraint)
|
# Use unique index to implement unique constraint on the lowercase name (not possible using a constraint)
|
||||||
cr.execute("DROP INDEX IF EXISTS ir_filters_name_model_uid_unique_index") # drop old index w/o action
|
cr.execute("DROP INDEX IF EXISTS ir_filters_name_model_uid_unique_index") # drop old index w/o action
|
||||||
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_filters_name_model_uid_unique_action_index'")
|
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_filters_name_model_uid_unique_action_index'")
|
||||||
if not cr.fetchone():
|
if not cr.fetchone():
|
||||||
cr.execute("""CREATE UNIQUE INDEX "ir_filters_name_model_uid_unique_action_index" ON ir_filters
|
cr.execute("""CREATE UNIQUE INDEX "ir_filters_name_model_uid_unique_action_index" ON ir_filters
|
||||||
(lower(name), model_id, COALESCE(user_id,-1), COALESCE(action_id,-1))""")
|
(lower(name), model_id, COALESCE(user_id,-1), COALESCE(action_id,-1))""")
|
||||||
|
return result
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Filter Name', translate=True, required=True),
|
'name': fields.char('Filter Name', translate=True, required=True),
|
||||||
|
|
Loading…
Reference in New Issue