diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-07-10 15:16:28 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-07-10 15:16:28 +0700 |
| commit | 659a62598fd984a233e9eee6f40ee6408ce17ac6 (patch) | |
| tree | 005df74098fae11463fbadd699b5610b0348a453 | |
| parent | 6aee89eff0e1511c257c60fac9fa84172729063c (diff) | |
| parent | 0a66ca2c69581100f5a0800152a6d80a07351d6c (diff) | |
(andri) fix conflict
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/approval_payment_term.py | 31 | ||||
| -rw-r--r-- | indoteknik_custom/models/dunning_run.py | 16 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/approval_payment_term.xml | 18 |
5 files changed, 58 insertions, 10 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index eb39a1ac..822c54f7 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -89,7 +89,7 @@ class AccountMove(models.Model): ('payment_state', 'not in', ['paid','in_payment', 'reversed']), ('invoice_date_due', '>=', today - timedelta(days=7)), ('invoice_date_due', '>=', today - timedelta(days=3)), - ('invoice_date_due', '=', today), + ('invoice_date_due', '>=', today), ('invoice_date_due', '<=', today + timedelta(days=3)), ('invoice_date_due', '<=', today + timedelta(days=7)), ('partner_id', '=', partner.id), diff --git a/indoteknik_custom/models/approval_payment_term.py b/indoteknik_custom/models/approval_payment_term.py index 4cd9ea36..6e1c8103 100644 --- a/indoteknik_custom/models/approval_payment_term.py +++ b/indoteknik_custom/models/approval_payment_term.py @@ -33,6 +33,33 @@ class ApprovalPaymentTerm(models.Model): approve_date = fields.Datetime('Approve Date') state = fields.Selection([('waiting_approval', 'Waiting Approval'), ('approved', 'Approved'), ('rejected', 'Rejected')], default='waiting_approval', tracking=True) reason_reject = fields.Selection([('reason1', 'Reason 1'), ('reason2', 'Reason 2'), ('reason3', 'Reason 3')], string='Reason Reject', tracking=True) + sale_order_ids = fields.Many2many( + 'sale.order', + string='Sale Orders', + copy=False, + tracking=True + ) + + total = fields.Char( + string='Sale Order Totals', + compute='_compute_total' + ) + + grand_total = fields.Float(string='Grand Total', compute="_compute_grand_total") + + def _compute_grand_total(self): + for rec in self: + grand_total = sum(order.amount_total for order in rec.sale_order_ids) + rec.grand_total = grand_total + + def _compute_total(self): + for rec in self: + totals_list = [] + for order in rec.sale_order_ids: + formatted_total = "{:,.2f}".format(order.amount_total) + totals_list.append(f"{order.name}: {formatted_total}") + + rec.total = "\n".join(totals_list) if totals_list else "No Sale Orders" @api.constrains('partner_id') @@ -48,11 +75,11 @@ class ApprovalPaymentTerm(models.Model): user = self.env.user is_it = user.has_group('indoteknik_custom.group_role_it') - if (not user.id ==7 and user.id == 19) or is_it: + if (not user.id ==7 and user.id == 19 and not self.approve_sales_manager) or is_it: self.approve_sales_manager = True return - if (not user.id ==7 and user.id == 688) or is_it: + if (not user.id ==7 and user.id == 688 and not self.approve_finance) or is_it: self.approve_finance = True return diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index bb53fc0c..341b206d 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -92,10 +92,19 @@ class DunningRun(models.Model): ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), ('partner_id', '=', partner.id), - # ('amount_residual_signed', '>', 0), ('date_kirim_tukar_faktur', '=', False), ] - invoices = self.env['account.move'].search(query, order='invoice_date') + invoices = self.env['account.move'].search(query) + + # sort by last number in invoice name + try: + invoices = sorted( + invoices, + key=lambda x: int((x.name or '0').split('/')[-1]) + ) + except Exception as e: + _logger.error('Gagal sort invoice number: %s', e) + count = 0 for invoice in invoices: self.env['dunning.run.line'].create([{ @@ -123,8 +132,9 @@ class DunningRunLine(models.Model): _name = 'dunning.run.line' _description = 'Dunning Run Line' # _order = 'dunning_id, id' - _order = 'invoice_id desc, id' + _order = 'invoice_number asc, id' + invoice_number = fields.Char('Invoice Number', related='invoice_id.name') dunning_id = fields.Many2one('dunning.run', string='Dunning Ref', required=True, ondelete='cascade', index=True, copy=False) partner_id = fields.Many2one('res.partner', string='Customer') invoice_id = fields.Many2one('account.move', string='Invoice') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 291940ed..2a0160e8 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -5,6 +5,7 @@ from datetime import datetime, timedelta class SaleOrderLine(models.Model): _inherit = 'sale.order.line' + item_margin = fields.Float('Margin', compute='compute_item_margin', help="Total Margin in Sales Order Header") item_before_margin = fields.Float('Before Margin', compute='compute_item_before_margin', help="Total Margin in Sales Order Header") diff --git a/indoteknik_custom/views/approval_payment_term.xml b/indoteknik_custom/views/approval_payment_term.xml index 44bd99f8..e785b72a 100644 --- a/indoteknik_custom/views/approval_payment_term.xml +++ b/indoteknik_custom/views/approval_payment_term.xml @@ -13,7 +13,14 @@ <field name="approve_sales_manager" optional="hide"/> <field name="approve_finance" optional="hide"/> <field name="approve_leader" optional="hide"/> + <field name="create_date" optional="hide"/> <field name="create_uid" optional="hide"/> + <field name="sale_order_ids" optional="hide" widget="many2many_tags"/> + <field name="total" optional="hide"/> + <field name="grand_total" optional="hide"/> + <field name="state" widget="badge" decoration-danger="state == 'rejected'" + decoration-success="state == 'approved'" + decoration-info="state == 'waiting_approval'"/> </tree> </field> </record> @@ -44,10 +51,10 @@ <field name="number" readonly="1"/> <field name="partner_id"/> <field name="parent_id" readonly="1"/> - <field name="blocking_stage" attrs="{'readonly': [('number', '=', False)]}"/> - <field name="warning_stage" attrs="{'readonly': [('number', '=', False)]}"/> - <field name="property_payment_term_id" attrs="{'readonly': [('number', '=', False)]}"/> - <field name="active_limit" attrs="{'readonly': [('number', '=', False)]}"/> + <field name="blocking_stage" attrs="{'readonly': [('number', '=', False), ('state', 'in', ['approved','rejected'])]}"/> + <field name="warning_stage" attrs="{'readonly': [('number', '=', False), ('state', 'in', ['approved','rejected'])]}"/> + <field name="property_payment_term_id" attrs="{'readonly': [('number', '=', False), ('state', 'in', ['approved','rejected'])]}"/> + <field name="active_limit" attrs="{'readonly': [('number', '=', False), ('state', 'in', ['approved','rejected'])]}"/> </group> <group> <field name="reason"/> @@ -56,6 +63,9 @@ <field name="approve_sales_manager" readonly="1"/> <field name="approve_finance" readonly="1"/> <field name="approve_leader" readonly="1"/> + <field name="sale_order_ids" widget="many2many_tags"/> + <field name="total"/> + <field name="grand_total"/> </group> </group> </sheet> |
