54
54
return self.pool.get('report.intrastat.product').search(cr, uid, [('intrastat_line_ids', 'in', ids)], context=context)
57
'company_id': fields.many2one('res.company', 'Company', required=True, states={'done':[('readonly',True)]}, help="Related company."),
58
'start_date': fields.date('Start date', required=True, states={'done':[('readonly',True)]}, help="Start date of the declaration. Must be the first day of a month."),
59
'end_date': fields.function(_compute_end_date, method=True, type='date', string='End date', store={
60
'report.intrastat.product': (lambda self, cr, uid, ids, c={}: ids, ['start_date'], 10),
61
}, help="End date for the declaration. Is the last day of the month of the start date."),
57
'company_id': fields.many2one('res.company', 'Company', required=True,
58
states={'done':[('readonly',True)]}, help="Related company."),
59
'start_date': fields.date('Start date', required=True,
60
states={'done':[('readonly',True)]},
61
help="Start date of the declaration. Must be the first day of a month."),
62
'end_date': fields.function(_compute_end_date, method=True, type='date',
63
string='End date', store={
64
'report.intrastat.product': (lambda self, cr, uid, ids, c={}: ids, ['start_date'], 10),
66
help="End date for the declaration. Is the last day of the month of the start date."),
62
67
'type': fields.selection([
65
], 'Type', required=True, states={'done':[('readonly',True)]}, help="Select the type of DEB."),
70
], 'Type', required=True, states={'done':[('readonly',True)]},
71
help="Select the type of DEB."),
66
72
'obligation_level' : fields.selection([
67
('detailed', 'Detailed'),
68
('simplified', 'Simplified')
69
], 'Obligation level', required=True, states={'done':[('readonly',True)]}, help="Your obligation level for a certain type of DEB (Import or Export) depends on the total value that you export or import per year. Note that the obligation level 'Simplified' doesn't exist for an Import DEB."),
70
'intrastat_line_ids': fields.one2many('report.intrastat.product.line', 'parent_id', 'Report intrastat product lines', states={'done':[('readonly',True)]}),
71
'num_lines': fields.function(_compute_numbers, method=True, type='integer', multi='numbers', string='Number of lines', store={
72
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['parent_id'], 20),
73
}, help="Number of lines in this declaration."),
74
'total_amount': fields.function(_compute_numbers, method=True, digits=(16,0), multi='numbers', string='Total amount', store={
75
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['amount_company_currency', 'parent_id'], 20),
76
}, help="Total amount in company currency of the declaration."),
77
'total_fiscal_amount': fields.function(_compute_total_fiscal_amount, method=True, digits=(16,0), string='Total fiscal amount', store={
78
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['amount_company_currency', 'parent_id'], 20),
79
}, help="Total fiscal amount in company currency of the declaration. This is the total amount that is displayed on the Prodouane website."),
80
'currency_id': fields.related('company_id', 'currency_id', readonly=True, type='many2one', relation='res.currency', string='Currency'),
73
('detailed', 'Detailed'),
74
('simplified', 'Simplified')
75
], 'Obligation level', required=True,
76
states={'done':[('readonly',True)]},
77
help="Your obligation level for a certain type of DEB (Import or Export) depends on the total value that you export or import per year. Note that the obligation level 'Simplified' doesn't exist for an Import DEB."),
78
'intrastat_line_ids': fields.one2many('report.intrastat.product.line',
79
'parent_id', 'Report intrastat product lines',
80
states={'done':[('readonly',True)]}),
81
'num_lines': fields.function(_compute_numbers, method=True, type='integer',
82
multi='numbers', string='Number of lines', store={
83
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['parent_id'], 20),
85
help="Number of lines in this declaration."),
86
'total_amount': fields.function(_compute_numbers, method=True,
87
digits_compute=dp.get_precision('Account'), multi='numbers',
88
string='Total amount', store={
89
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['amount_company_currency', 'parent_id'], 20),
91
help="Total amount in company currency of the declaration."),
92
'total_fiscal_amount': fields.function(_compute_total_fiscal_amount,
93
method=True, digits_compute=dp.get_precision('Account'),
94
string='Total fiscal amount', store={
95
'report.intrastat.product.line': (_get_intrastat_from_product_line, ['amount_company_currency', 'parent_id'], 20),
97
help="Total fiscal amount in company currency of the declaration. This is the total amount that is displayed on the Prodouane website."),
98
'currency_id': fields.related('company_id', 'currency_id', readonly=True,
99
type='many2one', relation='res.currency', string='Currency'),
81
100
'state' : fields.selection([
84
], 'State', select=True, readonly=True, help="State of the declaration. When the state is set to 'Done', the parameters become read-only."),
85
'date_done' : fields.datetime('Date done', readonly=True, help="Last date when the intrastat declaration was converted to 'Done' state."),
86
'notes' : fields.text('Notes', help="You can add some comments here if you want."),
103
], 'State', select=True, readonly=True,
104
help="State of the declaration. When the state is set to 'Done', the parameters become read-only."),
105
'date_done' : fields.datetime('Date done', readonly=True,
106
help="Last date when the intrastat declaration was converted to 'Done' state."),
107
'notes' : fields.text('Notes',
108
help="You can add some comments here if you want."),
198
228
skip_this_line = True
199
229
if skip_this_line:
201
amount_invoice_currency_to_write = line.price_subtotal
202
invoice_currency_id_to_write = parent_obj.currency_id.id
203
if parent_obj.currency_id.name <> 'EUR':
204
context['date'] = parent_obj.date_invoice
205
# TODO : add invoice_currency, also in add loop, WARN picking
206
amount_company_currency_to_write = self.pool.get('res.currency').compute(cr, uid, parent_obj.currency_id.id, intrastat.company_id.currency_id.id, line.price_subtotal, context=context)
208
amount_company_currency_to_write = line.price_subtotal
231
if line.product_id.is_accessory_cost and line.product_id.type == 'service':
232
total_invoice_cur_accessory_cost += line.price_subtotal
234
# END OF "continue" instructions
235
## AFTER THIS POINT, we are sure to have real products that have to be declared to DEB
236
amount_product_value_inv_cur_to_write = line.price_subtotal
237
total_invoice_cur_product_value += line.price_subtotal
238
invoice_currency_id_to_write = currency_obj.id
209
240
elif src == 'picking':
210
invoice_currency_id_to_write = False
211
amount_invoice_currency_to_write = False
241
invoice_currency_id_to_write = currency_obj.id
212
242
unit_stat_price = self.pool.get('product.pricelist').price_get(cr, uid, [intrastat.company_id.statistical_pricelist_id.id], line.product_id.id, 1.0)[intrastat.company_id.statistical_pricelist_id.id]
213
243
if not unit_stat_price:
214
244
raise osv.except_osv(_('Error :'), _("The Pricelist for statistical value '%s' that is set for the company '%s' gives a price of 0 for the product '%s'.") %(intrastat.company_id.statistical_pricelist_id.name, intrastat.company_id.name, line.product_id.name))
216
amount_company_currency_to_write = unit_stat_price * line_qty
246
amount_product_value_inv_cur_to_write = unit_stat_price * line_qty
218
248
if not parent_values['is_fiscal_only']:
799
851
# tree view when the value is False (if weight is an integer, a False value would
800
852
# be displayed as 0), that's why weight is a char !
801
853
'weight': fields.char('Weight', size=10, states={'done':[('readonly',True)]}),
802
'amount_invoice_currency': fields.integer('Fiscal value in invoice currency', readonly=True),
803
'amount_company_currency': fields.integer('Fiscal value in company currency', required=True, states={'done':[('readonly',True)]}),
854
'amount_company_currency': fields.integer('Fiscal value in company currency',
855
required=True, states={'done':[('readonly',True)]},
856
help="Amount in company currency to write in the declaration. Amount in company currency = amount in invoice currency converted to company currency with the rate of the invoice date (for pickings : with the rate of the 'date done') and rounded at 0 digits"),
857
'amount_invoice_currency': fields.float('Fiscal value in invoice currency',
858
digits_compute=dp.get_precision('Account'), readonly=True,
859
help="Amount in invoice currency = amount of product value in invoice currency + amount of accessory cost in invoice currency (not rounded)"),
860
'amount_accessory_cost_inv_cur': fields.float(
861
'Amount of accessory costs in invoice currency',
862
digits_compute=dp.get_precision('Account'), readonly=True,
863
help="Amount of accessory costs in invoice currency = total amount of accessory costs of the invoice broken down into each product line at the pro-rata of the value"),
864
'amount_product_value_inv_cur': fields.float(
865
'Amount of product value in invoice currency',
866
digits_compute=dp.get_precision('Account'), readonly=True,
867
help="Amount of product value in invoice currency. For invoices, it is the amount of the invoice line or group of invoice lines. For pickings, it is the value of the product given by the pricelist for statistical value of the company."),
804
868
'invoice_currency_id': fields.many2one('res.currency', "Invoice currency", readonly=True),
805
869
'product_country_origin_id' : fields.many2one('res.country', 'Product country of origin', states={'done':[('readonly',True)]}),
806
870
'product_country_origin_code' : fields.related('product_country_origin_id', 'code', type='string', relation='res.country', string='Product country of origin', readonly=True),