[MERGE] Forward-port of latest saas-1 bugfixes, up to rev. 8797 rev-id: dle@openerp.com-20131028202715-uinjafcgpnw1nucx
bzr revid: mat@openerp.com-20131028163349-hr0ul2uf18fcvg4b bzr revid: dle@openerp.com-20131028202944-eddqtgtikjq93nil
This commit is contained in:
commit
108eea6524
|
@ -107,14 +107,15 @@ class res_partner(osv.osv):
|
||||||
_description = 'Partner'
|
_description = 'Partner'
|
||||||
|
|
||||||
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context=None):
|
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context=None):
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
ctx = context.copy()
|
||||||
|
ctx['all_fiscalyear'] = True
|
||||||
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context=ctx)
|
||||||
cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
|
cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
|
||||||
FROM account_move_line l
|
FROM account_move_line l
|
||||||
LEFT JOIN account_account a ON (l.account_id=a.id)
|
LEFT JOIN account_account a ON (l.account_id=a.id)
|
||||||
WHERE a.type IN ('receivable','payable')
|
WHERE a.type IN ('receivable','payable')
|
||||||
AND l.partner_id IN %s
|
AND l.partner_id IN %s
|
||||||
AND (l.reconcile_id IS NULL OR
|
AND l.reconcile_id IS NULL
|
||||||
reconcile_id in (SELECT id FROM account_move_reconcile WHERE opening_reconciliation is TRUE))
|
|
||||||
AND """ + query + """
|
AND """ + query + """
|
||||||
GROUP BY l.partner_id, a.type
|
GROUP BY l.partner_id, a.type
|
||||||
""",
|
""",
|
||||||
|
|
|
@ -81,7 +81,8 @@
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.actions.act_window" id="act_analytic_cost_revenue">
|
<record model="ir.actions.act_window" id="act_analytic_cost_revenue">
|
||||||
<field name="context">{'search_default_account_id': [active_id], 'default_account_id': active_id, 'search_default_group_date': 1, 'search_default_group_journal': 1}</field>
|
<field name="context">{'search_default_group_date': 1, 'search_default_group_journal': 1}</field>
|
||||||
|
<field name="domain">[('account_id','child_of', active_id)]</field>
|
||||||
<field name="name">Costs & Revenues</field>
|
<field name="name">Costs & Revenues</field>
|
||||||
<field name="res_model">account.analytic.line</field>
|
<field name="res_model">account.analytic.line</field>
|
||||||
<field name="src_model">account.analytic.account</field>
|
<field name="src_model">account.analytic.account</field>
|
||||||
|
|
|
@ -61,66 +61,49 @@ class report_stock_move(osv.osv):
|
||||||
cr.execute("""
|
cr.execute("""
|
||||||
CREATE OR REPLACE view report_stock_move AS (
|
CREATE OR REPLACE view report_stock_move AS (
|
||||||
SELECT
|
SELECT
|
||||||
min(sm_id) as id,
|
min(sm.id) as id,
|
||||||
date_trunc('day',al.dp) as date,
|
date_trunc('day', sm.date) as date,
|
||||||
al.curr_year as year,
|
to_char(date_trunc('day',sm.date), 'YYYY') as year,
|
||||||
al.curr_month as month,
|
to_char(date_trunc('day',sm.date), 'MM') as month,
|
||||||
al.curr_day as day,
|
to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as day,
|
||||||
al.curr_day_diff as day_diff,
|
avg(date(sm.date)-date(sm.create_date)) as day_diff,
|
||||||
al.curr_day_diff1 as day_diff1,
|
avg(date(sm.date_expected)-date(sm.create_date)) as day_diff1,
|
||||||
al.curr_day_diff2 as day_diff2,
|
avg(date(sm.date)-date(sm.date_expected)) as day_diff2,
|
||||||
al.location_id as location_id,
|
|
||||||
al.picking_id as picking_id,
|
|
||||||
al.company_id as company_id,
|
|
||||||
al.location_dest_id as location_dest_id,
|
|
||||||
al.product_qty,
|
|
||||||
al.out_qty as product_qty_out,
|
|
||||||
al.in_qty as product_qty_in,
|
|
||||||
al.partner_id as partner_id,
|
|
||||||
al.product_id as product_id,
|
|
||||||
al.state as state ,
|
|
||||||
al.product_uom as product_uom,
|
|
||||||
al.categ_id as categ_id,
|
|
||||||
coalesce(al.type, 'other') as type,
|
|
||||||
al.stock_journal as stock_journal,
|
|
||||||
sum(al.in_value - al.out_value) as value
|
|
||||||
FROM (SELECT
|
|
||||||
CASE WHEN sp.type in ('out') THEN
|
|
||||||
sum(sm.product_qty * pu.factor / pu2.factor)
|
|
||||||
ELSE 0.0
|
|
||||||
END AS out_qty,
|
|
||||||
CASE WHEN sp.type in ('in') THEN
|
|
||||||
sum(sm.product_qty * pu.factor / pu2.factor)
|
|
||||||
ELSE 0.0
|
|
||||||
END AS in_qty,
|
|
||||||
CASE WHEN sp.type in ('out') THEN
|
|
||||||
sum(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price
|
|
||||||
ELSE 0.0
|
|
||||||
END AS out_value,
|
|
||||||
CASE WHEN sp.type in ('in') THEN
|
|
||||||
sum(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price
|
|
||||||
ELSE 0.0
|
|
||||||
END AS in_value,
|
|
||||||
min(sm.id) as sm_id,
|
|
||||||
sm.date as dp,
|
|
||||||
to_char(date_trunc('day',sm.date), 'YYYY') as curr_year,
|
|
||||||
to_char(date_trunc('day',sm.date), 'MM') as curr_month,
|
|
||||||
to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day,
|
|
||||||
avg(date(sm.date)-date(sm.create_date)) as curr_day_diff,
|
|
||||||
avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1,
|
|
||||||
avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2,
|
|
||||||
sm.location_id as location_id,
|
sm.location_id as location_id,
|
||||||
|
sm.picking_id as picking_id,
|
||||||
|
sm.company_id as company_id,
|
||||||
sm.location_dest_id as location_dest_id,
|
sm.location_dest_id as location_dest_id,
|
||||||
sum(sm.product_qty) as product_qty,
|
sum(sm.product_qty) as product_qty,
|
||||||
pt.categ_id as categ_id ,
|
sum(
|
||||||
|
(CASE WHEN sp.type in ('out') THEN
|
||||||
|
(sm.product_qty * pu.factor / pu2.factor)
|
||||||
|
ELSE 0.0
|
||||||
|
END)
|
||||||
|
) as product_qty_out,
|
||||||
|
sum(
|
||||||
|
(CASE WHEN sp.type in ('in') THEN
|
||||||
|
(sm.product_qty * pu.factor / pu2.factor)
|
||||||
|
ELSE 0.0
|
||||||
|
END)
|
||||||
|
) as product_qty_in,
|
||||||
sm.partner_id as partner_id,
|
sm.partner_id as partner_id,
|
||||||
sm.product_id as product_id,
|
sm.product_id as product_id,
|
||||||
sm.picking_id as picking_id,
|
sm.state as state,
|
||||||
sm.company_id as company_id,
|
sm.product_uom as product_uom,
|
||||||
sm.state as state,
|
pt.categ_id as categ_id ,
|
||||||
sm.product_uom as product_uom,
|
coalesce(sp.type, 'other') as type,
|
||||||
sp.type as type,
|
sp.stock_journal_id AS stock_journal,
|
||||||
sp.stock_journal_id AS stock_journal
|
sum(
|
||||||
|
(CASE WHEN sp.type in ('in') THEN
|
||||||
|
(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price
|
||||||
|
ELSE 0.0
|
||||||
|
END)
|
||||||
|
-
|
||||||
|
(CASE WHEN sp.type in ('out') THEN
|
||||||
|
(sm.product_qty * pu.factor / pu2.factor) * pt.standard_price
|
||||||
|
ELSE 0.0
|
||||||
|
END)
|
||||||
|
) as value
|
||||||
FROM
|
FROM
|
||||||
stock_move sm
|
stock_move sm
|
||||||
LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
|
LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
|
||||||
|
@ -129,16 +112,11 @@ class report_stock_move(osv.osv):
|
||||||
LEFT JOIN product_uom pu2 ON (sm.product_uom=pu2.id)
|
LEFT JOIN product_uom pu2 ON (sm.product_uom=pu2.id)
|
||||||
LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
sm.id,sp.type, sm.date,sm.partner_id,
|
coalesce(sp.type, 'other'), date_trunc('day', sm.date), sm.partner_id,
|
||||||
sm.product_id,sm.state,sm.product_uom,sm.date_expected,
|
sm.state, sm.product_uom, sm.date_expected,
|
||||||
sm.product_id,pt.standard_price, sm.picking_id, sm.product_qty,
|
sm.product_id, pt.standard_price, sm.picking_id,
|
||||||
sm.company_id,sm.product_qty, sm.location_id,sm.location_dest_id,pu.factor,pt.categ_id, sp.stock_journal_id)
|
sm.company_id, sm.location_id, sm.location_dest_id, pu.factor, pt.categ_id, sp.stock_journal_id,
|
||||||
AS al
|
year, month, day
|
||||||
GROUP BY
|
|
||||||
al.out_qty,al.in_qty,al.curr_year,al.curr_month,
|
|
||||||
al.curr_day,al.curr_day_diff,al.curr_day_diff1,al.curr_day_diff2,al.dp,al.location_id,al.location_dest_id,
|
|
||||||
al.partner_id,al.product_id,al.state,al.product_uom,
|
|
||||||
al.picking_id,al.company_id,al.type,al.product_qty, al.categ_id, al.stock_journal
|
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,14 @@ class invoice_directly(osv.osv_memory):
|
||||||
if context is None: context = {}
|
if context is None: context = {}
|
||||||
result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
|
result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
|
||||||
partial = self.browse(cr, uid, ids[0], context)
|
partial = self.browse(cr, uid, ids[0], context)
|
||||||
|
if partial.picking_id.state != 'done' and partial.picking_id.backorder_id:
|
||||||
|
# delivery is not finished, opening invoice on backorder
|
||||||
|
picking = partial.picking_id.backorder_id
|
||||||
|
else:
|
||||||
|
picking = partial.picking_id
|
||||||
context.update(active_model='stock.picking',
|
context.update(active_model='stock.picking',
|
||||||
active_ids=[partial.picking_id.id])
|
active_ids=[picking.id])
|
||||||
if partial.picking_id.invoice_state == '2binvoiced':
|
if picking.invoice_state == '2binvoiced':
|
||||||
return {
|
return {
|
||||||
'name': 'Create Invoice',
|
'name': 'Create Invoice',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
|
|
Loading…
Reference in New Issue