From a39466421a31d2ffd5f2252bf7aac903c4785d83 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 8 Aug 2023 09:47:05 +0700 Subject: add field price vendor --- indoteknik_custom/models/purchase_order_line.py | 12 ++++++++++++ indoteknik_custom/views/purchase_order.xml | 3 +++ 2 files changed, 15 insertions(+) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index f255095f..1b5bba3a 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -28,6 +28,18 @@ class PurchaseOrderLine(models.Model): qty_outgoing = fields.Float('Qty Outgoing', compute='compute_qty_stock') qty_available_store = fields.Float(string='Available') suggest = fields.Char(string='Suggest') + price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') + + + def compute_price_vendor(self): + for line in self: + purchase_pricelist = self.env['purchase.pricelist'].search([ + ('product_id', '=', line.product_id.id), + ('vendor_id', '=', line.partner_id.id) + ], limit=1) + + price_vendor = purchase_pricelist.product_price + line.price_vendor = price_vendor def compute_qty_stock(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 2f8590f3..7d436c46 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -56,6 +56,9 @@ + + + -- cgit v1.2.3 From 30eb623bace6b5ba9a1e275c7bdf70fc5920a583 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 8 Aug 2023 15:29:29 +0700 Subject: sync price unit po & price purchase pricelist --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/purchase_order.py | 9 +++ indoteknik_custom/models/purchase_order_line.py | 6 +- indoteknik_custom/views/mail_template_po.xml | 84 +++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 indoteknik_custom/views/mail_template_po.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index b7aadbdf..252d92b4 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -87,6 +87,7 @@ 'views/account_move_multi_update.xml', 'views/airway_bill.xml', 'views/product_attribute_value.xml', + 'views/mail_template_po.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 7091bb72..38e617e7 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -206,8 +206,17 @@ class PurchaseOrder(models.Model): self.date_planned = delta_time return res + + def _send_mail(self): + template_id = self.env.ref('indoteknik_custom.mail_template_po_sync_price').id + template = self.env['mail.template'].browse(template_id) + template.send_mail(self.id, force_send=True) def po_approve(self): + for line in self.order_line: + if line.price_unit != line.price_vendor: + self._send_mail() + if self.env.user.is_leader or self.env.user.is_purchasing_manager: raise UserError("Bisa langsung Confirm") elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 1b5bba3a..450d3430 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -30,15 +30,15 @@ class PurchaseOrderLine(models.Model): suggest = fields.Char(string='Suggest') price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') - def compute_price_vendor(self): for line in self: purchase_pricelist = self.env['purchase.pricelist'].search([ ('product_id', '=', line.product_id.id), - ('vendor_id', '=', line.partner_id.id) + ('vendor_id', '=', line.order_id.partner_id.id) ], limit=1) - price_vendor = purchase_pricelist.product_price + price_vendor = format(purchase_pricelist.product_price, ".2f") + price_vendor = float(price_vendor) line.price_vendor = price_vendor def compute_qty_stock(self): diff --git a/indoteknik_custom/views/mail_template_po.xml b/indoteknik_custom/views/mail_template_po.xml new file mode 100644 index 00000000..8eb72e12 --- /dev/null +++ b/indoteknik_custom/views/mail_template_po.xml @@ -0,0 +1,84 @@ + + + + + PO: Sync Unit Price Purchase Pricelist + + Your PO ${object.name} + + azkan4elll@gmail.com + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ PO
+ + ${object.name} + +
+
+
+
+ + + + + + + +
+
+ Dear Stefanus Darren, +

+ Terdapat PO yang harga Unit Price nya tidak sama dengan yang ada di purchase pricelist nya. +

+ Berikut adalah rincian PO: + % for line in object.order_line: +
    +
  • Nama Produk: ${line.product_id.name}
  • +
  • Harga Unit dalam PO: ${line.price_unit}
  • +
  • Harga Unit dalam Purchase Pricelist: ${line.price_vendor}
  • +
+ % endfor + Silahkan periksa dan lakukan koreksi jika diperlukan. +

+ Terima kasih. +
+
+
+
+
+
+
+ +
+
+
\ No newline at end of file -- cgit v1.2.3 From 3ef9d136bd238464de7ff0a224b1a68a9b7bb1f3 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 9 Aug 2023 10:32:32 +0700 Subject: add new condition email po --- indoteknik_custom/models/purchase_order.py | 14 +++++++++----- indoteknik_custom/models/purchase_order_line.py | 9 ++++++--- indoteknik_custom/views/mail_template_po.xml | 16 +++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 38e617e7..d73f9037 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -187,13 +187,21 @@ class PurchaseOrder(models.Model): def button_confirm(self): res = super(PurchaseOrder, self).button_confirm() + if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: raise UserError("Beda Margin dengan Sales, harus approval Manager") if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: raise UserError("Tidak ada link dengan SO, harus approval Manager") + send_email = False for line in self.order_line: if not line.product_id.purchase_ok: - raise UserError("Terdapat barang yang tidak bisa di proses") + raise UserError("Terdapat barang yang tidak bisa diproses") + if line.price_vendor != 0 and line.price_unit != line.price_vendor: + send_email = True + break + + if send_email: + self._send_mail() self.approval_status = 'approved' self.po_status = 'menunggu' @@ -213,10 +221,6 @@ class PurchaseOrder(models.Model): template.send_mail(self.id, force_send=True) def po_approve(self): - for line in self.order_line: - if line.price_unit != line.price_vendor: - self._send_mail() - if self.env.user.is_leader or self.env.user.is_purchasing_manager: raise UserError("Bisa langsung Confirm") elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 450d3430..39aeba0f 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -37,9 +37,12 @@ class PurchaseOrderLine(models.Model): ('vendor_id', '=', line.order_id.partner_id.id) ], limit=1) - price_vendor = format(purchase_pricelist.product_price, ".2f") - price_vendor = float(price_vendor) - line.price_vendor = price_vendor + if purchase_pricelist: + price_vendor = format(purchase_pricelist.product_price, ".2f") + price_vendor = float(price_vendor) + line.price_vendor = price_vendor + else: + line.price_vendor = 0 def compute_qty_stock(self): for line in self: diff --git a/indoteknik_custom/views/mail_template_po.xml b/indoteknik_custom/views/mail_template_po.xml index 8eb72e12..77c21837 100644 --- a/indoteknik_custom/views/mail_template_po.xml +++ b/indoteknik_custom/views/mail_template_po.xml @@ -6,11 +6,11 @@ Your PO ${object.name} - azkan4elll@gmail.com + darren@indoteknik.co.id - +
@@ -51,11 +51,13 @@

Berikut adalah rincian PO: % for line in object.order_line: -
    -
  • Nama Produk: ${line.product_id.name}
  • -
  • Harga Unit dalam PO: ${line.price_unit}
  • -
  • Harga Unit dalam Purchase Pricelist: ${line.price_vendor}
  • -
+ % if line.price_vendor != 0 and line.price_unit != line.price_vendor +
    +
  • Nama Produk: ${line.product_id.name}
  • +
  • Harga Unit dalam PO: ${line.price_unit}
  • +
  • Harga Unit dalam Purchase Pricelist: ${line.price_vendor}
  • +
+ % endif % endfor Silahkan periksa dan lakukan koreksi jika diperlukan.

-- cgit v1.2.3 From 4aa5108543075227378b856ce31f478bd5a3b3db Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 9 Aug 2023 11:09:23 +0700 Subject: ledger --- indoteknik_custom/__manifest__.py | 2 - indoteknik_custom/models/__init__.py | 4 - .../models/account_financial_report.py | 39 ---- indoteknik_custom/models/account_general_ledger.py | 134 ------------ .../models/account_report_general_ledger.py | 227 --------------------- .../views/account_financial_report_view.xml | 51 ----- .../views/account_report_general_ledger_view.xml | 37 ---- 7 files changed, 494 deletions(-) delete mode 100644 indoteknik_custom/models/account_financial_report.py delete mode 100644 indoteknik_custom/models/account_general_ledger.py delete mode 100644 indoteknik_custom/models/account_report_general_ledger.py delete mode 100644 indoteknik_custom/views/account_financial_report_view.xml delete mode 100644 indoteknik_custom/views/account_report_general_ledger_view.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 2cd7ad6e..b7aadbdf 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -84,8 +84,6 @@ 'views/product_sla.xml', 'views/voucher.xml', 'views/bill_receipt.xml', - 'views/account_financial_report_view.xml', - 'views/account_report_general_ledger_view.xml', 'views/account_move_multi_update.xml', 'views/airway_bill.xml', 'views/product_attribute_value.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index f26cbec2..1bdbc513 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -75,7 +75,3 @@ from . import account_move_due_extension from . import voucher from . import bill_receipt from . import account_move_multi_update -from . import account_financial_report -from . import account_general_ledger -from . import account_report_financial -from . import account_report_general_ledger \ No newline at end of file diff --git a/indoteknik_custom/models/account_financial_report.py b/indoteknik_custom/models/account_financial_report.py deleted file mode 100644 index 114449ce..00000000 --- a/indoteknik_custom/models/account_financial_report.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -###################################################################################### -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2019-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies(odoo@cybrosys.com) -# -# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) -# It is forbidden to publish, distribute, sublicense, or sell copies of the Software -# or modified copies of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -######################################################################################## - -from datetime import datetime -import json -import datetime -import io -from odoo import api, fields, models, _ -from odoo.tools import date_utils -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter - - -class AccountingReport(models.TransientModel): - _inherit = "accounting.report.xlsx" - - - \ No newline at end of file diff --git a/indoteknik_custom/models/account_general_ledger.py b/indoteknik_custom/models/account_general_ledger.py deleted file mode 100644 index 50d52374..00000000 --- a/indoteknik_custom/models/account_general_ledger.py +++ /dev/null @@ -1,134 +0,0 @@ -import time -from odoo import api, models, _ -from odoo.exceptions import UserError - - -class ReportGeneralLedger(models.AbstractModel): - _name = 'report.account.report_generalledger' - - def _get_account_move_entry_custom(self, accounts, init_balance, sortby, display_account): - """ - :param: - accounts: the recordset of accounts - init_balance: boolean value of initial_balance - sortby: sorting by date or partner and journal - display_account: type of account(receivable, payable and both) - - Returns a dictionary of accounts with following key and value { - 'code': account code, - 'name': account name, - 'debit': sum of total debit amount, - 'credit': sum of total credit amount, - 'balance': total balance, - 'amount_currency': sum of amount_currency, - 'move_lines': list of move line - } - """ - cr = self.env.cr - MoveLine = self.env['account.move.line'] - move_lines = {x: [] for x in accounts.ids} - - # Prepare initial sql query and Get the initial move lines - if init_balance: - init_tables, init_where_clause, init_where_params = MoveLine.with_context(date_from=self.env.context.get('date_from'), date_to=False, initial_bal=True)._query_get() - init_wheres = [""] - if init_where_clause.strip(): - init_wheres.append(init_where_clause.strip()) - init_filters = " AND ".join(init_wheres) - filters = init_filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l') - sql = ("""SELECT 0 AS lid, l.account_id AS account_id, '' AS ldate, '' AS lcode, 0.0 AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance, '' AS lpartner_id,\ - '' AS move_name, '' AS mmove_id, '' AS currency_code,\ - NULL AS currency_id,\ - '' AS invoice_id, '' AS invoice_type, '' AS invoice_number,\ - '' AS partner_name\ - FROM account_move_line l\ - LEFT JOIN account_move m ON (l.move_id=m.id)\ - LEFT JOIN res_currency c ON (l.currency_id=c.id)\ - LEFT JOIN res_partner p ON (l.partner_id=p.id)\ - LEFT JOIN account_move i ON (m.id =i.id)\ - JOIN account_journal j ON (l.journal_id=j.id)\ - WHERE l.account_id IN %s""" + filters + ' GROUP BY l.account_id') - params = (tuple(accounts.ids),) + tuple(init_where_params) - cr.execute(sql, params) - for row in cr.dictfetchall(): - move_lines[row.pop('account_id')].append(row) - - sql_sort = 'l.date, l.move_id' - if sortby == 'sort_journal_partner': - sql_sort = 'j.code, p.name, l.move_id' - - # Prepare sql query base on selected parameters from wizard - tables, where_clause, where_params = MoveLine._query_get() - wheres = [""] - if where_clause.strip(): - wheres.append(where_clause.strip()) - filters = " AND ".join(wheres) - filters = filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l') - - # Get move lines base on sql query and Calculate the total balance of move lines - sql = ('''SELECT l.id AS lid, l.account_id AS account_id, l.date AS ldate, j.code AS lcode, l.currency_id, l.amount_currency, l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) AS balance,\ - m.name AS move_name, c.symbol AS currency_code, p.name AS partner_name\ - FROM account_move_line l\ - JOIN account_move m ON (l.move_id=m.id)\ - LEFT JOIN res_currency c ON (l.currency_id=c.id)\ - LEFT JOIN res_partner p ON (l.partner_id=p.id)\ - JOIN account_journal j ON (l.journal_id=j.id)\ - JOIN account_account acc ON (l.account_id = acc.id) \ - WHERE l.account_id IN %s ''' + filters + ''' GROUP BY l.id, l.account_id, l.date, j.code, l.currency_id, l.amount_currency, l.ref, l.name, m.name, c.symbol, p.name ORDER BY ''' + sql_sort) - params = (tuple(accounts.ids),) + tuple(where_params) - cr.execute(sql, params) - - for row in cr.dictfetchall(): - balance = 0 - for line in move_lines.get(row['account_id']): - balance += line['debit'] - line['credit'] - row['balance'] += balance - move_lines[row.pop('account_id')].append(row) - - # Calculate the debit, credit and balance for Accounts - account_res = [] - for account in accounts: - currency = account.currency_id and account.currency_id or account.company_id.currency_id - res = dict((fn, 0.0) for fn in ['credit', 'debit', 'balance', 'balance_month']) - res['code'] = account.code - res['name'] = account.name - res['company_id'] = account.company_id.id - res['move_lines'] = move_lines[account.id] - for line in res.get('move_lines'): - res['debit'] += line['debit'] - res['credit'] += line['credit'] - res['balance'] = line['balance'] - if display_account == 'all': - account_res.append(res) - if display_account == 'movement' and res.get('move_lines'): - account_res.append(res) - if display_account == 'not_zero' and not currency.is_zero(res['balance']): - account_res.append(res) - return account_res - - @api.model - def _get_report_values(self, docids, data=None): - if not data.get('form') or not self.env.context.get('active_model'): - raise UserError(_("Form content is missing, this report cannot be printed.")) - - model = self.env.context.get('active_model') - docs = self.env[model].browse(self.env.context.get('active_ids', [])) - - init_balance = data['form'].get('initial_balance', True) - sortby = data['form'].get('sortby', 'sort_date') - display_account = data['form']['display_account'] - codes = [] - if data['form'].get('journal_ids', False): - codes = [journal.code for journal in self.env['account.journal'].search([('id', 'in', data['form']['journal_ids'])])] - - accounts = docs if model == 'account.account' else self.env['account.account'].search([]) - accounts_res = self.with_context(data['form'].get('used_context',{}))._get_account_move_entry_custom(accounts, init_balance, sortby, display_account) - return { - 'doc_ids': docids, - 'doc_model': model, - 'data': data['form'], - 'docs': docs, - 'time': time, - 'Accounts': accounts_res, - 'print_journal': codes, - } diff --git a/indoteknik_custom/models/account_report_general_ledger.py b/indoteknik_custom/models/account_report_general_ledger.py deleted file mode 100644 index 4e909872..00000000 --- a/indoteknik_custom/models/account_report_general_ledger.py +++ /dev/null @@ -1,227 +0,0 @@ -from datetime import datetime -from dateutil.relativedelta import relativedelta -from odoo.exceptions import UserError -import json -from datetime import timedelta, date -import datetime -import io -from odoo import api, fields, models, _ -from odoo.tools.float_utils import float_round -from odoo.tools import date_utils -try: - from odoo.tools.misc import xlsxwriter -except ImportError: - import xlsxwriter - -class AccountReportGeneralLedger(models.TransientModel): - _inherit = "account.report.general.ledger.xlsx" - - journal_ids = fields.Many2many('account.journal', string=_('Journals'), required=True,default=lambda self: self.env['account.journal'].search([('id', '=', 10)])) - - def _build_contexts(self, data): - result = {} - result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False - result['state'] = 'target_move' in data['form'] and data['form']['target_move'] or '' - date_from = data['form']['date_from'] or False - - if date_from: - date_from = fields.Date.from_string(date_from) - - date_from -= relativedelta(days=1) - - result['date_from'] = fields.Date.to_string(date_from) - else: - result['date_from'] = False - - result['date_to'] = data['form']['date_to'] or False - result['strict_range'] = True if result['date_from'] else False - return result - - def check_report_ledger(self): - self.ensure_one() - data = {} - data['ids'] = self.env.context.get('active_ids', []) - data['model'] = self.env.context.get('active_model', 'ir.ui.menu') - data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move'])[0] - used_context = self._build_contexts(data) - data['form']['used_context'] = dict(used_context, lang=self.env.context.get('lang') or 'en_US') - return { - 'type': 'ir.actions.report', - 'data': {'model': 'account.report.general.ledger.xlsx', - 'options': json.dumps(data, default=date_utils.json_default), - 'output_format': 'xlsx', - 'report_name': 'general ledger report', - }, - 'report_type': 'xlsx' - } - - def get_xlsx_report(self, options, response): - output = io.BytesIO() - workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - data = {} - vals = self.search([('id', '=', options['form']['id'])]) - data['form'] = vals.read([])[0] - data['model'] = 'ir.ui.menu' - data['ids'] = [] - data['form']['used_context'] = { - 'date_to': options['form'].get('date_to', False), - 'date_from': options['form'].get('date_from', False), - 'strict_range': True, - 'state': options['form']['target_move'], - 'journal_ids': options['form']['journal_ids'], - } - - env_obj = vals.env['report.account.report_generalledger'] - sortby = data['form'].get('sortby', 'sort_date') - display_account = data['form']['display_account'] - codes = [] - if data['form'].get('journal_ids', False): - codes = [journal.code for journal in self.env['account.journal'].search([('id', 'in', data['form']['journal_ids'])])] - # accounts = vals.active_account if vals.active_account else self.env['account.account'].search([]) - accounts = self.env['account.account'].browse(options['ids']) or self.env['account.account'].search([]) - init_balance = vals['initial_balance'] - date_from = options['form'].get('date_from', False) - date_to = options['form'].get('date_to', False) - report_obj = env_obj.with_context(data['form'].get('used_context', {}))._get_account_move_entry_custom( - accounts, init_balance, sortby, display_account) - sheet = workbook.add_worksheet() - format1 = workbook.add_format({'font_size': 16, 'align': 'center', 'bg_color': '#D3D3D3', 'bold': True}) - format1.set_font_color('#000080') - format2 = workbook.add_format({'font_size': 12, 'bold': True, 'bg_color': '#D3D3D3'}) - format3 = workbook.add_format({'font_size': 10, 'bold': True}) - format4 = workbook.add_format({'font_size': 10}) - format6 = workbook.add_format({'font_size': 10, 'bold': True}) - format7 = workbook.add_format({'font_size': 10, 'align': 'center'}) - format5 = workbook.add_format({'font_size': 10, 'align': 'right'}) - format1.set_align('center') - format2.set_align('center') - format3.set_align('right') - format4.set_align('left') - codes = [] - if data['form'].get('journal_ids', False): - codes = [journal.code for journal in - self.env['account.journal'].search([('id', 'in', data['form']['journal_ids'])])] - logged_users = self.env['res.company']._company_default_get('account.account') - report_date = datetime.datetime.now().strftime("%Y-%m-%d") - sheet.merge_range('M8:N8', _("Report Date"), format3) - sheet.merge_range('M9:N9', report_date, format4) - sheet.merge_range(1, 0, 1, 14, logged_users.name, format4) - sheet.merge_range(3, 0, 4, 14, _("General Ledger Report"), format1) - sheet.merge_range('A6:B6', _("Journals :"), format6) - - row = 6 - col = 0 - i = 0 - for values in codes: - sheet.write(row, col + i, values, format7) - i += 1 - if data['form']['display_account'] == 'all': - display_account = _('All accounts') - elif data['form']['display_account'] == 'movement': - display_account = _('With movements') - else: - display_account = _('With balance not equal to zero') - - if data['form']['target_move'] == 'all': - target_moves = _('All entries') - else: - target_moves = _('All posted entries') - - if data['form']['sortby'] == 'sort_date': - sortby = 'Date' - else: - sortby = 'Journal and partners' - if data['form']['date_from']: - date_start = datetime.datetime.strptime(str(data['form']['used_context']['date_from']), '%Y-%m-%d') - date_start = date_start.strftime('%Y-%m-%d') - else: - date_start = "" - if data['form']['date_to']: - date_end = datetime.datetime.strptime(str(data['form']['used_context']['date_to']), '%Y-%m-%d') - date_end = date_end.strftime('%Y-%m-%d') - else: - date_end = "" - if sortby == 'Date': - sheet.write('G8', _("Start Date"), format3) - sheet.write('G9', date_start, format4) - sheet.write('J8', _("End Date"), format3) - sheet.write('J9', date_end, format4) - sheet.merge_range('C8:D8', _("Sorted By"), format3) - sheet.merge_range('C9:D9', sortby, format4) - sheet.merge_range('A8:B8', _("Display Account"), format6) - sheet.merge_range('A9:B9', display_account, format7) - sheet.merge_range('E8:F8', _("Target Moves"), format6) - sheet.merge_range('E9:F9', target_moves, format7) - sheet.write('A11', "Date ", format2) - sheet.write('B11', "JRNL", format2) - sheet.merge_range('C11:D11', _("Partner"), format2) - sheet.merge_range('E11:F11', _("Ref"), format2) - sheet.merge_range('G11:H11', _("Move"), format2) - sheet.merge_range('I11:L11', _("Entry Label"), format2) - sheet.write('M11', _("Debit"), format2) - sheet.write('N11', _("Credit"), format2) - sheet.write('O11', _("Balance"), format2) - sheet.write('P11', _("Debit Month"), format2) - sheet.write('Q11', _("Credit Month"), format2) - sheet.write('R11', _("Balance Month"), format2) - accounts = self.env['account.account'].search([]) - row_number = 11 - col_number = 0 - for account in accounts: - for values in report_obj: - if account['name'] == values['name'] and account['company_id'].id == values['company_id']: - sheet.write(row_number, col_number, account['code'], format3) - sheet.merge_range(row_number, col_number + 1, row_number, col_number + 11, account['name'], format6) - sheet.write(row_number, col_number + 12, - logged_users.currency_id.symbol + ' ' + "{:,.2f}".format(values['debit']), format3) - sheet.write(row_number, col_number + 13, - logged_users.currency_id.symbol + ' ' + "{:,.2f}".format(values['credit']), format3) - sheet.write(row_number, col_number + 14, - logged_users.currency_id.symbol + ' ' + "{:,.2f}".format(values['balance']), format3) - row_number += 1 - for lines in values['move_lines']: - if lines['ldate']: - formatted_date = datetime.datetime.strptime(str(lines['ldate']), '%Y-%m-%d') - formatted_date = formatted_date.strftime('%Y-%m-%d') - else: - formatted_date = "" - - sheet.write(row_number, col_number, formatted_date, format4) - sheet.write(row_number, col_number + 1, lines['lcode'], format4) - sheet.merge_range(row_number, col_number + 2, row_number, col_number + 3, lines['partner_name'], - format4) - sheet.merge_range(row_number, col_number + 4, row_number, col_number + 5, lines['lref'], - format4) - sheet.merge_range(row_number, col_number + 6, row_number, col_number + 7, lines['move_name'], - format4) - sheet.merge_range(row_number, col_number + 8, row_number, col_number + 11, lines['lname'], - format4) - sheet.write(row_number, col_number + 12, "{:,}".format(lines['debit']), format5) - sheet.write(row_number, col_number + 13, "{:,.2f}".format(lines['credit']), format5) - sheet.write(row_number, col_number + 14, "{:,.2f}".format(lines['balance']), format5) - - if lines['lname'] == 'Initial Balance': - debit_value = lines.get('debit', 0.0) - value_debit = values.get('debit', 0.0) - total_debit = value_debit - debit_value - debit_month = "{:,.2f}".format(total_debit) - - credit_value = lines.get('credit', 0.0) - value_credit = values.get('credit', 0.0) - total_credit = value_credit - credit_value - credit_month = "{:,.2f}".format(total_credit) - - total_balance = total_debit - total_credit - balance_month = "{:,.2f}".format(total_balance) - sheet.write(row_number, col_number + 15, debit_month, format5) - sheet.write(row_number, col_number + 16, credit_month, format5) - sheet.write(row_number, col_number + 17, balance_month, format5) - - row_number += 1 - - - workbook.close() - output.seek(0) - response.stream.write(output.read()) - output.close() - diff --git a/indoteknik_custom/views/account_financial_report_view.xml b/indoteknik_custom/views/account_financial_report_view.xml deleted file mode 100644 index 31c04e7c..00000000 --- a/indoteknik_custom/views/account_financial_report_view.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - Common Report - accounting.report.xlsx - -
- - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- - - Financial Reports - accounting.report.xlsx - ir.actions.act_window - form - - new - - - - -
diff --git a/indoteknik_custom/views/account_report_general_ledger_view.xml b/indoteknik_custom/views/account_report_general_ledger_view.xml deleted file mode 100644 index b789874f..00000000 --- a/indoteknik_custom/views/account_report_general_ledger_view.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - Export Ledger - account.report.general.ledger.xlsx - -
- - - - - - - - - - - - -
-
- -
-
- - - export_ledger - account.report.general.ledger.xlsx - form - - new - - - -
\ No newline at end of file -- cgit v1.2.3 From eababb6272797427353ccc5a58609ceac6ceea1c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 9 Aug 2023 15:05:55 +0700 Subject: ledger --- indoteknik_custom/__manifest__.py | 2 +- indoteknik_custom/models/__init__.py | 2 +- .../models/account_financial_report.py | 22 ---------------------- indoteknik_custom/models/account_general_ledger.py | 1 - .../models/account_report_financial.py | 22 ---------------------- .../models/account_report_general_ledger.py | 1 - .../views/account_financial_report_view.xml | 2 +- .../views/account_report_general_ledger_view.xml | 2 +- 8 files changed, 4 insertions(+), 50 deletions(-) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 362b2b2b..7c669810 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -84,7 +84,7 @@ 'views/product_sla.xml', 'views/voucher.xml', 'views/bill_receipt.xml', - 'views/account_financial_report_view.xml', + 'views/account_financial_report_view.xml', 'views/account_report_general_ledger_view.xml', 'views/account_move_multi_update.xml', 'report/report.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 45c30473..8c7071e3 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -76,4 +76,4 @@ from . import account_move_multi_update from . import account_financial_report from . import account_general_ledger from . import account_report_financial -from . import account_report_general_ledger \ No newline at end of file +from . import account_report_general_ledger diff --git a/indoteknik_custom/models/account_financial_report.py b/indoteknik_custom/models/account_financial_report.py index 114449ce..1bf6816a 100644 --- a/indoteknik_custom/models/account_financial_report.py +++ b/indoteknik_custom/models/account_financial_report.py @@ -1,25 +1,3 @@ -# -*- coding: utf-8 -*- -###################################################################################### -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2019-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies(odoo@cybrosys.com) -# -# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) -# It is forbidden to publish, distribute, sublicense, or sell copies of the Software -# or modified copies of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -######################################################################################## - from datetime import datetime import json import datetime diff --git a/indoteknik_custom/models/account_general_ledger.py b/indoteknik_custom/models/account_general_ledger.py index 50d52374..e80696a4 100644 --- a/indoteknik_custom/models/account_general_ledger.py +++ b/indoteknik_custom/models/account_general_ledger.py @@ -2,7 +2,6 @@ import time from odoo import api, models, _ from odoo.exceptions import UserError - class ReportGeneralLedger(models.AbstractModel): _name = 'report.account.report_generalledger' diff --git a/indoteknik_custom/models/account_report_financial.py b/indoteknik_custom/models/account_report_financial.py index 9ed526da..c11fa25b 100644 --- a/indoteknik_custom/models/account_report_financial.py +++ b/indoteknik_custom/models/account_report_financial.py @@ -1,25 +1,3 @@ -# -*- coding: utf-8 -*- -###################################################################################### -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2020-TODAY Cybrosys Technologies(). -# Author: Cybrosys Technologies (odoo@cybrosys.com) -# -# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) -# It is forbidden to publish, distribute, sublicense, or sell copies of the Software -# or modified copies of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -######################################################################################## - import time from odoo import api, models, _ from odoo.exceptions import UserError diff --git a/indoteknik_custom/models/account_report_general_ledger.py b/indoteknik_custom/models/account_report_general_ledger.py index 4e909872..54e5bbd7 100644 --- a/indoteknik_custom/models/account_report_general_ledger.py +++ b/indoteknik_custom/models/account_report_general_ledger.py @@ -218,7 +218,6 @@ class AccountReportGeneralLedger(models.TransientModel): sheet.write(row_number, col_number + 17, balance_month, format5) row_number += 1 - workbook.close() output.seek(0) diff --git a/indoteknik_custom/views/account_financial_report_view.xml b/indoteknik_custom/views/account_financial_report_view.xml index 31c04e7c..7c156599 100644 --- a/indoteknik_custom/views/account_financial_report_view.xml +++ b/indoteknik_custom/views/account_financial_report_view.xml @@ -1,6 +1,6 @@ - + Common Report accounting.report.xlsx diff --git a/indoteknik_custom/views/account_report_general_ledger_view.xml b/indoteknik_custom/views/account_report_general_ledger_view.xml index b789874f..61c0ffff 100644 --- a/indoteknik_custom/views/account_report_general_ledger_view.xml +++ b/indoteknik_custom/views/account_report_general_ledger_view.xml @@ -1,5 +1,5 @@ - + Export Ledger account.report.general.ledger.xlsx -- cgit v1.2.3