summaryrefslogtreecommitdiff
path: root/vit_efaktur/wizard/auto.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
commit1ca3b3df3421961caec3b747a364071c80f5c7da (patch)
tree6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /vit_efaktur/wizard/auto.py
parentb57188be371d36d96caac4b8d65a40745c0e972c (diff)
initial commit
Diffstat (limited to 'vit_efaktur/wizard/auto.py')
-rw-r--r--vit_efaktur/wizard/auto.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/vit_efaktur/wizard/auto.py b/vit_efaktur/wizard/auto.py
new file mode 100644
index 0000000..7c7720b
--- /dev/null
+++ b/vit_efaktur/wizard/auto.py
@@ -0,0 +1,52 @@
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError
+
+class efaktur_wizard(models.TransientModel):
+ _name = 'vit.efaktur_auto'
+
+ start = fields.Date("Invoice Date Start",required=True)
+ end = fields.Date("Invoice Date End",required=True)
+ invoice_ids = fields.Many2many(comodel_name="account.move", string="Invoices", )
+
+ # @api.multi
+ def confirm_button(self):
+
+ invoice_ids = self.invoice_ids
+
+ efaktur_ids = self.env['vit.efaktur'].search([('is_used','=',False)],
+ order="name asc")
+ efaktur_len = len(efaktur_ids)
+
+ i = 0
+ for inv in invoice_ids:
+ if i < efaktur_len:
+ inv.efaktur_id = efaktur_ids[i]
+ else:
+ break
+ i+=1
+
+ self.env.cr.commit()
+ raise UserError("Selesai penomoran E-Faktur %s invoices(s)!" % i)
+
+ # @api.multi
+ def find_invoices(self):
+ start = self.start
+ end = self.end
+
+ inv_obj = self.env['account.move']
+ invoices = inv_obj.search([('invoice_date','>=', start),
+ ('invoice_date','<=', end),
+ ('state','=','open'),
+ ('efaktur_id','=',False),
+ ('type','=','out_invoice')
+ ])
+ i = 0
+ invoice_ids = []
+ for inv in invoices:
+ invoice_ids.append((4,inv.id))
+ i+=1
+
+ self.invoice_ids=invoice_ids
+ self.env.cr.commit()
+ raise UserError("Found %s invoices(s)!" % i)
+