Debian Codegraph @

addons/l10n_my_edi/wizard/myinvois_consolidate_invoice_wizard.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2 from odoo import fields, models
3
4 MAX_LINE_COUNT_PER_INVOICE = 100
5
6
7 class MyInvoisConsolidateInvoiceWizard(models.TransientModel):
8 _name = 'myinvois.consolidate.invoice.wizard'
9 _description = 'Consolidate Invoice Wizard'
10
11 # ------------------
12 # Fields declaration
13 # ------------------
14
15 date_from = fields.Date(
16 string='Date From',
17 required=True,
18 )
19 date_to = fields.Date(
20 string='Date To',
21 required=True,
22 )
23 consolidation_type = fields.Selection(
24 selection=[
25 ('invoice', 'Invoice'),
26 ],
27 required=True,
28 )
29
30 # --------------
31 # Action methods
32 # --------------
33
34 def button_consolidate(self):
35 """
36 By default, we only consolidated orders that are in the range, done and not invoiced.
37 We do allow to also consolidate invoices linked to a cancelled consolidated invoice.
38
39 Note that doing so lock the cancelled invoice into its cancelled state.
40 """
41 self.ensure_one()
42 myinvois_document_vals = self._get_myinvois_document_vals()
43 if myinvois_document_vals:
44 myinvois_documents = self.env["myinvois.document"].create(myinvois_document_vals)
45 return myinvois_documents.action_show_myinvois_documents()
46 return False
47
48 # ----------------
49 # Business methods
50 # ----------------
51
52 def _get_myinvois_document_vals(self):
53 """
54 Prepare and return a list of dicts containing the values needed to create the consolidated invoices for the
55 records inbetween the provided dates.
56 :return: A list of dicts used to create the consolidated invoices.
57 """
58 self.ensure_one()
59 if self.consolidation_type == 'invoice':
60 # We will support it soon, but not now. So we put the bases for it, but it won't be available to use yet.
61 # consolidation_type will never be 'invoice' unless custom code/actions are used.
62 raise NotImplementedError('Support for consolidated invoices in the invoicing app is not yet implemented.')