[MERGE] forward port of branch 7.0 up to 209ce6f

This commit is contained in:
Christophe Simonis 2015-03-09 11:24:32 +01:00
commit 4a3c4713e9
17 changed files with 101 additions and 48 deletions

View File

@ -182,8 +182,10 @@
<field name="date_due"/>
<field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]"
name="account_id" groups="account.group_account_user"/>
<field name="internal_number" invisible="1"/>
<field name="journal_id" groups="account.group_account_user"
on_change="onchange_journal_id(journal_id, context)" options="{'no_create': True}"/>
on_change="onchange_journal_id(journal_id, context)" options="{'no_create': True}"
attrs="{'readonly':[('internal_number','!=',False)]}"/>
<field name="currency_id" groups="base.group_multi_currency"/>
<field name="check_total" groups="account.group_supplier_inv_check_total"/>
</group>
@ -328,8 +330,10 @@
</group>
<group>
<field name="date_invoice"/>
<field name="internal_number" invisible="1"/>
<field name="journal_id" groups="account.group_account_user"
on_change="onchange_journal_id(journal_id, context)" options="{'no_create': True}"/>
on_change="onchange_journal_id(journal_id, context)" options="{'no_create': True}"
attrs="{'readonly':[('internal_number','!=',False)]}"/>
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]"
name="account_id" groups="account.group_account_user"/>

View File

@ -439,7 +439,7 @@ class account_move_line(osv.osv):
'debit': fields.float('Debit', 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),
'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'),
'ref': fields.related('move_id', 'ref', string='Reference', type='char', size=64, store=True),
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),

View File

@ -315,6 +315,7 @@ class res_partner(osv.osv):
('reconcile_id', '=', False),
('state', '!=', 'draft'),
('company_id', '=', company_id),
('date_maturity', '<=', fields.date.context_today(self,cr,uid)),
], 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."))
self.message_post(cr, uid, [ids[0]], body=_('Printed overdue payments report'), context=context)

View File

@ -21,6 +21,7 @@
import time
from collections import defaultdict
from openerp.osv import fields
from openerp.report import report_sxw
@ -54,6 +55,7 @@ class report_rappel(report_sxw.rml_parse):
('reconcile_id', '=', False),
('state', '!=', 'draft'),
('company_id', '=', company_id),
('date_maturity', '<=', fields.date.context_today(self,self.cr,self.uid)),
])
# lines_per_currency = {currency: [line data, ...], ...}

View File

@ -29,7 +29,7 @@
<field name="type" invisible="context.get('default_type', False)"/>
<field name="template_id" on_change="on_change_template(template_id,context)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
<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','&lt;&gt;','view')]}"/>
</group>
</group>

View File

@ -23,7 +23,7 @@
from operator import itemgetter
from textwrap import dedent
from openerp import tools
from openerp import tools, SUPERUSER_ID
from openerp.osv import fields, osv
class board_board(osv.osv):
@ -144,7 +144,7 @@ class board_create(osv.osv_memory):
''')
}, 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,
'parent_id': this.menu_parent_id.id,
'action': 'ir.actions.act_window,%s' % (action_id,)

View File

@ -328,6 +328,7 @@ class crm_lead(format_address, osv.osv):
partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
values = {
'partner_name': partner.name,
'title': partner.title and partner.title.id or False,
'street': partner.street,
'street2': partner.street2,
'city': partner.city,
@ -338,6 +339,7 @@ class crm_lead(format_address, osv.osv):
'mobile': partner.mobile,
'fax': partner.fax,
'zip': partner.zip,
'function': partner.function,
}
return {'value': values}

View File

@ -528,12 +528,13 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
MAX(id) as id,
name,
sheet_id,
timezone,
SUM(total_timesheet) as total_timesheet,
CASE WHEN SUM(total_attendance) < 0
CASE WHEN SUM(orphan_attendances) != 0
THEN (SUM(total_attendance) +
CASE WHEN current_date <> name
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
)
ELSE SUM(total_attendance)
@ -542,21 +543,25 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
((
select
min(hrt.id) as id,
'UTC' as timezone,
l.date::date as name,
s.id as sheet_id,
sum(l.unit_amount) as total_timesheet,
0 as orphan_attendances,
0.0 as total_attendance
from
hr_analytic_timesheet hrt
JOIN account_analytic_line l ON l.id = hrt.line_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 (
select
-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,
s.id as sheet_id,
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
from
hr_attendance a
@ -571,9 +576,9 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
LEFT JOIN res_partner p
ON u.partner_id = p.id
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
GROUP BY name, sheet_id
GROUP BY name, sheet_id, timezone
)) AS bar""")

View File

@ -28,6 +28,35 @@
<field name="name">Volume</field>
</record>
<!--
Precisions
-->
<record forcecreate="True" id="decimal_price" model="decimal.precision">
<field name="name">Product Price</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_discount" model="decimal.precision">
<field name="name">Discount</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_account" model="decimal.precision">
<field name="name">Account</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_stock_weight" model="decimal.precision">
<field name="name">Stock Weight</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_product_uom" model="decimal.precision">
<field name="name">Product Unit of Measure</field>
<field name="digits" eval="3"/>
</record>
<record forcecreate="True" id="decimal_product_uos" model="decimal.precision">
<field name="name">Product UoS</field>
<field name="digits" eval="3"/>
</record>
<!--
Resource: product.uom
-->
@ -163,30 +192,6 @@ parameter) will see those record just disappear.
<field eval="'product.pricelist,'+str(ref('list0'))" name="value"/>
</record>
<record forcecreate="True" id="decimal_price" model="decimal.precision">
<field name="name">Product Price</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_discount" model="decimal.precision">
<field name="name">Discount</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_account" model="decimal.precision">
<field name="name">Account</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_stock_weight" model="decimal.precision">
<field name="name">Stock Weight</field>
<field name="digits">2</field>
</record>
<record forcecreate="True" id="decimal_product_uom" model="decimal.precision">
<field name="name">Product Unit of Measure</field>
<field name="digits" eval="3"/>
</record>
<record forcecreate="True" id="decimal_product_uos" model="decimal.precision">
<field name="name">Product UoS</field>
<field name="digits" eval="3"/>
</record>
<!--
Product

View File

@ -316,7 +316,7 @@ class project(osv.osv):
return True
_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):
@ -872,7 +872,7 @@ class task(osv.osv):
_constraints = [
(_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

View File

@ -148,6 +148,19 @@ class purchase_order(osv.osv):
limit=1)
return res and res[0] or False
def _has_non_stockable_item(self, cr, uid, ids, *args):
res = dict.fromkeys(ids, False)
for order in self.browse(cr, uid, ids):
for order_line in order.order_line:
if (
not order_line.product_id
or
order_line.product_id
and order_line.product_id.type not in ('product', 'consu')
):
res[order.id] = True
return res
STATE_SELECTION = [
('draft', 'Draft PO'),
('sent', 'RFQ Sent'),
@ -224,6 +237,7 @@ class purchase_order(osv.osv):
'create_uid': fields.many2one('res.users', 'Responsible'),
'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal'),
'has_non_stockable_item': fields.function(_has_non_stockable_item, method=True, type='boolean', string='Contains a non-stockable item'),
}
_defaults = {
'date_order': fields.date.context_today,
@ -408,6 +422,7 @@ class purchase_order(osv.osv):
})
return action
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)})
return True
@ -473,6 +488,10 @@ class purchase_order(osv.osv):
for po in self.browse(cr, uid, ids, context=context):
if not po.order_line:
raise osv.except_osv(_('Error!'),_('You cannot confirm a purchase order without any purchase order line.'))
if po.invoice_method == 'picking' and po.has_non_stockable_item is True:
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:
if line.state=='draft':
todo.append(line.id)

View File

@ -605,6 +605,14 @@ class sale_order_line(osv.osv):
res['value'].update({'product_packaging': False})
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
product_obj = product_obj.browse(cr, uid, product, context=context)
res['value']['delay'] = (product_obj.sale_delay or 0.0)

View File

@ -1583,7 +1583,7 @@ class Export(http.Controller):
fields['.id'] = fields.pop('id', {'string': 'ID'})
fields_sequence = sorted(fields.iteritems(),
key=lambda field: field[1].get('string', ''))
key=lambda field: openerp.tools.ustr(field[1].get('string', '')))
records = []
for field_name, field in fields_sequence:

View File

@ -255,7 +255,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.dataset.ids.push(state.id);
}
this.dataset.select_id(state.id);
this.do_show({ reload: warm });
this.do_show();
}
},
/**
@ -2660,6 +2660,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
this.$textarea = this.$el.find('textarea');
this.auto_sized = false;
this.default_height = this.$textarea.css('height');
if (this.default_height === '0px') this.default_height = '90px';
if (this.get("effective_readonly")) {
this.$textarea.attr('disabled', 'disabled');
}

View File

@ -299,21 +299,24 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
this.$pager
.on('click', 'a[data-pager-action]', function () {
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')) {
case 'first':
self.page = 0; break;
self.page = 0;
break;
case 'last':
self.page = max_page - 1;
self.page = max_page_index;
break;
case 'next':
self.page += 1; break;
self.page += 1;
break;
case 'previous':
self.page -= 1; break;
self.page -= 1;
break;
}
if (self.page < 0) {
self.page = max_page;
} else if (self.page > max_page) {
self.page = max_page_index;
} else if (self.page > max_page_index) {
self.page = 0;
}
self.reload_content();

View File

@ -109,7 +109,9 @@ class ir_attachment(osv.osv):
return fname
def _file_delete(self, cr, uid, location, fname):
count = self.search(cr, 1, [('store_fname','=',fname)], count=True)
# 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]
if count <= 1:
full_path = self._full_path(cr, uid, location, fname)
try:

View File

@ -118,12 +118,13 @@ class ir_filters(osv.osv):
]
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)
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_filters_name_model_uid_unique_index'")
if not cr.fetchone():
cr.execute("""CREATE UNIQUE INDEX "ir_filters_name_model_uid_unique_index" ON ir_filters
(lower(name), model_id, COALESCE(user_id,-1))""")
return result
_columns = {
'name': fields.char('Filter Name', size=64, translate=True, required=True),