diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-10 14:45:54 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-10 14:45:54 +0700 |
| commit | 3de9e2a7e2b9b455fa85e33231612996538830f4 (patch) | |
| tree | c31cd2576cc20a1655af84eda29335d67b216c90 | |
| parent | 519d2466e550ccf382466b8bb46af84169f3267b (diff) | |
| parent | dec973e8e6b8647e8762ab6ce32d90df371cd24b (diff) | |
Merge branch 'release' of bitbucket.org:altafixco/indoteknik-addons into release
| -rw-r--r-- | indoteknik_custom/models/dunning_run.py | 7 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 8 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 23 | ||||
| -rw-r--r-- | indoteknik_custom/views/dunning_run.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 7 |
6 files changed, 49 insertions, 7 deletions
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index ee0669ca..8e5b2c19 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -23,13 +23,14 @@ class DunningRun(models.Model): date_terima_tukar_faktur = fields.Date(string='Terima Faktur') shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') is_validated = fields.Boolean(string='Validated') + notification = fields.Char(string='Notification') def copy_date_faktur(self): if not self.is_validated: raise UserError('Harus di validate dulu') for line in self.dunning_line: invoice = line.invoice_id - if not invoice.date_kirim_tukar_faktur: + if not invoice.date_kirim_tukar_faktur and self.date_kirim_tukar_faktur: invoice.date_kirim_tukar_faktur = self.date_kirim_tukar_faktur tukar_date = self.date_kirim_tukar_faktur term = invoice.invoice_payment_term_id @@ -40,7 +41,7 @@ class DunningRun(models.Model): invoice.invoice_date_due = due_date if not invoice.resi_tukar_faktur: invoice.resi_tukar_faktur = self.resi_tukar_faktur - if not invoice.date_terima_tukar_faktur: + if not invoice.date_terima_tukar_faktur and self.date_terima_tukar_faktur: invoice.date_terima_tukar_faktur = self.date_terima_tukar_faktur tukar_date = self.date_terima_tukar_faktur term = invoice.invoice_payment_term_id @@ -51,12 +52,14 @@ class DunningRun(models.Model): invoice.invoice_date_due = due_date if not invoice.shipper_faktur_id: invoice.shipper_faktur_id = self.shipper_faktur_id + self.notification = 'Berhasil copy tanggal terima faktur ke setiap invoice %s' % self.date_terima_tukar_faktur def validate_dunning(self): if not self.dunning_line: raise UserError('Dunning Line masih kosong, generate dulu') else: self.is_validated = True + self.notification = 'Jangan lupa klik Copy Date jika sudah ada tanggal kirim / tanggal terima faktur' def generate_dunning_line(self): if self.is_validated: diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index b4d671b6..0ef6a9f2 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -38,6 +38,12 @@ class PurchaseOrder(models.Model): summary_qty_receipt = fields.Float('Summary Qty Receipt', compute='_compute_summary_qty') count_line_product = fields.Float('Total Item', compute='compute_count_line_product') + def action_create_invoice(self): + res = super(PurchaseOrder, self).action_create_invoice() + if not self.env.user.is_accounting: + raise UserError('Hanya Accounting yang bisa membuat Bill') + return res + def calculate_line_no(self): line_no = 0 for line in self.order_line: @@ -169,6 +175,8 @@ class PurchaseOrder(models.Model): self.approval_status = 'approved' self.po_status = 'menunggu' + self.calculate_line_no() + return res def po_approve(self): diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7d7eb86c..f21554f7 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -67,6 +67,14 @@ class SaleOrder(models.Model): ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') + def calculate_line_no(self): + line_no = 0 + for line in self.order_line: + if line.product_id.type == 'product': + line_no += 1 + line.line_no = line_no + # _logger.info('Calculate PO Line No %s' % line.id) + def calculate_so_status_beginning(self): so_state = ['sale'] sales = self.env['sale.order'].search([ @@ -273,6 +281,7 @@ class SaleOrder(models.Model): raise UserError("Harus diapprove oleh Manager") else: order.approval_status = 'approved' + order.calculate_line_no() return res @@ -331,6 +340,7 @@ class SaleOrderLine(models.Model): domain=['|', ('active', '=', False), ('active', '=', True)]) delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) + line_no = fields.Integer('No', default=0) def compute_item_margin(self): for line in self: diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 9599548c..4049c535 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -95,13 +95,25 @@ class StockPicking(models.Model): pick.approval_return_status = 'pengajuan1' def calculate_line_no(self): - line_no = 0 for picking in self: for line in picking.move_ids_without_package: - if line.product_id.type == 'product': - line_no += 1 - line.line_no = line_no - # _logger.info('Calculate PO Line No %s' % line.id) + # order_lines = picking.group_id.order_line + name = picking.group_id.name + if picking.group_id.sale_id: + order = self.env['sale.order'].search([('name', '=', name)], limit=1) + else: + order = self.env['purchase.order'].search([('name', '=', name)], limit=1) + + order_lines = order.order_line + set_line = 0 + + for order_line in order_lines: + if line.product_id == order_line.product_id: + set_line = order_line.line_no + break + else: + continue + line.line_no = set_line def _compute_summary_qty(self): sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0 @@ -153,6 +165,7 @@ class StockPicking(models.Model): self.approval_status = 'approved' res = super(StockPicking, self).button_validate() + self.calculate_line_no() return res @api.model diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index 6343a79b..cae9cc32 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -63,6 +63,7 @@ <field name="number"/> <field name="partner_id"/> <field name="dunning_date"/> + <field name="notification" readonly="1"/> </group> <group> <field name="is_validated" readonly="1"/> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 9dfd9805..1b6f31aa 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -7,6 +7,10 @@ <field name="inherit_id" ref="sale.view_order_form"/> <field name="arch" type="xml"> <button id="action_confirm" position="after"> + <button name="calculate_line_no" + string="Create No" + type="object" + /> <button name="sale_order_approve" string="Ask Approval" type="object" @@ -50,6 +54,9 @@ <field name="purchase_tax_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}" domain="[('type_tax_use','=','purchase')]"/> <field name="item_percent_margin"/> </xpath> + <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before"> + <field name="line_no" readonly="1"/> + </xpath> <field name="amount_total" position="after"> <field name="total_margin"/> <field name="total_percent_margin"/> |
