[FIX] report_intrastat, l10n_be_intrastat: period
The intrastat report period should match the accounting period of the invoice. This might not be the case if the user manually chooses an accounting period which does not match the invoice date. opw-668827
This commit is contained in:
parent
63fd73d83d
commit
f994be0e85
|
@ -208,6 +208,7 @@ class xml_decl(osv.TransientModel):
|
|||
left join res_country countrypartner on countrypartner.id = res_partner.country_id
|
||||
join product_product on inv_line.product_id=product_product.id
|
||||
join product_template on product_product.product_tmpl_id=product_template.id
|
||||
left join account_period on account_period.id=inv.period_id
|
||||
where
|
||||
inv.state in ('open','paid')
|
||||
and inv.company_id=%s
|
||||
|
@ -218,8 +219,8 @@ class xml_decl(osv.TransientModel):
|
|||
or (res_country.code is null and countrypartner.code is not null
|
||||
and not countrypartner.code=%s))
|
||||
and inv.type in (%s, %s)
|
||||
and to_char(inv.date_invoice, 'YYYY')=%s
|
||||
and to_char(inv.date_invoice, 'MM')=%s
|
||||
and to_char(account_period.date_start, 'YYYY')=%s
|
||||
and to_char(account_period.date_start, 'MM')=%s
|
||||
"""
|
||||
|
||||
cr.execute(sqlreq, (company.id, company.partner_id.country_id.code,
|
||||
|
|
|
@ -77,8 +77,8 @@ class report_intrastat(osv.osv):
|
|||
cr.execute("""
|
||||
create or replace view report_intrastat as (
|
||||
select
|
||||
to_char(inv.date_invoice, 'YYYY') as name,
|
||||
to_char(inv.date_invoice, 'MM') as month,
|
||||
to_char(account_period.date_start, 'YYYY') as name,
|
||||
to_char(account_period.date_start, 'MM') as month,
|
||||
min(inv_line.id) as id,
|
||||
intrastat.id as intrastat_id,
|
||||
upper(inv_country.code) as code,
|
||||
|
@ -113,11 +113,12 @@ class report_intrastat(osv.osv):
|
|||
left join (res_partner inv_address
|
||||
left join res_country inv_country on (inv_country.id = inv_address.country_id))
|
||||
on (inv_address.id = inv.partner_id)
|
||||
left join account_period on account_period.id=inv.period_id
|
||||
where
|
||||
inv.state in ('open','paid')
|
||||
and inv_line.product_id is not null
|
||||
and inv_country.intrastat=true
|
||||
group by to_char(inv.date_invoice, 'YYYY'), to_char(inv.date_invoice, 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id
|
||||
group by to_char(account_period.date_start, 'YYYY'), to_char(account_period.date_start, 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id
|
||||
)""")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue