[MERGE] forward port of branch 7.0 up to da15c9d

This commit is contained in:
Denis Ledoux 2014-11-14 15:59:33 +01:00
commit 7ab413724a
9 changed files with 33 additions and 9 deletions

View File

@ -1157,6 +1157,19 @@ class account_move(osv.osv):
_description = "Account Entry" _description = "Account Entry"
_order = 'id desc' _order = 'id desc'
def account_assert_balanced(self, cr, uid, context=None):
cr.execute("""\
SELECT move_id
FROM account_move_line
WHERE state = 'valid'
GROUP BY move_id
HAVING abs(sum(debit) - sum(credit)) > 0.00001
""")
assert len(cr.fetchall()) == 0, \
"For all Journal Items, the state is valid implies that the sum " \
"of credits equals the sum of debits"
return True
def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_id=False, context=None): def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_id=False, context=None):
''' '''
Prepares and returns a dictionary of values, ready to be passed to create() based on the parameters received. Prepares and returns a dictionary of values, ready to be passed to create() based on the parameters received.

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<openerp> <openerp>
<data> <data>
<assert model="account.move" search="[]" string="For all Journal Items, the state is valid implies that the sum of credits equals the sum of debits"> <function name="account_assert_balanced" model="account.move"/>
<test expr="not len(line_id) or line_id[0].state != 'valid' or (sum([l.debit - l.credit for l in line_id]) &lt;= 0.00001)"/>
</assert>
</data> </data>
</openerp> </openerp>

View File

@ -25,5 +25,11 @@
<field name="global" eval="True" /> <field name="global" eval="True" />
<field name="domain_force">[('warehouse_id.company_id','child_of',[user.company_id.id])]</field> <field name="domain_force">[('warehouse_id.company_id','child_of',[user.company_id.id])]</field>
</record> </record>
<record id="rule_pos_order_report_multi_company" model="ir.rule">
<field name="name">Point Of Sale Order Analysis multi-company</field>
<field name="model_id" ref="model_report_pos_order"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
</data> </data>
</openerp> </openerp>

View File

@ -671,7 +671,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
get_all_prices: function(){ get_all_prices: function(){
var self = this; var self = this;
var currency_rounding = this.pos.currency.rounding; var currency_rounding = this.pos.currency.rounding;
var base = round_pr(this.get_quantity() * this.get_unit_price() * (1.0 - (this.get_discount() / 100.0)), currency_rounding); var base = round_pr(round_pr(this.get_quantity() * this.get_unit_price(), currency_rounding) * (1.0 - (this.get_discount() / 100.0)), currency_rounding);
var totalTax = base; var totalTax = base;
var totalNoTax = base; var totalNoTax = base;

View File

@ -790,7 +790,7 @@ class product_product(osv.osv):
if not limit or len(ids) < limit: if not limit or len(ids) < limit:
# we may underrun the limit because of dupes in the results, that's fine # we may underrun the limit because of dupes in the results, that's fine
limit2 = (limit - len(ids)) if limit else False limit2 = (limit - len(ids)) if limit else False
ids.update(self.search(cr, user, args + [('name', operator, name)], limit=limit2, context=context)) ids.update(self.search(cr, user, args + [('name', operator, name), ('id', 'not in', list(ids))], limit=limit2, context=context))
ids = list(ids) ids = list(ids)
elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS: elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS:
ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context) ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context)

View File

@ -474,7 +474,7 @@ class purchase_order(osv.osv):
if not acc_id: if not acc_id:
acc_id = po_line.product_id.categ_id.property_account_expense_categ.id acc_id = po_line.product_id.categ_id.property_account_expense_categ.id
if not acc_id: if not acc_id:
raise osv.except_osv(_('Error!'), _('Define expense account for this company: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,)) raise osv.except_osv(_('Error!'), _('Define expense account for this product: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,))
else: else:
acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context=context).id acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context=context).id
fpos = po_line.order_id.fiscal_position or False fpos = po_line.order_id.fiscal_position or False

View File

@ -2340,6 +2340,9 @@ class stock_move(osv.osv):
context = {} context = {}
src_company_ctx = dict(context,force_company=move.location_id.company_id.id) src_company_ctx = dict(context,force_company=move.location_id.company_id.id)
dest_company_ctx = dict(context,force_company=move.location_dest_id.company_id.id) dest_company_ctx = dict(context,force_company=move.location_dest_id.company_id.id)
# do not take the company of the one of the user
# used to select the correct period
company_ctx = dict(context, company_id=move.company_id.id)
account_moves = [] account_moves = []
# Outgoing moves (or cross-company output part) # Outgoing moves (or cross-company output part)
if move.location_id.company_id \ if move.location_id.company_id \
@ -2371,7 +2374,8 @@ class stock_move(osv.osv):
{ {
'journal_id': j_id, 'journal_id': j_id,
'line_id': move_lines, 'line_id': move_lines,
'ref': move.picking_id and move.picking_id.name}, context=context) 'company_id': move.company_id.id,
'ref': move.picking_id and move.picking_id.name}, context=company_ctx)
def action_done(self, cr, uid, ids, context=None): def action_done(self, cr, uid, ids, context=None):
""" Makes the move done and if all moves are done, it will finish the picking. """ Makes the move done and if all moves are done, it will finish the picking.

View File

@ -1521,7 +1521,11 @@ instance.web.search.DateField = instance.web.search.Field.extend(/** @lends inst
return instance.web.date_to_str(facetValue.get('value')); return instance.web.date_to_str(facetValue.get('value'));
}, },
complete: function (needle) { complete: function (needle) {
var d = Date.parse(needle); try {
var d = instance.web.str_to_date(instance.web.parse_value(needle, {'widget': 'date'}));
} catch (e) {
return false;
}
if (!d) { return $.when(null); } if (!d) { return $.when(null); }
var date_string = instance.web.format_value(d, this.attrs); var date_string = instance.web.format_value(d, this.attrs);
var label = _.str.sprintf(_.str.escapeHTML( var label = _.str.sprintf(_.str.escapeHTML(

View File

@ -4109,7 +4109,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
if (!this.fields_view || !this.editable()){ if (!this.fields_view || !this.editable()){
return true; return true;
} }
this.o2m._dirty_flag = true;
var r; var r;
return _.every(this.records.records, function(record){ return _.every(this.records.records, function(record){
r = record; r = record;