Merge lp:~camptocamp/new-report-intrastat/7.0-country-from-commercial into lp:new-report-intrastat/7.0

Proposed by Guewen Baconnier @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/new-report-intrastat/7.0-country-from-commercial
Merge into: lp:new-report-intrastat/7.0
Diff against target: 49 lines (+10/-6)
1 file modified
l10n_fr_intrastat_product/intrastat_product.py (+10/-6)
To merge this branch: bzr merge lp:~camptocamp/new-report-intrastat/7.0-country-from-commercial
Reviewer Review Type Date Requested Status
New report intrastat commiters Pending
Review via email: mp+225957@code.launchpad.net

Description of the change

When a partner of an invoice has no country, takes the country of the partner's commercial entity.

To post a comment you must log in.

Unmerged revisions

92. By Guewen Baconnier @ Camptocamp on 2014-07-08

wrong replacement

91. By Guewen Baconnier @ Camptocamp on 2014-07-08

When a partner has no country, takes the one of the commercial partner

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_fr_intrastat_product/intrastat_product.py'
2--- l10n_fr_intrastat_product/intrastat_product.py 2014-04-14 17:41:39 +0000
3+++ l10n_fr_intrastat_product/intrastat_product.py 2014-07-08 11:36:07 +0000
4@@ -392,7 +392,9 @@
5 if parent_values['is_vat_required']:
6 # If I have invoice.intrastat_country_id and the invoice partner
7 # is outside the EU, then I look for the fiscal rep of the partner
8- if invoice.intrastat_country_id and not invoice.partner_id.country_id.intrastat:
9+ partner_country = (invoice.partner_id.country_id or
10+ invoice.partner_id.commercial_partner_id.country_id)
11+ if invoice.intrastat_country_id and not partner_country.intrastat:
12 if not invoice.partner_id.intrastat_fiscal_representative:
13 raise orm.except_orm(_('Error :'), _("Missing fiscal representative for partner '%s'. It is required for invoice '%s' which has an invoice partner outside the EU but the goods were delivered to or received from inside the EU.") % (invoice.partner_id.name, invoice.number))
14 else:
15@@ -512,19 +514,21 @@
16 #print "INVOICE num =", invoice.number
17 parent_values = {}
18
19+ partner_country = (invoice.partner_id.country_id or
20+ invoice.partner_id.commercial_partner_id.country_id)
21 # We should always have a country on partner_id
22- if not invoice.partner_id.country_id:
23+ if not partner_country:
24 raise orm.except_orm(_('Error :'), _("Missing country on partner '%s'.") % invoice.partner_id.name)
25
26 # If I have no invoice.intrastat_country_id, which is the case the first month
27 # of the deployment of the module, then I use the country on invoice partner
28 if not invoice.intrastat_country_id:
29- if not invoice.partner_id.country_id.intrastat:
30+ if not partner_country.intrastat:
31 continue
32- elif invoice.partner_id.country_id.id == intrastat.company_id.country_id.id:
33+ elif partner_country.id == intrastat.company_id.country_id.id:
34 continue
35 else:
36- parent_values['partner_country_id_to_write'] = invoice.partner_id.country_id.id
37+ parent_values['partner_country_id_to_write'] = partner_country.id
38
39 # If I have invoice.intrastat_country_id, which should be the case after the
40 # first month of use of the module, then I use invoice.intrastat_country_id
41@@ -557,7 +561,7 @@
42 else:
43 parent_values['intrastat_type_id_to_write'] = invoice.intrastat_type_id.id
44
45- if invoice.intrastat_country_id and not invoice.partner_id.country_id.intrastat and invoice.partner_id.intrastat_fiscal_representative:
46+ if invoice.intrastat_country_id and not partner_country.intrastat and invoice.partner_id.intrastat_fiscal_representative:
47 # fiscal rep
48 parent_values['partner_id_to_write'] = invoice.partner_id.intrastat_fiscal_representative.id
49 else:

Subscribers

People subscribed via source and target branches