diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index 922e01963e5..9ce9b593f0f 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -824,7 +824,7 @@ class account_invoice(osv.osv):
total_fixed += line.value_amount
if line.value == 'procent':
total_percent += line.value_amount
- total_fixed = (total_fixed * 100) / inv.amount_total
+ total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
if (total_fixed + total_percent) > 100:
raise osv.except_osv(_('Error !'), _("Cannot create the invoice !\nThe payment term defined gives a computed amount greater than the total invoiced amount."))
diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py
index 2f793b77d67..4ab6201b507 100644
--- a/addons/account/wizard/account_fiscalyear_close.py
+++ b/addons/account/wizard/account_fiscalyear_close.py
@@ -79,9 +79,9 @@ class account_fiscalyear_close(osv.osv_memory):
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise osv.except_osv(_('UserError'),
_('The journal must have default credit and debit account'))
- if not new_journal.centralisation:
+ if (not new_journal.centralisation) or new_journal.entry_posted:
raise osv.except_osv(_('UserError'),
- _('The journal must have centralised counterpart'))
+ _('The journal must have centralised counterpart without the Skipping draft state option checked!'))
move_ids = obj_acc_move_line.search(cr, uid, [
('journal_id', '=', new_journal.id), ('period_id.fiscalyear_id', '=', new_fyear.id)])
diff --git a/addons/account/wizard/account_validate_move_view.xml b/addons/account/wizard/account_validate_move_view.xml
index 352d23d6b53..d4184dd9c8b 100644
--- a/addons/account/wizard/account_validate_move_view.xml
+++ b/addons/account/wizard/account_validate_move_view.xml
@@ -10,7 +10,7 @@
diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py
index cca922304aa..9de7379d962 100644
--- a/addons/hr_evaluation/hr_evaluation.py
+++ b/addons/hr_evaluation/hr_evaluation.py
@@ -124,7 +124,7 @@ class hr_employee(osv.osv):
flag = False
evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0]
if not evaluation_date:
- evaluation_date=(parser.parse(datetime.date.today().strftime('%Y-%m-%d'))+ relativedelta(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
+ evaluation_date=(parser.parse(datetime.now().strftime('%Y-%m-%d'))+ relativedelta(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
flag = True
else:
if (parser.parse(evaluation_date) + relativedelta(months = int(evaluation_plan.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"):
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py
index d4cf10263f2..c780951d07e 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py
@@ -319,7 +319,7 @@ class hr_timesheet_sheet(osv.osv):
if r=='month':
return time.strftime('%Y-%m-01')
elif r=='week':
- return (datetime.today() + relativedelta(weekday=0)).strftime('%Y-%m-%d')
+ return (datetime.today() + relativedelta(weekday=0, weeks=-1)).strftime('%Y-%m-%d')
elif r=='year':
return time.strftime('%Y-01-01')
return time.strftime('%Y-%m-%d')
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_demo.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_demo.xml
index dedac8377a7..a4b4b434da6 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_demo.xml
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_demo.xml
@@ -10,11 +10,12 @@
-
+
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index d0402708f5f..cee60e63023 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -350,48 +350,6 @@ def rounding(f, r):
return f
return round(f / r) * r
-class many2many_domain(fields.many2many):
- def set(self, cr, obj, id, name, values, user=None, context=None):
- return super(many2many_domain, self).set(cr, obj, id, name, values, user=user,
- context=context)
-
- def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
- if not context:
- context = {}
-
- move_obj = obj.pool.get('stock.move')
- res = {}
- for i in ids:
- res[i] = []
- valid_move_ids = move_obj.search(cr, user, self._domain) # move ids relative to domain argument
- if valid_move_ids:
- cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s",
- [tuple(ids), tuple(valid_move_ids)])
- related_move_map = cr.fetchall()
- related_move_dict = dict((k, list(set([v[1] for v in itr]))) for k, itr in groupby(related_move_map, itemgetter(0)))
- res.update(related_move_dict)
-
- return res
-
-class one2many_domain(fields.one2many):
- def set(self, cr, obj, id, field, values, user=None, context=None):
- return super(one2many_domain, self).set(cr, obj, id, field, values,
- user=user, context=context)
-
- def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
- if not context:
- context = {}
-
- move_obj = obj.pool.get('stock.move')
- res = {}
- for i in ids:
- res[i] = []
- move_ids = move_obj.search(cr, user, self._domain+[('production_id', 'in', tuple(ids))], context=context)
- related_move_dict = dict([(o.production_id.id, [o.id]) for o in move_obj.browse(cr, user, move_ids, context=context)])
- res.update(related_move_dict)
-
- return res
-
class mrp_production(osv.osv):
"""
Production Orders / Manufacturing Orders
@@ -467,10 +425,10 @@ class mrp_production(osv.osv):
'picking_id': fields.many2one('stock.picking', 'Picking list', readonly=True,
help="This is the internal picking list that brings the finished product to the production plan"),
'move_prod_id': fields.many2one('stock.move', 'Move product', readonly=True),
- 'move_lines': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}),
- 'move_lines2': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))]),
- 'move_created_ids': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}),
- 'move_created_ids2': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))]),
+ 'move_lines': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}),
+ 'move_lines2': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))]),
+ 'move_created_ids': fields.one2many('stock.move', 'production_id', 'Moves Created', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}),
+ 'move_created_ids2': fields.one2many('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))]),
'product_lines': fields.one2many('mrp.production.product.line', 'production_id', 'Scheduled goods'),
'workcenter_lines': fields.one2many('mrp.production.workcenter.line', 'production_id', 'Work Centers Utilisation'),
'state': fields.selection([('draft','Draft'),('picking_except', 'Picking Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Cancelled'),('done','Done')],'State', readonly=True,
@@ -745,7 +703,7 @@ class mrp_production(osv.osv):
if rest_qty <= production_qty:
production_qty = rest_qty
if rest_qty > 0 :
- stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context)
+ stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, context=context)
for raw_product in production.move_lines2:
new_parent_ids = []
diff --git a/addons/purchase_requisition/wizard/purchase_requisition_partner.py b/addons/purchase_requisition/wizard/purchase_requisition_partner.py
index 2ae3ae795e9..ad2478cb7a5 100644
--- a/addons/purchase_requisition/wizard/purchase_requisition_partner.py
+++ b/addons/purchase_requisition/wizard/purchase_requisition_partner.py
@@ -86,21 +86,26 @@ class purchase_requisition_partner(osv.osv_memory):
uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False
newdate = datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S')
newdate = newdate - relativedelta(days=company.po_lead)
- delay = partner_rec and partner_rec.delay or False
- newdate = newdate -(delay or datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
+ delay = partner_rec and partner_rec.delay or 0.0
+ newdate = newdate -(delay and relativedelta(days=delay) or datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
partner = partner_rec and partner_rec.name or supplier_data
pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id or False
price = pricelist_obj.price_get(cr, uid, [pricelist_id], line.product_id.id, line.product_qty, False, {'uom': uom_id})[pricelist_id]
product = prod_obj.browse(cr, uid, line.product_id.id, context=context)
location_id = self.pool.get('stock.warehouse').read(cr, uid, [tender.warehouse_id.id], ['lot_input_id'])[0]['lot_input_id'][0]
+ if not newdate:
+ date_planned = datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S')
+ else:
+ date_planned = newdate.strftime('%Y-%m-%d %H:%M:%S')
+
purchase_order_line= {
'name': product.partner_ref,
'product_qty': line.product_qty,
'product_id': line.product_id.id,
'product_uom': uom_id,
'price_unit': price,
- 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date_planned': date_planned,
'notes': product.description_purchase,
}
taxes_ids = line.product_id.product_tmpl_id.supplier_taxes_id
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index f6c5f1de554..fe984b10f22 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2215,7 +2215,7 @@ class stock_move(osv.osv):
'product_qty': quantity,
'product_uos_qty': uos_qty,
'state': move.state,
- 'location_id': location_id
+ 'location_id': location_id or move.location_id.id,
}
if move.product_id.track_production and location_id:
# IF product has checked track for production lot, move lines will be split by 1
@@ -2238,9 +2238,8 @@ class stock_move(osv.osv):
update_val = {
'product_qty' : quantity_rest,
'product_uos_qty' : uos_qty_rest,
- 'location_id': location_id
+ 'location_id': location_id or move.location_id.id
}
-
self.write(cr, uid, [move.id], update_val)
product_obj = self.pool.get('product.product')