Somesh Khare(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-6191-skh into
lp:openobject-addons/6.0.
Requested reviews:
Priyesh (OpenERP) (pso-openerp)
Jay Vora (OpenERP) (jvo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-6191-skh/+merge/64397
Hello Sir,
[Fix] : Wrong stock value in the Multi Company.
This happens in the scenario when there is 2 or more child companies for a
parent company, and if there is one shared product "test product" and a common
partner for both child companies. If the user of the child companies are
creating the purchase order as,
Child 1: buys 1 "test product" at R10 -> reciepts stock and validates supplier
invoice.
Child 2: buys 1 "test product" at R20 -> reciepts stock and validates
supplier invoice.
Total stock valuation (eg. in reporting->inventory analysis) should be R30
Branch 1: stock value: 10 Branch 2: stock value: 20 Consolidated total: stock
value: 30
But In the current system the value is,
Child 1: stock value: 20
Child 2: stock value: 20
Consolidated total: stock value: 40 (Wrong)
Issue is fixed in the branch.
Thanks,
SKH
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-6191-skh/+merge/64397
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-6191-skh.
=== modified file 'account/account.py'
--- account/account.py 2011-06-07 18:21:44 +0000
+++ account/account.py 2011-06-13 12:33:33 +0000
@@ -952,7 +952,9 @@
raise osv.except_osv(_('Error'), _('You should have chosen periods that belongs to the same company'))
if period_date_start > period_date_stop:
raise osv.except_osv(_('Error'), _('Start period should be smaller then End period'))
- return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
+ if period_from.special:
+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id),('special', '=', False)])
account_period()
=== modified file 'account/account_move_line.py'
--- account/account_move_line.py 2011-05-12 12:22:12 +0000
+++ account/account_move_line.py 2011-06-13 12:33:33 +0000
@@ -82,16 +82,20 @@
period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1)
if period_ids and period_ids[0]:
first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context)
- # Find the old periods where date start of those periods less then Start period
- periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)])
- periods = ','.join([str(x) for x in periods])
- if periods:
- query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND id IN (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date)
+ ids = ','.join([str(x) for x in context['periods']])
+ query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND date_start <= '%s' AND id NOT IN (%s)) %s %s" % (fiscalyear_clause, first_period.date_start, ids, where_move_state, where_move_lines_by_date)
else:
ids = ','.join([str(x) for x in context['periods']])
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND id IN (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
else:
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s)) %s %s" % (fiscalyear_clause, where_move_state, where_move_lines_by_date)
+
+ if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
+ #we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
+ #so we have to invalidate this query
+ raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance"))
+
+
if context.get('journal_ids', False):
query += ' AND '+obj+'.journal_id IN (%s)' % ','.join(map(str, context['journal_ids']))
=== modified file 'account/report/account_general_ledger.py'
--- account/report/account_general_ledger.py 2011-01-14 00:11:01 +0000
+++ account/report/account_general_ledger.py 2011-06-13 12:33:33 +0000
@@ -40,9 +40,10 @@
self.sortby = data['form'].get('sortby', 'sort_date')
self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context',{}))
ctx2 = data['form'].get('used_context',{}).copy()
- ctx2.update({'initial_bal': True})
+ self.init_balance = data['form'].get('initial_balance', True)
+ if self.init_balance:
+ ctx2.update({'initial_bal': True})
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
- self.init_balance = data['form']['initial_balance']
self.display_account = data['form']['display_account']
self.target_move = data['form'].get('target_move', 'all')
ctx = self.context.copy()
=== modified file 'account/report/account_partner_ledger.py'
--- account/report/account_partner_ledger.py 2011-01-14 00:11:01 +0000
+++ account/report/account_partner_ledger.py 2011-06-13 12:33:33 +0000
@@ -58,10 +58,13 @@
obj_partner = self.pool.get('res.partner')
self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
ctx2 = data['form'].get('used_context',{}).copy()
- ctx2.update({'initial_bal': True})
+ self.initial_balance = data['form'].get('initial_balance', True)
+ if self.initial_balance:
+ ctx2.update({'initial_bal': True})
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
- self.reconcil = data['form'].get('reconcil', True)
- self.initial_balance = data['form'].get('initial_balance', True)
+ self.reconcil = True
+ if data['form']['filter'] == 'unreconciled':
+ self.reconcil = False
self.result_selection = data['form'].get('result_selection', 'customer')
self.amount_currency = data['form'].get('amount_currency', False)
self.target_move = data['form'].get('target_move', 'all')
=== modified file 'account/wizard/account_report_common.py'
--- account/wizard/account_report_common.py 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_common.py 2011-06-13 12:33:33 +0000
@@ -56,7 +56,7 @@
return res
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
- res = {}
+ res = {'value': {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}}
if filter == 'filter_no':
res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}
if filter == 'filter_date':
@@ -68,7 +68,7 @@
FROM account_period p
LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
- ORDER BY p.date_start ASC
+ ORDER BY p.date_start ASC, p.special ASC
LIMIT 1) AS period_start
UNION
SELECT * FROM (SELECT p.id
=== modified file 'account/wizard/account_report_partner_ledger.py'
--- account/wizard/account_report_partner_ledger.py 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_partner_ledger.py 2011-06-13 12:33:33 +0000
@@ -32,22 +32,29 @@
_columns = {
'initial_balance': fields.boolean('Include initial balances',
help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
- 'reconcil': fields.boolean('Include Reconciled Entries', help='Consider reconciled entries'),
+ 'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods'), ('unreconciled', 'Unreconciled Entries')], "Filter by", required=True),
'page_split': fields.boolean('One Partner Per Page', help='Display Ledger Report with One partner per page'),
'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"),
}
_defaults = {
- 'reconcil': True,
- 'initial_balance': True,
+ 'initial_balance': False,
'page_split': False,
}
+ def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
+ res = super(account_partner_ledger, self).onchange_filter(cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id, context=context)
+ if filter in ['filter_no', 'unreconciled']:
+ if filter == 'unreconciled':
+ res['value'].update({'fiscalyear_id': False})
+ res['value'].update({'initial_balance': False, 'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False})
+ return res
+
def _print_report(self, cr, uid, ids, data, context=None):
if context is None:
context = {}
data = self.pre_print_report(cr, uid, ids, data, context=context)
- data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'reconcil', 'page_split', 'amount_currency'])[0])
+ data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'filter', 'page_split', 'amount_currency'])[0])
if data['form']['page_split']:
return {
'type': 'ir.actions.report.xml',
=== modified file 'account/wizard/account_report_partner_ledger_view.xml'
--- account/wizard/account_report_partner_ledger_view.xml 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_partner_ledger_view.xml 2011-06-13 12:33:33 +0000
@@ -15,12 +15,14 @@
</xpath>
<xpath expr="//field[@name='target_move']" position="after">
<field name="result_selection"/>
- <field name="initial_balance"/>
- <field name="reconcil"/>
<field name="amount_currency"/>
<field name="page_split"/>
<newline/>
</xpath>
+ <xpath expr="//field[@name='filter']" position="replace">
+ <field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4"/>
+ <field name="initial_balance" attrs="{'readonly':[('filter', 'in', ('filter_no', 'unreconciled'))]}" />
+ </xpath>
</data>
</field>
</record>
=== modified file 'stock/report/report_stock_move.py'
--- stock/report/report_stock_move.py 2011-05-03 09:57:42 +0000
+++ stock/report/report_stock_move.py 2011-06-13 12:33:33 +0000
@@ -176,7 +176,7 @@
m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
m.company_id,
m.state as state, m.prodlot_id as prodlot_id,
- coalesce(sum(-pt.standard_price * m.product_qty)::decimal, 0.0) as value,
+ coalesce(sum(-m.price_unit * m.product_qty)::decimal, 0.0) as value,
CASE when pt.uom_id = m.product_uom
THEN
coalesce(sum(-m.product_qty)::decimal, 0.0)
@@ -200,7 +200,7 @@
m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
m.company_id,
m.state as state, m.prodlot_id as prodlot_id,
- coalesce(sum(pt.standard_price * m.product_qty )::decimal, 0.0) as value,
+ coalesce(sum(m.price_unit * m.product_qty )::decimal, 0.0) as value,
CASE when pt.uom_id = m.product_uom
THEN
coalesce(sum(m.product_qty)::decimal, 0.0)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp