[MERGE] forward port of branch 8.0 up to c41109f
authorJeremy Kersten <jke@odoo.com>
Tue, 18 Nov 2014 15:57:06 +0000 (16:57 +0100)
committerJeremy Kersten <jke@odoo.com>
Tue, 18 Nov 2014 15:57:06 +0000 (16:57 +0100)
addons/account_budget/account_budget.py
addons/account_payment/account_payment_view.xml
addons/account_payment/wizard/account_payment_populate_statement.py
addons/point_of_sale/static/src/js/models.js
addons/point_of_sale/static/src/js/screens.js
addons/website/views/website_templates.xml
addons/website_forum/controllers/main.py
addons/website_forum/static/src/js/website_forum.js
addons/website_sale/models/product.py
doc/reference/qweb.rst

index d2b8a10..1985234 100644 (file)
 #
 ##############################################################################
 
-import datetime
+from datetime import date, datetime
 
 from openerp.osv import fields, osv
-from openerp.tools import ustr
+from openerp.tools import ustr, DEFAULT_SERVER_DATE_FORMAT
 from openerp.tools.translate import _
 
 import openerp.addons.decimal_precision as dp
 
+
+# ---------------------------------------------------------
+# Utils
+# ---------------------------------------------------------
 def strToDate(dt):
-        dt_date=datetime.date(int(dt[0:4]),int(dt[5:7]),int(dt[8:10]))
-        return dt_date
+    return date(int(dt[0:4]), int(dt[5:7]), int(dt[8:10]))
+
+def strToDatetime(strdate):
+    return datetime.strptime(strdate, DEFAULT_SERVER_DATE_FORMAT)
 
 # ---------------------------------------------------------
 # Budgets
@@ -135,17 +141,12 @@ class crossovered_budget_lines(osv.osv):
         return res
 
     def _theo_amt(self, cr, uid, ids, context=None):
-        res = {}
-        if context is None: 
+        if context is None:
             context = {}
+
+        res = {}
         for line in self.browse(cr, uid, ids, context=context):
-            today = datetime.datetime.today()
-            date_to = today.strftime("%Y-%m-%d")
-            date_from = line.date_from
-            if context.has_key('wizard_date_from'):
-                date_from = context['wizard_date_from']
-            if context.has_key('wizard_date_to'):
-                date_to = context['wizard_date_to']
+            today = datetime.now()
 
             if line.paid_date:
                 if strToDate(line.date_to) <= strToDate(line.paid_date):
@@ -153,13 +154,15 @@ class crossovered_budget_lines(osv.osv):
                 else:
                     theo_amt = line.planned_amount
             else:
-                total = strToDate(line.date_to) - strToDate(line.date_from)
-                elapsed = min(strToDate(line.date_to),strToDate(date_to)) - max(strToDate(line.date_from),strToDate(date_from))
-                if strToDate(date_to) < strToDate(line.date_from):
-                    elapsed = strToDate(date_to) - strToDate(date_to)
+                line_timedelta = strToDatetime(line.date_to) - strToDatetime(line.date_from)
+                elapsed_timedelta = today - (strToDatetime(line.date_from))
 
-                if total.days:
-                    theo_amt = float((elapsed.days + 1) / float(total.days + 1)) * line.planned_amount
+                if elapsed_timedelta.days < 0:
+                    # If the budget line has not started yet, theoretical amount should be zero
+                    theo_amt = 0.00
+                elif line_timedelta.days > 0 and today < strToDatetime(line.date_to):
+                    # If today is between the budget line date_from and date_to
+                    theo_amt = (elapsed_timedelta.total_seconds() / line_timedelta.total_seconds()) * line.planned_amount
                 else:
                     theo_amt = line.planned_amount
 
index 312f38b..2002505 100644 (file)
@@ -92,8 +92,8 @@
                                         <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_scheduled,currency,company_currency)" domain="[('reconcile_id','=', False), ('credit', '>',0), ('account_id.reconcile', '=', True)] "/>
                                         <separator colspan="4" string="Transaction Information"/>
                                         <field name="date"/>
-                                        <label for="amount_currency" groups="base.group_multi_currency"/>
-                                        <div groups="base.group_multi_currency">
+                                        <label for="amount_currency" string="Amount"/>
+                                        <div>
                                             <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,company_currency)" class="oe_inline"/>
                                             <field name="currency" nolabel="1" class="oe_inline"/>
                                         </div>
index 6a049ff..528d357 100644 (file)
@@ -56,9 +56,6 @@ class account_payment_populate_statement(osv.osv_memory):
         statement_obj = self.pool.get('account.bank.statement')
         statement_line_obj = self.pool.get('account.bank.statement.line')
         currency_obj = self.pool.get('res.currency')
-        voucher_obj = self.pool.get('account.voucher')
-        voucher_line_obj = self.pool.get('account.voucher.line')
-        move_line_obj = self.pool.get('account.move.line')
 
         if context is None:
             context = {}
@@ -71,49 +68,24 @@ class account_payment_populate_statement(osv.osv_memory):
 
         for line in line_obj.browse(cr, uid, line_ids, context=context):
             ctx = context.copy()
-            ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now
+            ctx['date'] = line.ml_maturity_date  # was value_date earlier,but this field exists no more now
             amount = currency_obj.compute(cr, uid, line.currency.id,
                     statement.currency.id, line.amount_currency, context=ctx)
 
-            if not line.move_line_id.id:
-                continue
-            context = dict(context, move_line_ids=[line.move_line_id.id])
-            result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, amount=abs(amount), currency_id= statement.currency.id, ttype='payment', date=line.ml_maturity_date, context=context)
+            st_line_vals = self._prepare_statement_line_vals(cr, uid, line, amount, statement, context=context)
+            st_line_id = statement_line_obj.create(cr, uid, st_line_vals, context=context)
 
-            if line.move_line_id:
-                voucher_res = {
-                        'type': 'payment',
-                        'name': line.name,
-                        'partner_id': line.partner_id.id,
-                        'journal_id': statement.journal_id.id,
-                        'account_id': result['value'].get('account_id', statement.journal_id.default_credit_account_id.id),
-                        'company_id': statement.company_id.id,
-                        'currency_id': statement.currency.id,
-                        'date': line.date or time.strftime('%Y-%m-%d'),
-                        'amount': abs(amount),
-                        'period_id': statement.period_id.id,
-                }
-                voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
-
-                voucher_line_dict =  {}
-                for line_dict in result['value']['line_cr_ids'] + result['value']['line_dr_ids']:
-                    move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context)
-                    if line.move_line_id.move_id.id == move_line.move_id.id:
-                        voucher_line_dict = line_dict
-
-                if voucher_line_dict:
-                    voucher_line_dict.update({'voucher_id': voucher_id})
-                    voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
-                st_line_id = statement_line_obj.create(cr, uid, {
-                    'name': line.order_id.reference or '?',
-                    'amount': - amount,
-                    'partner_id': line.partner_id.id,
-                    'statement_id': statement.id,
-                    'ref': line.communication,
-                    }, context=context)
-
-                line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
+            line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
         return {'type': 'ir.actions.act_window_close'}
 
