diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-12-18 09:31:54 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-12-18 09:31:54 +0700 |
| commit | 7099c4615aa3435273839c49ceee121306fec84d (patch) | |
| tree | 81d305474cb66747955aaf0c571a3ef81b8baad3 | |
| parent | 07e8a51fc023025d2cbde83ab0333e5e53e2ad12 (diff) | |
| parent | 8fc9eddc57f76f62c3efaa70c9a3aee8be1911fa (diff) | |
Merge branch 'production' into purchasing-job
# Conflicts:
# indoteknik_custom/models/__init__.py
# indoteknik_custom/security/ir.model.access.csv
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 11 | ||||
| -rw-r--r-- | indoteknik_custom/models/commision.py | 14 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_advance_payment_inv.py | 37 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 47 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move.xml | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/customer_commision.xml | 4 |
8 files changed, 108 insertions, 10 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 7a6b4251..4faf969d 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -93,5 +93,6 @@ from . import product_monitoring from . import account_bank_statement from . import stock_warehouse_orderpoint from . import commision +from . import sale_advance_payment_inv from . import purchasing_job from . import purchasing_job_multi_update diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 699191d6..82a86a39 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -31,6 +31,17 @@ class AccountMove(models.Model): due_line = fields.One2many('due.extension.line', 'invoice_id', compute='_compute_due_line', string='Due Extension Lines') no_faktur_pajak = fields.Char(string='No Faktur Pajak') date_completed = fields.Datetime(string='Date Completed') + mark_upload_efaktur = fields.Selection([ + ('belum_upload', 'Belum Upload FP'), + ('sudah_upload', 'Sudah Upload FP'), + ], 'Mark Upload Faktur', compute='_compute_mark_upload_efaktur', default='belum_upload') + + def _compute_mark_upload_efaktur(self): + for move in self: + if move.date_efaktur_exported or move.is_efaktur_exported or move.efaktur_document: + move.mark_upload_efaktur = 'sudah_upload' + else: + move.mark_upload_efaktur = 'belum_upload' def _compute_due_line(self): for invoice in self: diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index a11d85c7..a9ad624c 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -131,7 +131,7 @@ class CustomerCommision(models.Model): number = fields.Char(string='Document No', index=True, copy=False, readonly=True) date_from = fields.Date(string='Date From', required=True) date_to = fields.Date(string='Date To', required=True) - partner_id = fields.Many2one('res.partner', String='Customer', required=True) + partner_ids = fields.Many2many('res.partner', String='Customer', required=True) description = fields.Char(string='Description') notification = fields.Char(string='Notification') commision_lines = fields.One2many('customer.commision.line', 'customer_commision_id', string='Lines', auto_join=True) @@ -202,9 +202,9 @@ class CustomerCommision(models.Model): self._generate_customer_commision_rebate() def _generate_customer_commision_rebate(self): - partners = [] - partners += self.partner_id.child_ids - partners.append(self.partner_id) + for rec in self: + # partners = rec.partner_ids.child_ids + rec.partner_ids + partners = rec.partner_ids for partner in partners: brand = [92, 10, 89, 12, 324, 11] @@ -234,9 +234,9 @@ class CustomerCommision(models.Model): return def _generate_customer_commision_fee(self): - partners = [] - partners += self.partner_id.child_ids - partners.append(self.partner_id) + for rec in self: + # partners = rec.partner_ids.child_ids + rec.partner_ids + partners = rec.partner_ids for partner in partners: where = [ diff --git a/indoteknik_custom/models/sale_advance_payment_inv.py b/indoteknik_custom/models/sale_advance_payment_inv.py index e07d0ee0..dde7ed74 100644 --- a/indoteknik_custom/models/sale_advance_payment_inv.py +++ b/indoteknik_custom/models/sale_advance_payment_inv.py @@ -5,6 +5,42 @@ from odoo.exceptions import UserError class SaleAdvancePaymentInv(models.TransientModel): _inherit = 'sale.advance.payment.inv' + def _prepare_invoice_values(self, order, name, amount, so_line): + parent_id = order.partner_id.parent_id + parent_id = parent_id if parent_id else order.partner_id + + invoice_vals = { + 'ref': order.client_order_ref, + 'move_type': 'out_invoice', + 'invoice_origin': order.name, + 'invoice_user_id': order.user_id.id, + 'narration': order.note, + 'partner_id': parent_id, + 'fiscal_position_id': (order.fiscal_position_id or order.fiscal_position_id.get_fiscal_position(order.partner_id.id)).id, + 'partner_shipping_id': parent_id.id, + 'currency_id': order.pricelist_id.currency_id.id, + 'payment_reference': order.reference, + 'invoice_payment_term_id': order.payment_term_id.id, + 'partner_bank_id': order.company_id.partner_id.bank_ids[:1].id, + 'team_id': order.team_id.id, + 'campaign_id': order.campaign_id.id, + 'medium_id': order.medium_id.id, + 'source_id': order.source_id.id, + 'invoice_line_ids': [(0, 0, { + 'name': name, + 'price_unit': amount, + 'quantity': 1.0, + 'product_id': self.product_id.id, + 'product_uom_id': so_line.product_uom.id, + 'tax_ids': [(6, 0, so_line.tax_id.ids)], + 'sale_line_ids': [(6, 0, [so_line.id])], + 'analytic_tag_ids': [(6, 0, so_line.analytic_tag_ids.ids)], + 'analytic_account_id': order.analytic_account_id.id or False, + })], + } + + return invoice_vals + def create_invoices(self): sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', [])) @@ -40,7 +76,6 @@ class SaleAdvancePaymentInv(models.TransientModel): if self._context.get('open_invoices', False): return sale_orders.action_view_invoice() return {'type': 'ir.actions.act_window_close'} - # def _create_invoices(self, grouped=False, final=False, date=None): # """ # Create the invoice associated to the SO. diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 55a6bd26..9f31c0fd 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -84,6 +84,53 @@ class SaleOrder(models.Model): helper_by_id = fields.Many2one('res.users', 'Helper By') # picking_ids = fields.Many2many('stock.picking', string='Pickings', compute='_get_pickings', readonly=True, copy=False, search="_search_picking_ids") + def _prepare_invoice(self): + """ + Prepare the dict of values to create the new invoice for a sales order. This method may be + overridden to implement custom invoice generation (making sure to call super() to establish + a clean extension chain). + """ + self.ensure_one() + journal = self.env['account.move'].with_context(default_move_type='out_invoice')._get_default_journal() + if not journal: + raise UserError(_('Please define an accounting sales journal for the company %s (%s).') % (self.company_id.name, self.company_id.id)) + + parent_id = self.partner_id.parent_id + parent_id = parent_id if parent_id else self.partner_id + + invoice_vals = { + 'ref': self.client_order_ref or '', + 'move_type': 'out_invoice', + 'narration': self.note, + 'currency_id': self.pricelist_id.currency_id.id, + 'campaign_id': self.campaign_id.id, + 'medium_id': self.medium_id.id, + 'source_id': self.source_id.id, + 'user_id': self.user_id.id, + 'invoice_user_id': self.user_id.id, + 'team_id': self.team_id.id, + 'partner_id': parent_id.id, + 'partner_shipping_id': parent_id.id, + 'fiscal_position_id': (self.fiscal_position_id or self.fiscal_position_id.get_fiscal_position(self.partner_invoice_id.id)).id, + 'partner_bank_id': self.company_id.partner_id.bank_ids[:1].id, + 'journal_id': journal.id, # company comes from the journal + 'invoice_origin': self.name, + 'invoice_payment_term_id': self.payment_term_id.id, + 'payment_reference': self.reference, + 'transaction_ids': [(6, 0, self.transaction_ids.ids)], + 'invoice_line_ids': [], + 'company_id': self.company_id.id, + } + return invoice_vals + + @api.constrains('email') + def _validate_email(self): + rule_regex = self.env['ir.config_parameter'].sudo().get_param('sale.order.validate_email') or '' + pattern = rf'^{rule_regex}$' + + if self.email and not re.match(pattern, self.email): + raise UserError('Email harus menggunakan karakter @') + def override_allow_create_invoice(self): if not self.env.user.is_accounting: raise UserError('Hanya Finance Accounting yang dapat klik tombol ini') diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 6ba720c2..09801dbc 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -85,5 +85,6 @@ access_customer_rebate,access.customer.rebate,model_customer_rebate,,1,1,1,1 access_wati_history,access.wati.history,model_wati_history,,1,1,1,1 access_wati_history_line,access.wati.history.line,model_wati_history_line,,1,1,1,1 access_v_purchasing_job,access.v.purchasing.job,model_v_purchasing_job,,1,1,1,1 +access_sale_advance_payment_inv,access.sale.advance.payment.inv,model_sale_advance_payment_inv,,1,1,1,1 access_purchasing_job_multi_update,access.purchasing.job.multi.update,model_purchasing_job_multi_update,,1,1,1,1 access_automatic_purchase_sales_match,access.automatic.purchase.sales.match,model_automatic_purchase_sales_match,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index b0a206bf..7995b83b 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -56,6 +56,9 @@ </field> <field name="invoice_date_due" position="after"> <field name="invoice_day_to_due" attrs="{'invisible': [['payment_state', 'in', ('paid', 'in_payment', 'reversed')]]}"/> + <field name="mark_upload_efaktur" optional="hide" widget="badge" + decoration-danger="mark_upload_efaktur == 'belum_upload'" + decoration-success="mark_upload_efaktur == 'sudah_upload'" /> <field name="due_extension" optional="hide"/> </field> <field name="payment_state" position="after"> diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index 993521ca..88fe1cf1 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -8,7 +8,7 @@ <field name="number"/> <field name="date_from"/> <field name="date_to"/> - <field name="partner_id"/> + <field name="partner_ids"/> <field name="description"/> <field name="notification" readonly="1"/> <field name="status" readonly="1"/> @@ -48,7 +48,7 @@ <group> <field name="number"/> <field name="date_from"/> - <field name="partner_id"/> + <field name="partner_ids" widget="many2many_tags"/> <field name="description"/> <field name="commision_percent"/> <field name="commision_amt"/> |
