summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/account_move.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
-rw-r--r--indoteknik_custom/models/account_move.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 42467b78..723f225c 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -601,6 +601,7 @@ class AccountMove(models.Model):
template.send_mail(record.id, email_values=email_values, force_send=True)
elif record.partner_id.id in special_partner_ids:
+ cust_ref = record.sale_id.client_order_ref if record.sale_id and record.sale_id.client_order_ref else ''
attachment = self.generate_attachment(record)
email_list = [record.partner_id.email] if record.partner_id.email else []
if record.real_invoice_id and record.real_invoice_id.email:
@@ -610,7 +611,7 @@ class AccountMove(models.Model):
'email_to': ",".join(set(email_list)),
'attachment_ids': [(4, attachment.id)]
}
- template.send_mail(record.id, email_values=email_values, force_send=True)
+ template.with_context(cust_ref=cust_ref).send_mail(record.id, email_values=email_values, force_send=True)
# @api.model
# def create(self, vals):
@@ -785,6 +786,24 @@ class AccountMove(models.Model):
if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm':
raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock')
return res
+
+ def action_open_change_date_wizard(self):
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa edit tanggal journal entry')
+ non_draft = self.filtered(lambda m: m.state != 'draft')
+ if non_draft:
+ raise UserError('Hanya invoice dengan status draft yang bisa diubah tanggalnya. Mohon reset ke draft terlebih dahulu.')
+ return{
+ 'name': 'Change Date Journal Entry',
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'account.move.change.date.wizard',
+ 'target': 'new',
+ 'context':{
+ 'active_ids': self.ids,
+ 'active_model': self._name,
+ }
+ }
def action_post(self):
if self._name != 'account.move':
@@ -996,3 +1015,31 @@ class SyncPromiseDateWizardLine(models.TransientModel):
date_terima_tukar_faktur = fields.Date(related="invoice_id.date_terima_tukar_faktur", string="Tanggal Terima Tukar Faktur", readonly=True)
amount_total = fields.Monetary(related="invoice_id.amount_total", string="Total", readonly=True)
currency_id = fields.Many2one(related="invoice_id.currency_id", readonly=True)
+
+class AccountMoveChangeDateWizard(models.TransientModel):
+ _name = "account.move.change.date.wizard"
+ _description = "Account Move Change Date Wizard"
+
+ # move_id = fields.Many2one('account.move', string="Journal Entry", required=True)
+ new_date = fields.Date(string="New Date", required=True)
+
+ def action_change_date(self):
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa ubah tanggal')
+
+ active_ids = self.env.context.get('active_ids', [])
+ moves = self.env['account.move'].browse(active_ids)
+
+ if not moves:
+ raise UserError("Tidak ada journal entry yang dipilih.")
+
+ non_draft_moves = moves.filtered(lambda m: m.state != 'draft')
+ if non_draft_moves:
+ raise UserError("Hanya journal entry dengan status 'Draft' yang dapat diubah tanggalnya.")
+
+ for move in moves:
+ move.write({'date': self.new_date})
+ move.message_post(body="Tanggal berhasil diubah")
+
+ return {'type': 'ir.actions.act_window_close'}
+ \ No newline at end of file