+    def _prepare_statement_line_vals(self, cr, uid, payment_line, amount,
+                                     statement, context=None):
+        return {
+            'name': payment_line.order_id.reference or '?',
+            'amount':-amount,
+            'partner_id': payment_line.partner_id.id,
+            'statement_id': statement.id,
+            'ref': payment_line.communication,
+        }
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 07be5f0..355d0ef 100644 (file)
@@ -736,7 +736,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
         },
         // return the unit of measure of the product
         get_unit: function(){
-            var unit_id = (this.product.uos_id || this.product.uom_id);
+            var unit_id = this.product.uom_id;
             if(!unit_id){
                 return undefined;
             }
index c45f415..f92fb50 100644 (file)
@@ -464,7 +464,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
             if(!product || !this.pos){
                 return defaultstr;
             }
-            var unit_id = product.uos_id || product.uom_id;
+            var unit_id = product.uom_id;
             if(!unit_id){
                 return defaultstr;
             }
index b8ff361..26ca38b 100644 (file)
 
     <script type="text/javascript" src="/website/static/src/js/website.snippets.animation.js"></script>
     <script type="text/javascript" src="/web/static/lib/bootstrap/js/bootstrap.js"></script>
+
+    <link rel="stylesheet" href="/web/static/lib/select2/select2.css"/>
+    <link rel="stylesheet" href="/website/static/lib/select2-bootstrap-css/select2-bootstrap.css"/>
+    <script type="text/javascript" src="/web/static/lib/select2/select2.js"></script>
     
 </template>
 
     <link rel='stylesheet' href='/website/static/src/css/snippets.css'/>
     <link rel='stylesheet' href='/website/static/src/css/editor.css'/>
     <link rel='stylesheet' href="/web/static/lib/jquery.ui/css/smoothness/jquery-ui-1.9.1.custom.css"/>
-    <link rel="stylesheet" href="/web/static/lib/select2/select2.css"/>
-    <link rel="stylesheet" href="/website/static/lib/select2-bootstrap-css/select2-bootstrap.css"/>
-
-    <script type="text/javascript" src="/web/static/lib/select2/select2.js"></script>
+    
     <script type="text/javascript" src="/web/static/lib/ckeditor/ckeditor.js"></script>
     <script type="text/javascript" src="/website/static/lib/ace/ace.js"></script>
     <script type="text/javascript" src="/website/static/lib/ace/theme-monokai.js"></script>
index cc25ecb..bc3a7bc 100644 (file)
@@ -276,7 +276,7 @@ class WebsiteForum(http.Controller):
         if not request.session.uid:
             return login_redirect()
 
-        post_tag_ids = forum._tag_to_write_vals(post.get('post_tags', False))
+        post_tag_ids = forum._tag_to_write_vals(post.get('post_tags', ''))
         new_question = request.env['forum.post'].create({
             'forum_id': forum.id,
             'name': post.get('post_name', ''),
index bced7f5..7b0b22d 100644 (file)
@@ -1,7 +1,5 @@
-$(document).ready(function () {
-    if ($('.website_forum').length){
+    openerp.website.if_dom_contains('.website_forum', function () {
         $("[data-toggle='popover']").popover();
-        
         $('.karma_required').on('click', function (ev) {
             var karma = $(ev.currentTarget).data('karma');
             if (karma) {
@@ -214,22 +212,22 @@ $(document).ready(function () {
                 }
             });
         }
-    }
-});
-
-function IsKarmaValid(eventNumber,minKarma){
-    "use strict";
-    if(parseInt($("#karma").val()) >= minKarma){
-        CKEDITOR.tools.callFunction(eventNumber,this);
-        return false;
-    } else {
-        alert("Sorry you need more than " + minKarma + " Karma.");
-    }
-}
-
-function CKEDITORLoadComplete(){
-    "use strict";
-    $('.cke_button__link').attr('onclick','IsKarmaValid(33,30)');
-    $('.cke_button__unlink').attr('onclick','IsKarmaValid(37,30)');
-    $('.cke_button__image').attr('onclick','IsKarmaValid(41,30)');
-}
+
+        function IsKarmaValid(eventNumber,minKarma){
+            "use strict";
+            if(parseInt($("#karma").val()) >= minKarma){
+                CKEDITOR.tools.callFunction(eventNumber,this);
+                return false;
+            } else {
+                alert("Sorry you need more than " + minKarma + " Karma.");
+            }
+        }
+
+        function CKEDITORLoadComplete(){
+            "use strict";
+            $('.cke_button__link').attr('onclick','IsKarmaValid(33,30)');
+            $('.cke_button__unlink').attr('onclick','IsKarmaValid(37,30)');
+            $('.cke_button__image').attr('onclick','IsKarmaValid(41,30)');
+        }
+    });
+
index 2f58ca2..590c790 100644 (file)
@@ -123,7 +123,7 @@ class product_template(osv.Model):
             string='Website Comments',
         ),
         'website_published': fields.boolean('Available in the website', copy=False),
-        'website_description': fields.html('Description for the website'),
+        'website_description': fields.html('Description for the website', translate=True),
         'alternative_product_ids': fields.many2many('product.template','product_alternative_rel','src_id','dest_id', string='Alternative Products', help='Appear on the product page'),
         'accessory_product_ids': fields.many2many('product.product','product_accessory_rel','src_id','dest_id', string='Accessory Products', help='Appear on the shopping cart'),
         'website_size_x': fields.integer('Size X'),
index 47a4d0a..08170da 100644 (file)
@@ -129,7 +129,9 @@ value), a mapping (the current item will be the current key) or an integer
 integer exclusive).
 
 In addition to the name passed via ``t-as``, ``foreach`` provides a few other
-variables for various data points (``$as`` is the name passed to ``t-as``):
+variables for various data points:
+
+.. warning:: ``$as`` will be replaced by the name passed to ``t-as``
 
 :samp:`{$as}_all`
     the object being iterated over