diff --git a/addons/account/account.py b/addons/account/account.py
index 1178712362e..61851b30f1f 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -248,59 +248,59 @@ class account_account(osv.osv):
def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
query='', query_params=()):
- """ compute the balance, debit and/or credit for the provided
- account ids
- Arguments:
- `ids`: account ids
- `field_names`: the fields to compute (a list of any of
- 'balance', 'debit' and 'credit')
- `arg`: unused fields.function stuff
- `query`: additional query filter (as a string)
- `query_params`: parameters for the provided query string
- (__compute will handle their escaping) as a
- tuple
- """
- mapping = {
- 'balance': "COALESCE(SUM(l.debit),0) " \
- "- COALESCE(SUM(l.credit), 0) as balance",
- 'debit': "COALESCE(SUM(l.debit), 0) as debit",
- 'credit': "COALESCE(SUM(l.credit), 0) as credit"
- }
- #get all the necessary accounts
- children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
- #compute for each account the balance/debit/credit from the move lines
- accounts = {}
- if children_and_consolidated:
- aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ """ compute the balance, debit and/or credit for the provided
+ account ids
+ Arguments:
+ `ids`: account ids
+ `field_names`: the fields to compute (a list of any of
+ 'balance', 'debit' and 'credit')
+ `arg`: unused fields.function stuff
+ `query`: additional query filter (as a string)
+ `query_params`: parameters for the provided query string
+ (__compute will handle their escaping) as a
+ tuple
+ """
+ mapping = {
+ 'balance': "COALESCE(SUM(l.debit),0) " \
+ "- COALESCE(SUM(l.credit), 0) as balance",
+ 'debit': "COALESCE(SUM(l.debit), 0) as debit",
+ 'credit': "COALESCE(SUM(l.credit), 0) as credit"
+ }
+ #get all the necessary accounts
+ children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
+ #compute for each account the balance/debit/credit from the move lines
+ accounts = {}
+ if children_and_consolidated:
+ aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
- wheres = [""]
- if query.strip():
- wheres.append(query.strip())
- if aml_query.strip():
- wheres.append(aml_query.strip())
- filters = " AND ".join(wheres)
- self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
- 'Filters: %s'%filters)
- # IN might not work ideally in case there are too many
- # children_and_consolidated, in that case join on a
- # values() e.g.:
- # SELECT l.account_id as id FROM account_move_line l
- # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
- # ON l.account_id = tmp.id
- # or make _get_children_and_consol return a query and join on that
- request = ("SELECT l.account_id as id, " +\
- ' , '.join(map(mapping.__getitem__, field_names)) +
- " FROM account_move_line l" \
- " WHERE l.account_id IN %s " \
- + filters +
- " GROUP BY l.account_id")
- params = (tuple(children_and_consolidated),) + query_params
- cr.execute(request, params)
- self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
- 'Status: %s'%cr.statusmessage)
+ wheres = [""]
+ if query.strip():
+ wheres.append(query.strip())
+ if aml_query.strip():
+ wheres.append(aml_query.strip())
+ filters = " AND ".join(wheres)
+ self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
+ 'Filters: %s'%filters)
+ # IN might not work ideally in case there are too many
+ # children_and_consolidated, in that case join on a
+ # values() e.g.:
+ # SELECT l.account_id as id FROM account_move_line l
+ # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
+ # ON l.account_id = tmp.id
+ # or make _get_children_and_consol return a query and join on that
+ request = ("SELECT l.account_id as id, " +\
+ ' , '.join(map(mapping.__getitem__, field_names)) +
+ " FROM account_move_line l" \
+ " WHERE l.account_id IN %s " \
+ + filters +
+ " GROUP BY l.account_id")
+ params = (tuple(children_and_consolidated),) + query_params
+ cr.execute(request, params)
+ self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
+ 'Status: %s'%cr.statusmessage)
- for res in cr.dictfetchall():
- accounts[res['id']] = res
+ for res in cr.dictfetchall():
+ accounts[res['id']] = res
# consolidate accounts with direct children
children_and_consolidated.reverse()
@@ -2539,9 +2539,9 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'account_paid_id': acc_template_ref[value['account_paid_id']],
})
- # Creating Journals
+ # Creating Journals Sales and Purchase
vals_journal={}
- data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_view')])
+ data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
data = data_pool.browse(cr, uid, data_id[0])
view_id = data.res_id
@@ -2573,6 +2573,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
vals_journal['type'] = 'purchase'
vals_journal['code'] = _('EXJ')
vals_journal['sequence_id'] = seq_id_purchase
+ vals_journal['view_id'] = view_id
if obj_multi.chart_template_id.property_account_payable:
vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index bf12bdc2087..76989d2f02c 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -183,7 +183,7 @@ class account_move_line(osv.osv):
# Compute the current move
move_id = False
partner_id = False
- if context.get('journal_id',False) and context.get('period_id',False):
+ if context.get('journal_id', False) and context.get('period_id', False):
if 'move_id' in fields:
cr.execute('select move_id \
from \
@@ -199,6 +199,7 @@ class account_move_line(osv.osv):
return data
else:
data['move_id'] = move_id
+
if 'date' in fields:
cr.execute('select date \
from \
@@ -214,7 +215,6 @@ class account_move_line(osv.osv):
period = period_obj.browse(cr, uid, context['period_id'],
context=context)
data['date'] = period.date_start
-
if not move_id:
return data
@@ -786,6 +786,31 @@ class account_move_line(osv.osv):
return j+(p and (':'+p) or '')
return False
+# def onchange_date(self, cr, user, ids, date, context={}):
+# """
+# Returns a dict that contains new values and context
+# @param cr: A database cursor
+# @param user: ID of the user currently logged in
+# @param date: latest value from user input for field date
+# @param args: other arguments
+# @param context: context arguments, like lang, time zone
+# @return: Returns a dict which contains new values, and context
+# """
+# res = {}
+# period_pool = self.pool.get('account.period')
+# pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
+# if pids:
+# res.update({
+# 'period_id':pids[0]
+# })
+# context.update({
+# 'period_id':pids[0]
+# })
+# return {
+# 'value':res,
+# 'context':context,
+# }
+
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu)
if view_type != 'tree':
@@ -848,11 +873,14 @@ class account_move_line(osv.osv):
elif field == 'credit':
attrs.append('sum="Total credit"')
elif field == 'account_tax_id':
- attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
+ attrs.append('domain="[(\'parent_id\',\'=\',False), (\'type_tax_use\',\'=\',context.get(journal_id.type, \'sale\'))]"')
elif field == 'account_id' and journal.id:
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
elif field == 'partner_id':
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
+# elif field == 'date':
+# attrs.append('on_change="onchange_date(date)"')
+
# if field.readonly:
# attrs.append('readonly="1"')
# if field.required:
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 93567fb2b5a..be650a4613f 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -269,9 +269,9 @@
-
-
-
+
+
+
@@ -283,8 +283,8 @@
-
-
+
+
@@ -295,11 +295,18 @@
form
+
+ Journal Views
+ account.journal.view
+ form
+ tree,form
+
+
- Price List
+ Price per unit
product.price_list
form
-
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index acb8280757f..2ffdd78e284 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -305,7 +305,7 @@ class purchase_order(osv.osv):
def inv_line_create(self, cr, uid, a, ol):
return (0, False, {
'name': ol.name,
- 'account_id': a.id,
+ 'account_id': a,
'price_unit': ol.price_unit or 0.0,
'quantity': ol.product_qty,
'product_id': ol.product_id.id or False,
@@ -344,7 +344,7 @@ class purchase_order(osv.osv):
if not a:
raise osv.except_osv(_('Error !'), _('There is no expense account defined for this product: "%s" (id:%d)') % (ol.product_id.name, ol.product_id.id,))
else:
- a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
+ a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category').id
fpos = o.fiscal_position or False
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
il.append(self.inv_line_create(cr, uid, a, ol))
@@ -746,23 +746,24 @@ class procurement_order(osv.osv):
po_obj = self.pool.get('purchase.order')
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
- partner = procurement.product_id.seller_ids[0].name
+ partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
+ seller_qty = procurement.product_id.seller_qty
+ seller_delay = int(procurement.product_id.seller_delay)
partner_id = partner.id
- partner_rec = procurement.product_id.seller_ids[0]
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
pricelist_id = partner.property_product_pricelist_purchase.id
uom_id = procurement.product_id.uom_po_id.id
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
- if procurement.product_id.seller_ids[0].qty:
- qty = max(qty,partner_rec.qty)
+ if seller_qty:
+ qty = max(qty,seller_qty)
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id]
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
- newdate = newdate - partner_rec.delay
+ newdate = newdate - seller_delay
#Passing partner_id to context for purchase order line integrity of Line name
context.update({'lang': partner.lang, 'partner_id': partner_id})
diff --git a/addons/resource/resource_view.xml b/addons/resource/resource_view.xml
index e84fa6fc34d..98afe8f5a03 100644
--- a/addons/resource/resource_view.xml
+++ b/addons/resource/resource_view.xml
@@ -78,8 +78,7 @@
-
-
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index bb5af627ebb..83f828203f6 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2079,9 +2079,10 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.id], update_val)
product_obj = self.pool.get('product.product')
- for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]):
- message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(move.product_qty) + "' "+ _("quantity.")
- self.log(cr, uid, move.id, message)
+ for new_move in self.browse(cr, uid, res, context=context):
+ for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]):
+ message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.")
+ self.log(cr, uid, new_move.id, message)
self.action_done(cr, uid, res)
return res